Esempio n. 1
0
        public Instruction(InstructionTemplate template, ushort opcode)
        {
            Handler = template.Handler;
            Format  = template.Format;

            Arguments = (Generic.DataStructures.InstructionArgs) new InstructionArgs(template.Type);
            ((InstructionArgs)Arguments).SetArguments(opcode);
        }
Esempio n. 2
0
        public InstructionDictionary(Processor proc)
            : base()
        {
            Processor = proc;

            Instructions["00E0"] = new InstructionTemplate(InstructionType.NoArguments, "CLS", (Generic.DataStructures.InstructionHandler)clearScreen);
            Instructions["00EE"] = new InstructionTemplate(InstructionType.NoArguments, "RET", (Generic.DataStructures.InstructionHandler)returnFromSubroutine);
            Instructions["1XXX"] = new InstructionTemplate(InstructionType.OneArgument12Bits, "JP 0x{0:X4}", (Generic.DataStructures.InstructionHandler)jumpToAddress);
            Instructions["2XXX"] = new InstructionTemplate(InstructionType.OneArgument12Bits, "CALL 0x{0:X4}", (Generic.DataStructures.InstructionHandler)callSubroutineAtAddress);
            Instructions["3XXX"] = new InstructionTemplate(InstructionType.TwoArguments4BitsAnd8Bits, "SE V{0:X}, V{1:X2}", (Generic.DataStructures.InstructionHandler)skipIfRegEqualToConst);
            Instructions["4XXX"] = new InstructionTemplate(InstructionType.TwoArguments4BitsAnd8Bits, "SNE V{0:X}, V{1:X2}", (Generic.DataStructures.InstructionHandler)skipIfRegNotEqualToConst);
            Instructions["5XX0"] = new InstructionTemplate(InstructionType.TwoArguments4BitsEach, "SE V{0:X}, V{1:X}", (Generic.DataStructures.InstructionHandler)skipIfRegEqualToReg);
            Instructions["6XXX"] = new InstructionTemplate(InstructionType.TwoArguments4BitsAnd8Bits, "LD V{0:X}, 0x{1:X2}", (Generic.DataStructures.InstructionHandler)loadConstToReg);
            Instructions["7XXX"] = new InstructionTemplate(InstructionType.TwoArguments4BitsAnd8Bits, "ADD V{0:X}, 0x{1:X2}", (Generic.DataStructures.InstructionHandler)addConstToRegNoCarry);
            Instructions["8XX0"] = new InstructionTemplate(InstructionType.TwoArguments4BitsEach, "LD V{0:X}, V{1:X}", (Generic.DataStructures.InstructionHandler)loadRegToReg);
            Instructions["8XX1"] = new InstructionTemplate(InstructionType.TwoArguments4BitsEach, "OR V{0:X}, V{1:X}", (Generic.DataStructures.InstructionHandler)bitwiseOrRegToReg);
            Instructions["8XX2"] = new InstructionTemplate(InstructionType.TwoArguments4BitsEach, "AND V{0:X}, V{1:X}", (Generic.DataStructures.InstructionHandler)bitwiseAndRegToReg);
            Instructions["8XX3"] = new InstructionTemplate(InstructionType.TwoArguments4BitsEach, "XOR V{0:X}, V{1:X}", (Generic.DataStructures.InstructionHandler)bitwiseXorRegToReg);
            Instructions["8XX4"] = new InstructionTemplate(InstructionType.TwoArguments4BitsEach, "ADD V{0:X}, V{1:X}", (Generic.DataStructures.InstructionHandler)addRegToRegWithCarry);
            Instructions["8XX5"] = new InstructionTemplate(InstructionType.TwoArguments4BitsEach, "SUB V{0:X}, V{1:X}", (Generic.DataStructures.InstructionHandler)subtractRegToTegWithBorrow);
            Instructions["8XX6"] = new InstructionTemplate(InstructionType.TwoArguments4BitsEach, "SHR V{0:X}, V{1:X}", (Generic.DataStructures.InstructionHandler)rightShiftRegSpillCarry);
            Instructions["8XX7"] = new InstructionTemplate(InstructionType.TwoArguments4BitsEach, "SUBN V{0:X}, V{1:X}", (Generic.DataStructures.InstructionHandler)invertedSubtractRegToRegWithBorrow);
            Instructions["8XXE"] = new InstructionTemplate(InstructionType.TwoArguments4BitsEach, "SHL V{0:X}, V{1:X}", (Generic.DataStructures.InstructionHandler)leftShiftRegSpillCarry);
            Instructions["9XX0"] = new InstructionTemplate(InstructionType.TwoArguments4BitsEach, "SNE V{0:X}, V{1:X}", (Generic.DataStructures.InstructionHandler)skipIfRegNotEqualToReg);
            Instructions["AXXX"] = new InstructionTemplate(InstructionType.OneArgument12Bits, "LD I, 0x{0:X4}", (Generic.DataStructures.InstructionHandler)loadIWithAddress);
            Instructions["BXXX"] = new InstructionTemplate(InstructionType.OneArgument12Bits, "JP V0, 0x{0:X4}", (Generic.DataStructures.InstructionHandler)jumpToAddressWithOffsetInReg0);
            Instructions["CXXX"] = new InstructionTemplate(InstructionType.TwoArguments4BitsAnd8Bits, "RND V{0:X}, 0x{1:X2}", (Generic.DataStructures.InstructionHandler)bitwiseAndRandomNumberAndConst);
            Instructions["DXXX"] = new InstructionTemplate(InstructionType.ThreeArguments4BitsEach, "DRW V{0:X}, V{1:X}, 0x{2:X2}", (Generic.DataStructures.InstructionHandler)drawSpriteAndDetectCollision);
            Instructions["EX9E"] = new InstructionTemplate(InstructionType.OneArgument4Bits, "SKP V{0:X}", (Generic.DataStructures.InstructionHandler)skipIfKeypressNameInRegIsPressed);
            Instructions["EXA1"] = new InstructionTemplate(InstructionType.OneArgument4Bits, "SKNP V{0:X}", (Generic.DataStructures.InstructionHandler)skipIfKeypressNameInRegIsNotPressed);
            Instructions["FX07"] = new InstructionTemplate(InstructionType.OneArgument4Bits, "LD V{0:X}, DT", (Generic.DataStructures.InstructionHandler)loadRegWithDelayValue);
            Instructions["FX0A"] = new InstructionTemplate(InstructionType.OneArgument4Bits, "LD V{0:X}, K", (Generic.DataStructures.InstructionHandler)waitForKeypressAndStoreNameInReg);
            Instructions["FX15"] = new InstructionTemplate(InstructionType.OneArgument4Bits, "LD DT, V{0:X}", (Generic.DataStructures.InstructionHandler)loadDelayValueWithReg);
            Instructions["FX18"] = new InstructionTemplate(InstructionType.OneArgument4Bits, "LD ST, V{0:X}", (Generic.DataStructures.InstructionHandler)loadSoundTimerWithReg);
            Instructions["FX1E"] = new InstructionTemplate(InstructionType.OneArgument4Bits, "ADD I, V{0:X}", (Generic.DataStructures.InstructionHandler)addRegToI);
            Instructions["FX29"] = new InstructionTemplate(InstructionType.OneArgument4Bits, "LD F, V{0:X}", (Generic.DataStructures.InstructionHandler)loadFontSpriteStartToI);
            Instructions["FX33"] = new InstructionTemplate(InstructionType.OneArgument4Bits, "LD B, V{0:X}", (Generic.DataStructures.InstructionHandler)loadBCDOfRegToStartI);
            Instructions["FX55"] = new InstructionTemplate(InstructionType.OneArgument4Bits, "LD [I], V{0:X}", (Generic.DataStructures.InstructionHandler)dumpRegsToMemoryStartingAtI);
            Instructions["FX65"] = new InstructionTemplate(InstructionType.OneArgument4Bits, "LD V{0:X}, [I]", (Generic.DataStructures.InstructionHandler)populateRegsFromMemoryStartingAtI);
            Instructions["XXXX"] = new InstructionTemplate(InstructionType.NoArguments, "", (Generic.DataStructures.InstructionHandler)unrecognizedInstruction);
        }