1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-25 18:30:07 +00:00

Adjust semantics to avoid culling end of relevant RETs.

This commit is contained in:
Thomas Harte 2023-09-28 15:24:15 -04:00
parent 960cca163e
commit ae4a588de3
2 changed files with 7 additions and 7 deletions

View File

@ -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:

View File

@ -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) {