mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-16 18:30:32 +00:00
Deal with printing segment:offset.
70 failing files remaining.
This commit is contained in:
parent
0a0051eb59
commit
f16ac603f2
@ -777,6 +777,7 @@ std::pair<int, typename Decoder<model>::InstructionT> Decoder<model>::decode(con
|
||||
case 5: operation_ = Operation::JMPfar; break;
|
||||
case 6: operation_ = Operation::PUSH; break;
|
||||
}
|
||||
// TODO: CALLfar and JMPfar aren't correct above; find out what is.
|
||||
break;
|
||||
|
||||
case ModRegRMFormat::MemRegSingleOperand:
|
||||
|
@ -62,13 +62,13 @@ std::string InstructionSet::x86::to_string(Operation operation, DataSize size) {
|
||||
|
||||
case Operation::CALLabs: return "call";
|
||||
case Operation::CALLrel: return "call";
|
||||
case Operation::CALLfar: return "callf word";
|
||||
case Operation::CALLfar: return "callf far";
|
||||
case Operation::IRET: return "iret";
|
||||
case Operation::RETfar: return "retf";
|
||||
case Operation::RETnear: return "retn";
|
||||
case Operation::JMPabs: return "jmp";
|
||||
case Operation::JMPrel: return "jmp";
|
||||
case Operation::JMPfar: return "jmpf word";
|
||||
case Operation::JMPfar: return "jmpf far";
|
||||
case Operation::JCXZ: return "jcxz";
|
||||
case Operation::INT: return "int";
|
||||
case Operation::INTO: return "into";
|
||||
|
@ -25,7 +25,7 @@ namespace {
|
||||
// provide their real path here.
|
||||
constexpr char TestSuiteHome[] = "/Users/tharte/Projects/ProcessorTests/8088/v1";
|
||||
|
||||
std::string to_hex(int value, int digits) {
|
||||
std::string to_hex(int value, int digits, bool with_suffix = true) {
|
||||
auto stream = std::stringstream();
|
||||
stream << std::setfill('0') << std::uppercase << std::hex << std::setw(digits);
|
||||
switch(digits) {
|
||||
@ -33,7 +33,7 @@ std::string to_hex(int value, int digits) {
|
||||
case 4: stream << +uint16_t(value); break;
|
||||
default: stream << value; break;
|
||||
}
|
||||
stream << 'h';
|
||||
if (with_suffix) stream << 'h';
|
||||
return stream.str();
|
||||
};
|
||||
|
||||
@ -173,6 +173,7 @@ std::string to_string(InstructionSet::x86::DataPointer pointer, const Instructio
|
||||
// Form string version, compare.
|
||||
std::string operation;
|
||||
|
||||
// TODO: determine which reps, if any, this operation permits, and print only as relevant.
|
||||
using Repetition = InstructionSet::x86::Repetition;
|
||||
switch(instruction.repetition()) {
|
||||
case Repetition::None: break;
|
||||
@ -182,18 +183,32 @@ std::string to_string(InstructionSet::x86::DataPointer pointer, const Instructio
|
||||
|
||||
operation += to_string(instruction.operation, instruction.operation_size());
|
||||
|
||||
const int operands = num_operands(instruction.operation);
|
||||
const bool displacement = has_displacement(instruction.operation);
|
||||
operation += " ";
|
||||
if(operands > 1) {
|
||||
operation += to_string(instruction.destination(), instruction, offsetLength);
|
||||
operation += ", ";
|
||||
}
|
||||
if(operands > 0) {
|
||||
operation += to_string(instruction.source(), instruction, offsetLength);
|
||||
}
|
||||
if(displacement) {
|
||||
operation += to_hex(instruction.displacement(), 2);
|
||||
// Deal with a few special cases up front.
|
||||
using Operation = InstructionSet::x86::Operation;
|
||||
switch(instruction.operation) {
|
||||
default: {
|
||||
const int operands = num_operands(instruction.operation);
|
||||
const bool displacement = has_displacement(instruction.operation);
|
||||
operation += " ";
|
||||
if(operands > 1) {
|
||||
operation += to_string(instruction.destination(), instruction, offsetLength);
|
||||
operation += ", ";
|
||||
}
|
||||
if(operands > 0) {
|
||||
operation += to_string(instruction.source(), instruction, offsetLength);
|
||||
}
|
||||
if(displacement) {
|
||||
operation += to_hex(instruction.displacement(), 2);
|
||||
}
|
||||
} break;
|
||||
|
||||
case Operation::CALLfar:
|
||||
case Operation::JMPfar: {
|
||||
operation += " 0x";
|
||||
operation += to_hex(instruction.segment(), 4, false);
|
||||
operation += ":0x";
|
||||
operation += to_hex(instruction.offset(), 4, false);
|
||||
} break;
|
||||
}
|
||||
|
||||
return [NSString stringWithUTF8String:operation.c_str()];
|
||||
|
Loading…
x
Reference in New Issue
Block a user