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

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

            return(binaryOperationArgument.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(binaryOperationArgument.DestinationAddress))}, " + FormatNumber(binaryOperationArgument.Argument1) + ", " + FormatNumber(binaryOperationArgument.Argument2));
        }
예제 #2
0
 private static int BinaryOperationArgumentLength(BinaryOperationArgument value)
 {
     if (value.ShouldHaveFirstArgumentSeparatelyEncoded)
     {
         return(1 + 2 + NumberLength(value.Argument1) + NumberLength(value.Argument2));
     }
     return(1 + 2 + NumberLength(value.Argument2));
 }