예제 #1
0
        private string FormatBinaryOperation(Instruction instruction)
        {
            Opcode65 opcode65 = instruction.Data[0];

            if (opcode65.Type == Argument2)
            {
                return($"mov {FormatNumber(NumberSpec.FromAddress(opcode65.DestinationAddress))}, {FormatNumber(opcode65.Argument2)}");
            }
            if (opcode65.Type == Zero)
            {
                return($"mov {FormatNumber(NumberSpec.FromAddress(opcode65.DestinationAddress))}, 0");
            }

            return(opcode65.Type switch
            {
                Add => "add",
                Subtract => "sub",
                Multiply => "mul",
                Divide => "div",
                Remainder => "rem",
                BitwiseAnd => "and",
                BitwiseOr => "or",
                BitwiseXor => "xor",
                LeftShift => "lsh",
                RightShift => "rsh",
                _ => throw new ArgumentOutOfRangeException(),
            } +$" {FormatNumber(NumberSpec.FromAddress(opcode65.DestinationAddress))}, " + FormatNumber(opcode65.Argument1) + ", " + FormatNumber(opcode65.Argument2));
        }
예제 #2
0
 private static int Opcode65Length(Opcode65 value)
 {
     if (value.ShouldHaveFirstArgumentSeparatelyEncoded)
     {
         return(1 + 2 + NumberLength(value.Argument1) + NumberLength(value.Argument2));
     }
     return(1 + 2 + NumberLength(value.Argument2));
 }