public void AddInstruction(Instruction instruction) { instructions.Add(instruction); }
private Instruction GetZeroPageAlternative(Instruction instruction) { Instruction zeroPageAlternative = null; if ((operandValue & 0xFF00) == 0) { switch (instruction.OperandKind) { case OperandKind.Absolute: Instruction.TryFind(instruction.Mnemonic, OperandKind.ZeroPage, out zeroPageAlternative); break; case OperandKind.AbsoluteX: Instruction.TryFind(instruction.Mnemonic, OperandKind.ZeroPageX, out zeroPageAlternative); break; case OperandKind.AbsoluteY: Instruction.TryFind(instruction.Mnemonic, OperandKind.ZeroPageY, out zeroPageAlternative); break; } } return zeroPageAlternative; }
public static bool TryFind(string mnemonic, OperandKind operandKind, out Instruction instruction) { return SupportedInstructions.TryGetValue(GetKey(mnemonic, operandKind), out instruction); }
private void OnInstructionResolved(Instruction instruction) { instruction = GetZeroPageAlternative(instruction) ?? instruction; var operandLo = (byte) (operandValue & 0xFF); var operandHi = (byte) ((operandValue & 0xFF00) >> 8); AddOpCode(instruction.OpCode); switch (instruction.Length) { case 1: break; case 2: AddOpCode(operandLo); break; case 3: AddOpCode(operandLo); AddOpCode(operandHi); break; } }
private static void AddInstruction(Instruction instruction) { SupportedInstructions.Add(GetKey(instruction.Mnemonic, instruction.OperandKind), instruction); }