mirror of
https://github.com/TomHarte/CLK.git
synced 2024-09-28 09:54:49 +00:00
Adjust semantics to avoid culling end of relevant RETs.
This commit is contained in:
parent
960cca163e
commit
ae4a588de3
@ -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) {
|
switch(operation) {
|
||||||
default: return 2;
|
default: return 2;
|
||||||
|
|
||||||
@ -381,6 +381,8 @@ constexpr int num_operands(Operation operation) {
|
|||||||
case Operation::JMPabs: case Operation::JMPfar:
|
case Operation::JMPabs: case Operation::JMPfar:
|
||||||
case Operation::CALLabs: case Operation::CALLfar:
|
case Operation::CALLabs: case Operation::CALLfar:
|
||||||
case Operation::NEG: case Operation::NOT:
|
case Operation::NEG: case Operation::NOT:
|
||||||
|
case Operation::RETnear:
|
||||||
|
case Operation::RETfar:
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
// Pedantically, these have an displacement rather than an operand.
|
// 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::CBW: case Operation::CWD:
|
||||||
case Operation::INTO:
|
case Operation::INTO:
|
||||||
case Operation::PUSHF: case Operation::POPF:
|
case Operation::PUSHF: case Operation::POPF:
|
||||||
case Operation::RETnear:
|
|
||||||
case Operation::RETfar:
|
|
||||||
case Operation::IRET:
|
case Operation::IRET:
|
||||||
case Operation::NOP:
|
case Operation::NOP:
|
||||||
case Operation::XLAT:
|
case Operation::XLAT:
|
||||||
|
@ -219,14 +219,14 @@ std::string to_string(
|
|||||||
// Deal with a few special cases up front.
|
// Deal with a few special cases up front.
|
||||||
switch(instruction.operation) {
|
switch(instruction.operation) {
|
||||||
default: {
|
default: {
|
||||||
const int operands = num_operands(instruction.operation);
|
const int operands = max_num_operands(instruction.operation);
|
||||||
const bool displacement = has_displacement(instruction.operation);
|
const bool displacement = has_displacement(instruction.operation);
|
||||||
operation += " ";
|
operation += " ";
|
||||||
if(operands > 1) {
|
if(operands > 1 && instruction.destination().source() != Source::None) {
|
||||||
operation += to_string(instruction.destination(), instruction, offsetLength, immediateLength);
|
operation += to_string(instruction.destination(), instruction, offsetLength, immediateLength);
|
||||||
operation += ", ";
|
operation += ", ";
|
||||||
}
|
}
|
||||||
if(operands > 0) {
|
if(operands > 0 && instruction.source().source() != Source::None) {
|
||||||
operation += to_string(instruction.source(), instruction, offsetLength, immediateLength);
|
operation += to_string(instruction.source(), instruction, offsetLength, immediateLength);
|
||||||
}
|
}
|
||||||
if(displacement) {
|
if(displacement) {
|
||||||
@ -257,7 +257,7 @@ std::string to_string(
|
|||||||
case Operation::ROL: case Operation::ROR:
|
case Operation::ROL: case Operation::ROR:
|
||||||
case Operation::SAL: case Operation::SAR:
|
case Operation::SAL: case Operation::SAR:
|
||||||
case Operation::SHR:
|
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);
|
const bool displacement = has_displacement(instruction.operation);
|
||||||
operation += " ";
|
operation += " ";
|
||||||
if(operands > 1) {
|
if(operands > 1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user