private void CheckEaContentsFlags( CpuInstruction instruction, UInt16 regValue, UInt16 eaContents, Boolean expectedOverflow, Boolean expectedSign, Boolean expectedZero, String message) { ExecuteEaContentsInstruction(instruction, regValue, eaContents); CheckFlags(expectedOverflow, expectedSign, expectedZero, message); }
public override void Register(CpuInstruction[] opcodeHandlers) { opcodeHandlers[Mnemonic.IncZeroPage] = new CpuInstruction(ZeroPage, 5); opcodeHandlers[Mnemonic.IncZeroPageX] = new CpuInstruction(ZeroPageX, 6); opcodeHandlers[Mnemonic.IncAbsolute] = new CpuInstruction(Absolute, 6); opcodeHandlers[Mnemonic.IncAbsoluteX] = new CpuInstruction(AbsoluteX, 7); }
public void TheCpuMustFetchAndIncrementPcAndExecuteOpCodesOnClockZero() { ushort originalPC = _subject.ProgramCounter; byte expectedOpCode = 10; _mockDataBus .Setup(mock => mock.ReadFromMemory(originalPC, false)) .Returns(expectedOpCode) .Verifiable(); _mockExecutor .Setup(mock => mock.BreakInterrupt()) .Returns(0) .Verifiable(); _mockAddressing .Setup(mock => mock.Immediate()) .Returns(0) .Verifiable(); var expectedInstruction = new CpuInstruction(MOS6502Instruction.BRK, MOS6502AddressingMode.Immediate, _mockExecutor.Object.BreakInterrupt, _mockAddressing.Object.Immediate, 2); _mockInstructionsTable .Setup(mock => mock.GetInstructionForOpCode(expectedOpCode)) .Returns(expectedInstruction) .Verifiable(); _subject.OnClockTick(); _mockDataBus.Verify(); _mockExecutor.Verify(); _mockAddressing.Verify(); _mockInstructionsTable.Verify(); Check.That(_subject.ProgramCounter).Equals(originalPC + 1); }
public void TheCpuMustntFetchNorExecuteUntilTheCyclesForTheInstructionsAreComplete() { ushort originalPC = _subject.ProgramCounter; byte expectedOpCode = 10; _mockDataBus .Setup(mock => mock.ReadFromMemory(originalPC, false)) .Returns(expectedOpCode); _mockExecutor .Setup(mock => mock.BreakInterrupt()) .Returns(0); _mockAddressing .Setup(mock => mock.Immediate()) .Returns(0); var expectedInstruction = new CpuInstruction(MOS6502Instruction.BRK, MOS6502AddressingMode.Immediate, _mockExecutor.Object.BreakInterrupt, _mockAddressing.Object.Immediate, 2); _mockInstructionsTable .Setup(mock => mock.GetInstructionForOpCode(expectedOpCode)) .Returns(expectedInstruction) .Verifiable(); _subject.OnClockTick(); _subject.OnClockTick(); _mockDataBus.Verify(mock => mock.ReadFromMemory(originalPC, false), Times.Once); _mockExecutor.Verify(mock => mock.BreakInterrupt(), Times.Once); _mockAddressing.Verify(mock => mock.Immediate(), Times.Once); _mockInstructionsTable.Verify(mock => mock.GetInstructionForOpCode(expectedOpCode), Times.Once); }
private void CheckRegisterFlags( CpuInstruction instruction, UInt16 reg1Value, UInt16 reg2Value, Boolean expectedOverflow, Boolean expectedSign, Boolean expectedZero, String message) { ExecuteRegisterInstruction(instruction, reg1Value, reg2Value); CheckFlags(expectedOverflow, expectedSign, expectedZero, message); }
public void TheCpuMustNotExtendTheInstructionCyclesIfOnlyTheAddressingModeRequestsSo() { ushort originalPC = _subject.ProgramCounter; byte expectedOpCode = 10; _mockDataBus .Setup(mock => mock.ReadFromMemory(It.IsAny <ushort>(), false)) .Returns(expectedOpCode); _mockExecutor .Setup(mock => mock.BreakInterrupt()) .Returns(0); _mockAddressing .Setup(mock => mock.Immediate()) .Returns(1); var expectedInstruction = new CpuInstruction(MOS6502Instruction.BRK, MOS6502AddressingMode.Immediate, _mockExecutor.Object.BreakInterrupt, _mockAddressing.Object.Immediate, 1); _mockInstructionsTable .Setup(mock => mock.GetInstructionForOpCode(expectedOpCode)) .Returns(expectedInstruction) .Verifiable(); _subject.OnClockTick(); _subject.OnClockTick(); _mockDataBus.Verify(mock => mock.ReadFromMemory(originalPC, false), Times.Once); _mockDataBus.Verify(mock => mock.ReadFromMemory((ushort)(originalPC + 1), false), Times.Once); _mockExecutor.Verify(mock => mock.BreakInterrupt(), Times.Exactly(2)); _mockAddressing.Verify(mock => mock.Immediate(), Times.Exactly(2)); _mockInstructionsTable.Verify(mock => mock.GetInstructionForOpCode(expectedOpCode), Times.Exactly(2)); }
private void ExecuteRegisterInstruction(CpuInstruction instruction, UInt16 reg1Value, UInt16 reg2Value) { // レジスタに値を設定し、命令を実行します。 m_registerSet.GR[R1].Value = reg1Value; m_registerSet.GR[R2].Value = reg2Value; instruction.Execute(R1, R2, m_registerSet, m_memory); }
private void CheckEaContentsMemory( CpuInstruction instruction, UInt16 regValue, UInt16 eaContents, UInt16 address, UInt16 expected, String message) { ExecuteEaContentsInstruction(instruction, regValue, eaContents); MemoryTest.Check(m_memory, address, expected, message); }
public override void Register(CpuInstruction[] opcodeHandlers) { opcodeHandlers[Mnemonic.LdxImmediate] = new CpuInstruction(Immediate, 2); opcodeHandlers[Mnemonic.LdxZeroPage] = new CpuInstruction(ZeroPage, 3); opcodeHandlers[Mnemonic.LdxZeroPageY] = new CpuInstruction(ZeroPageY, 4); opcodeHandlers[Mnemonic.LdxAbsolute] = new CpuInstruction(Absolute, 4); opcodeHandlers[Mnemonic.LdxAbsoluteY] = new CpuInstruction(AbsoluteY, 4); }
public override void Register(CpuInstruction[] opcodeHandlers) { opcodeHandlers[Mnemonic.StaZeroPage] = new CpuInstruction(ZeroPage, 3); opcodeHandlers[Mnemonic.StaZeroPageX] = new CpuInstruction(ZeroPageX, 4); opcodeHandlers[Mnemonic.StaAbsolute] = new CpuInstruction(Absolute, 4); opcodeHandlers[Mnemonic.StaAbsoluteX] = new CpuInstruction(AbsoluteX, 5); opcodeHandlers[Mnemonic.StaAbsoluteY] = new CpuInstruction(AbsoluteY, 5); opcodeHandlers[Mnemonic.StaIndirectX] = new CpuInstruction(IndirectX, 6); opcodeHandlers[Mnemonic.StaIndirectY] = new CpuInstruction(IndirectY, 6); }
private void CheckJump( CpuInstruction instruction, Boolean overflowFlag, Boolean signFlag, Boolean zeroFlag, Boolean jump, String message) { m_registerSet.FR.SetFlags(overflowFlag, signFlag, zeroFlag); ExecuteEaContentsInstruction(instruction, DontCareUInt16, DontCareUInt16); UInt16 expected = jump ? EffectiveAddress : NextAddressPlusOne; CpuRegisterTest.Check(m_registerSet.PR, expected, message); }
private void ExecuteEaContentsInstruction(CpuInstruction instruction, UInt16 regValue, UInt16 eaContents) { // 命令語の次のアドレスに adr, 実効アドレスの内容、GRx にオフセットの値を書き込みます。 m_memory.Write(NextAddress, Adr); m_memory.Write(EffectiveAddress, eaContents); m_registerSet.GR[X].Value = Offset; // レジスタと PR に値を設定し、命令を実行します。 m_registerSet.GR[R].Value = regValue; m_registerSet.PR.Value = NextAddress; instruction.Execute(R, X, m_registerSet, m_memory); }
private void CheckDecode(UInt16 opcode, CpuInstruction expected, String message) { try { CpuInstruction actual = Decoder.Decode(opcode); Assert.IsNotNull(expected, message); Assert.AreSame(expected, actual, message); } catch (Casl2SimulatorException) { Assert.IsNull(expected, message); } }
public void TheCpuMustExecuteAnotherInstructionOnceCyclesAreComplete() { ushort originalPC = _subject.ProgramCounter; ushort secondExpectedPC = (ushort)(originalPC + 1); byte expectedOpCode = 10; _mockDataBus .Setup(mock => mock.ReadFromMemory(originalPC, false)) .Returns(expectedOpCode); _mockDataBus .Setup(mock => mock.ReadFromMemory(secondExpectedPC, false)) .Returns(expectedOpCode); _mockExecutor .Setup(mock => mock.BreakInterrupt()) .Returns(0); _mockAddressing .Setup(mock => mock.Immediate()) .Returns(0); var expectedInstruction = new CpuInstruction(MOS6502Instruction.BRK, MOS6502AddressingMode.Immediate, _mockExecutor.Object.BreakInterrupt, _mockAddressing.Object.Immediate, 2); _mockInstructionsTable .Setup(mock => mock.GetInstructionForOpCode(expectedOpCode)) .Returns(expectedInstruction) .Verifiable(); _subject.OnClockTick(); _subject.OnClockTick(); _subject.OnClockTick(); _mockDataBus.Verify(mock => mock.ReadFromMemory(originalPC, false), Times.Once); _mockDataBus.Verify(mock => mock.ReadFromMemory(secondExpectedPC, false), Times.Once); _mockExecutor.Verify(mock => mock.BreakInterrupt(), Times.Exactly(2)); _mockAddressing.Verify(mock => mock.Immediate(), Times.Exactly(2)); _mockInstructionsTable.Verify(mock => mock.GetInstructionForOpCode(expectedOpCode), Times.Exactly(2)); Check.That(_subject.ProgramCounter).IsEqualTo(originalPC + 2); }
public void Handle(ICpu cpu, CpuInstruction instruction) { Debug.WriteLine("In JMP"); cpu.IP.Store(instruction.SingleOperand); }
private void CheckToString(CpuInstruction instruction, String expected) { String actual = instruction.ToString(); Assert.AreEqual(expected, actual); }
/// <summary> /// Converts instance of <see cref="DecodedInstruction"/> into an instance of <see cref="CpuInstruction"/>. /// </summary> /// <param name="decodedInstruction">Decoded 2 bytes of memory.</param> /// <returns>Concrete Cpu instruction or <see cref="UndefinedInstruction"/> if instruction cannot be determined.</returns> public CpuInstruction GetCpuInstruction(DecodedInstruction decodedInstruction) { CpuInstruction cpuInstruction = null; switch (decodedInstruction.OpCode) { case 0x0: if (decodedInstruction.kk == 0xE0) { cpuInstruction = new Instruction_00E0(decodedInstruction); } else if (decodedInstruction.kk == 0xEE) { cpuInstruction = new Instruction_00EE(decodedInstruction); } break; case 0x1: cpuInstruction = new Instruction_1nnn(decodedInstruction); break; case 0x2: cpuInstruction = new Instruction_2nnn(decodedInstruction); break; case 0x3: cpuInstruction = new Instruction_3xkk(decodedInstruction); break; case 0x4: cpuInstruction = new Instruction_4xkk(decodedInstruction); break; case 0x5: if (decodedInstruction.n == 0x0) { cpuInstruction = new Instruction_5xy0(decodedInstruction); } break; case 0x6: cpuInstruction = new Instruction_6xkk(decodedInstruction); break; case 0x7: cpuInstruction = new Instruction_7xkk(decodedInstruction); break; case 0x8: { switch (decodedInstruction.n) { case 0x0: cpuInstruction = new Instruction_8xy0(decodedInstruction); break; case 0x1: cpuInstruction = new Instruction_8xy1(decodedInstruction); break; case 0x2: cpuInstruction = new Instruction_8xy2(decodedInstruction); break; case 0x3: cpuInstruction = new Instruction_8xy3(decodedInstruction); break; case 0x4: cpuInstruction = new Instruction_8xy4(decodedInstruction); break; case 0x5: cpuInstruction = new Instruction_8xy5(decodedInstruction); break; case 0x6: cpuInstruction = new Instruction_8xy6(decodedInstruction); break; case 0x7: cpuInstruction = new Instruction_8xy7(decodedInstruction); break; case 0xE: cpuInstruction = new Instruction_8xyE(decodedInstruction); break; default: cpuInstruction = new UndefinedInstruction(decodedInstruction); break; } } break; case 0x9: if (decodedInstruction.n == 0x0) { cpuInstruction = new Instruction_9xy0(decodedInstruction); } break; case 0xA: cpuInstruction = new Instruction_Annn(decodedInstruction); break; case 0xB: cpuInstruction = new Instruction_Bnnn(decodedInstruction); break; case 0xC: cpuInstruction = new Instruction_Cxkk(decodedInstruction); break; case 0xD: cpuInstruction = new Instruction_Dxyn(decodedInstruction); break; case 0xE: { switch (decodedInstruction.kk) { case 0x9E: cpuInstruction = new Instruction_Ex9E(decodedInstruction); break; case 0xA1: cpuInstruction = new Instruction_ExA1(decodedInstruction); break; default: cpuInstruction = new UndefinedInstruction(decodedInstruction); break; } } break; case 0xF: { switch (decodedInstruction.kk) { case 0x07: cpuInstruction = new Instruction_Fx07(decodedInstruction); break; case 0x0A: cpuInstruction = new Instruction_Fx0A(decodedInstruction); break; case 0x15: cpuInstruction = new Instruction_Fx15(decodedInstruction); break; case 0x18: cpuInstruction = new Instruction_Fx18(decodedInstruction); break; case 0x1E: cpuInstruction = new Instruction_Fx1E(decodedInstruction); break; case 0x29: cpuInstruction = new Instruction_Fx29(decodedInstruction); break; case 0x33: cpuInstruction = new Instruction_Fx33(decodedInstruction); break; case 0x55: cpuInstruction = new Instruction_Fx55(decodedInstruction); break; case 0x65: cpuInstruction = new Instruction_Fx65(decodedInstruction); break; default: cpuInstruction = new UndefinedInstruction(decodedInstruction); break; } break; } default: cpuInstruction = new UndefinedInstruction(decodedInstruction); break; } return(cpuInstruction ?? new UndefinedInstruction(decodedInstruction)); }
private void CheckRegisterRegister( CpuInstruction instruction, UInt16 reg1Value, UInt16 reg2Value, UInt16 expected, String message) { ExecuteRegisterInstruction(instruction, reg1Value, reg2Value); CpuRegisterTest.Check(m_registerSet.GR[R1], expected, message); }
public override void Register(CpuInstruction[] opcodeHandlers) { opcodeHandlers[Mnemonic.StyAbsolute] = new CpuInstruction(Absolute, 2); opcodeHandlers[Mnemonic.StyZeroPage] = new CpuInstruction(ZeroPage, 3); opcodeHandlers[Mnemonic.StyZeroPageX] = new CpuInstruction(ZeroPageX, 4); }
public void Handle(ICpu cpu, CpuInstruction instruction) { cpu.IP.Increment(instruction.SingleOperand); }
private void CheckEaContentsRegister( CpuInstruction instruction, UInt16 regValue, UInt16 eaContents, UInt16 expected, String message) { ExecuteEaContentsInstruction(instruction, regValue, eaContents); CpuRegisterTest.Check(m_registerSet.GR[R], expected, message); }
private void CodeAnalyzer_Load(object sender, EventArgs e) { string output = ""; var assembler = new Assembler(SourceCode, 0); Assembler.B33Program program = assembler.Assemble(OutputTypes.RawBinary); if (!assembler.Successful) { return; } for (ushort i = 0; i < program.ExecutionAddress;) { string labelName = program.LabelDictionary.ContainsValue(i) ? program.LabelDictionary.FirstOrDefault(z => z.Value == i).Key : ""; if (labelName == "") { i++; continue; } output = output + labelName + " = " + ToHex(i) + Environment.NewLine; i++; } output = output + Environment.NewLine; for (ushort i = program.ExecutionAddress; i < program.ProgramBytes.Length;) { CpuInstruction instruction = Help.Help.GetInstructionByByteCode(program.ProgramBytes[i]); if (instruction == null) { break; } ushort num; string labelName; string tmp1; if (program.LabelDictionary.ContainsValue(i)) { output = output + program.LabelDictionary.FirstOrDefault(z => z.Value == i).Key + ":" + Environment.NewLine; } switch (instruction.ByteCode) { case 0x01: case 0x02: case 0x2A: case 0x2B: case 0x2F: case 0x30: output = output + " " + string.Format(instruction.AnalyticalText, ShowNumbersInHexadecimal ? ToHex(program.ProgramBytes[i + 1]) : program.ProgramBytes[i + 1].ToString()); break; case 0x03: case 0x04: case 0x05: num = BitConverter.ToUInt16(new[] { program.ProgramBytes[i + 1], program.ProgramBytes[i + 2] }, 0); labelName = program.LabelDictionary.ContainsValue(num) ? program.LabelDictionary.FirstOrDefault(z => z.Value == num).Key : ""; output = output + " " + string.Format(instruction.AnalyticalText, GetNumberOrLabel(labelName, num)); break; case 0x06: case 0x07: num = BitConverter.ToUInt16(new[] { program.ProgramBytes[i + 1], program.ProgramBytes[i + 2] }, 0); labelName = program.LabelDictionary.ContainsValue(num) ? program.LabelDictionary.FirstOrDefault(z => z.Value == num).Key : ""; output = output + " " + string.Format(instruction.AnalyticalText, "[Data at " + GetNumberOrLabel(labelName, num) + "]"); break; case 0x08: case 0x09: case 0x0A: num = BitConverter.ToUInt16(new[] { program.ProgramBytes[i + 1], program.ProgramBytes[i + 2] }, 0); labelName = program.LabelDictionary.ContainsValue(num) ? program.LabelDictionary.FirstOrDefault(z => z.Value == num).Key : ""; output = output + " " + string.Format(instruction.AnalyticalText, "[Data at " + GetNumberOrLabel(labelName, num) + "]"); break; case 0x0B: case 0x0C: case 0x0D: case 0x0E: case 0x0F: num = BitConverter.ToUInt16(new[] { program.ProgramBytes[i + 1], program.ProgramBytes[i + 2] }, 0); labelName = program.LabelDictionary.ContainsValue(num) ? program.LabelDictionary.FirstOrDefault(z => z.Value == num).Key : ""; output = output + " " + string.Format(instruction.AnalyticalText, GetNumberOrLabel(labelName, num)); break; case 0x10: tmp1 = "[Data at " + GetRegister(program.ProgramBytes[i + 2]) + " register] = "; tmp1 = tmp1 + "A."; if ((program.ProgramBytes[i + 2] & 32) == 32) { tmp1 = tmp1 + " Increment " + GetRegister(program.ProgramBytes[i + 2]) + " by "; tmp1 = (program.ProgramBytes[i + 2] & 128) == 128 ? tmp1 + "2" : tmp1 + "1"; } if ((program.ProgramBytes[i + 2] & 64) == 64) { tmp1 = tmp1 + " Decrement " + GetRegister(program.ProgramBytes[i + 2]) + " by "; tmp1 = (program.ProgramBytes[i + 2] & 128) == 128 ? tmp1 + "2" : tmp1 + "1"; } output = output + " " + string.Format(instruction.AnalyticalText, tmp1); break; case 0x11: tmp1 = "[Data at " + GetRegister(program.ProgramBytes[i + 2]) + " register] = "; tmp1 = tmp1 + "B."; if ((program.ProgramBytes[i + 2] & 32) == 32) { tmp1 = tmp1 + " Increment " + GetRegister(program.ProgramBytes[i + 2]) + " by "; tmp1 = (program.ProgramBytes[i + 2] & 128) == 128 ? tmp1 + "2" : tmp1 + "1"; } if ((program.ProgramBytes[i + 2] & 64) == 64) { tmp1 = tmp1 + " Decrement " + GetRegister(program.ProgramBytes[i + 2]) + " by "; tmp1 = (program.ProgramBytes[i + 2] & 128) == 128 ? tmp1 + "2" : tmp1 + "1"; } output = output + " " + string.Format(instruction.AnalyticalText, tmp1); break; case 0x12: case 0x13: output = output + " " + string.Format(instruction.AnalyticalText, ShowNumbersInHexadecimal ? ToHex(program.ProgramBytes[i + 1]) : program.ProgramBytes[i + 1].ToString()); break; case 0x14: case 0x15: case 0x16: num = BitConverter.ToUInt16(new[] { program.ProgramBytes[i + 1], program.ProgramBytes[i + 2] }, 0); labelName = program.LabelDictionary.ContainsValue(num) ? program.LabelDictionary.FirstOrDefault(z => z.Value == num).Key : ""; output = output + " " + string.Format(instruction.AnalyticalText, GetNumberOrLabel(labelName, num)); break; case 0x17: case 0x18: num = BitConverter.ToUInt16(new[] { program.ProgramBytes[i + 1], program.ProgramBytes[i + 2] }, 0); labelName = program.LabelDictionary.ContainsValue(num) ? program.LabelDictionary.FirstOrDefault(z => z.Value == num).Key : ""; output = output + " " + string.Format(instruction.AnalyticalText, GetNumberOrLabel(labelName, num)); break; case 0x19: tmp1 = "A = "; tmp1 = tmp1 + "[Data at " + GetRegister(program.ProgramBytes[i + 2]) + " register]."; if ((program.ProgramBytes[i + 2] & 32) == 32) { tmp1 = tmp1 + " Increment " + GetRegister(program.ProgramBytes[i + 2]) + " by "; tmp1 = (program.ProgramBytes[i + 2] & 128) == 128 ? tmp1 + "2" : tmp1 + "1"; } if ((program.ProgramBytes[i + 2] & 64) == 64) { tmp1 = tmp1 + " Decrement " + GetRegister(program.ProgramBytes[i + 2]) + " by "; tmp1 = (program.ProgramBytes[i + 2] & 128) == 128 ? tmp1 + "2" : tmp1 + "1"; } output = output + " " + string.Format(instruction.AnalyticalText, tmp1); break; case 0x1A: tmp1 = "B = "; tmp1 = tmp1 + "[Data at " + GetRegister(program.ProgramBytes[i + 2]) + " register]."; if ((program.ProgramBytes[i + 2] & 32) == 32) { tmp1 = tmp1 + " Increment " + GetRegister(program.ProgramBytes[i + 2]) + " by "; tmp1 = (program.ProgramBytes[i + 2] & 128) == 128 ? tmp1 + "2" : tmp1 + "1"; } if ((program.ProgramBytes[i + 2] & 64) == 64) { tmp1 = tmp1 + " Decrement " + GetRegister(program.ProgramBytes[i + 2]) + " by "; tmp1 = (program.ProgramBytes[i + 2] & 128) == 128 ? tmp1 + "2" : tmp1 + "1"; } output = output + " " + string.Format(instruction.AnalyticalText, tmp1); break; case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x27: num = BitConverter.ToUInt16(new[] { program.ProgramBytes[i + 1], program.ProgramBytes[i + 2] }, 0); labelName = program.LabelDictionary.ContainsValue(num) ? program.LabelDictionary.FirstOrDefault(z => z.Value == num).Key : ""; output = output + " " + string.Format(instruction.AnalyticalText, GetNumberOrLabel(labelName, num)); break; case 0x25: case 0x26: output = output + " " + string.Format(instruction.AnalyticalText, GetRegister(program.ProgramBytes[i + 1])); break; case 0x2C: case 0x2D: case 0x2E: case 0x31: case 0x32: case 0x33: num = BitConverter.ToUInt16(new[] { program.ProgramBytes[i + 1], program.ProgramBytes[i + 2] }, 0); labelName = ShowNumbersInHexadecimal ? ToHex(num) : num.ToString(); output = output + " " + string.Format(instruction.AnalyticalText, GetNumberOrLabel(labelName, num)); break; case 0x34: case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: case 0x3A: case 0x3B: case 0x3C: case 0x3D: output = output + " " + string.Format(instruction.AnalyticalText, GetRegister(program.ProgramBytes[i + 1])); break; case 0x3E: output = output + " " + string.Format(instruction.AnalyticalText, GetRegister(program.ProgramBytes[i + 2]), GetRegister(program.ProgramBytes[i + 1])); break; case 0x3F: case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: case 0x45: output = output + " " + string.Format(instruction.AnalyticalText, GetRegister(program.ProgramBytes[i + 1])); break; case 0x46: case 0x47: num = BitConverter.ToUInt16(new[] { program.ProgramBytes[i + 1], program.ProgramBytes[i + 2] }, 0); labelName = program.LabelDictionary.ContainsValue(num) ? program.LabelDictionary.FirstOrDefault(z => z.Value == num).Key : ""; output = output + " " + string.Format(instruction.AnalyticalText, GetNumberOrLabel(labelName, num)); break; case 0x48: case 0x49: output = output + " " + string.Format(instruction.AnalyticalText, GetRegister(program.ProgramBytes[i + 1]), GetRegister(program.ProgramBytes[i + 2])); break; case 0x4A: case 0x4B: case 0x54: case 0x55: case 0x60: case 0x61: output = output + " " + string.Format(instruction.AnalyticalText, ToHex(program.ProgramBytes[i + 1])); break; case 0x4C: case 0x4D: case 0x4E: case 0x56: case 0x57: case 0x58: case 0x62: case 0x63: case 0x64: num = BitConverter.ToUInt16(new[] { program.ProgramBytes[i + 1], program.ProgramBytes[i + 2] }, 0); output = output + " " + string.Format(instruction.AnalyticalText, ToHex(num)); break; case 0x4F: case 0x50: case 0x51: case 0x52: case 0x53: case 0x59: case 0x5A: case 0x5B: case 0x5C: case 0x5D: case 0x65: case 0x66: case 0x67: case 0x68: case 0x69: case 0x6A: case 0x6F: output = output + " " + string.Format(instruction.AnalyticalText, GetRegister(program.ProgramBytes[i + 1])); break; case 0x5E: case 0x5F: output = output + " " + string.Format(instruction.AnalyticalText, GetRegister(program.ProgramBytes[i + 1]), GetRegister(program.ProgramBytes[i + 2])); break; default: output = output + " " + instruction.AnalyticalText; break; } output = output + Environment.NewLine; i = (ushort)(i + instruction.NumberOfBytes); } txtEditor.Text = output; }
public void Handle(ICpu cpu, CpuInstruction instruction) { Debug.WriteLine("In NOP"); cpu.IP.Increment(CpuInstruction.Width); }