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