diff --git a/InstructionSets/x86/Instruction.hpp b/InstructionSets/x86/Instruction.hpp index 6677c523d..64c0a0a9a 100644 --- a/InstructionSets/x86/Instruction.hpp +++ b/InstructionSets/x86/Instruction.hpp @@ -367,7 +367,7 @@ constexpr bool has_displacement(Operation operation) { } } -constexpr int num_operands(Operation operation) { +constexpr int max_num_operands(Operation operation) { switch(operation) { default: return 2; @@ -381,6 +381,8 @@ constexpr int num_operands(Operation operation) { case Operation::JMPabs: case Operation::JMPfar: case Operation::CALLabs: case Operation::CALLfar: case Operation::NEG: case Operation::NOT: + case Operation::RETnear: + case Operation::RETfar: return 1; // Pedantically, these have an displacement rather than an operand. @@ -410,8 +412,6 @@ constexpr int num_operands(Operation operation) { case Operation::CBW: case Operation::CWD: case Operation::INTO: case Operation::PUSHF: case Operation::POPF: - case Operation::RETnear: - case Operation::RETfar: case Operation::IRET: case Operation::NOP: case Operation::XLAT: diff --git a/OSBindings/Mac/Clock SignalTests/8088Tests.mm b/OSBindings/Mac/Clock SignalTests/8088Tests.mm index 8c967ec99..0cec54928 100644 --- a/OSBindings/Mac/Clock SignalTests/8088Tests.mm +++ b/OSBindings/Mac/Clock SignalTests/8088Tests.mm @@ -219,14 +219,14 @@ std::string to_string( // Deal with a few special cases up front. switch(instruction.operation) { default: { - const int operands = num_operands(instruction.operation); + const int operands = max_num_operands(instruction.operation); const bool displacement = has_displacement(instruction.operation); operation += " "; - if(operands > 1) { + if(operands > 1 && instruction.destination().source() != Source::None) { operation += to_string(instruction.destination(), instruction, offsetLength, immediateLength); operation += ", "; } - if(operands > 0) { + if(operands > 0 && instruction.source().source() != Source::None) { operation += to_string(instruction.source(), instruction, offsetLength, immediateLength); } if(displacement) { @@ -257,7 +257,7 @@ std::string to_string( case Operation::ROL: case Operation::ROR: case Operation::SAL: case Operation::SAR: case Operation::SHR: - const int operands = num_operands(instruction.operation); + const int operands = max_num_operands(instruction.operation); const bool displacement = has_displacement(instruction.operation); operation += " "; if(operands > 1) {