1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 23:52:26 +00:00

Improve string output, better to find actual errors.

Still at 194/324 failures, but a lot of them seem reasonable.
This commit is contained in:
Thomas Harte 2023-09-22 11:24:33 -04:00
parent 9f63db991c
commit 587ec81900
3 changed files with 42 additions and 17 deletions

View File

@ -142,6 +142,24 @@ std::string InstructionSet::x86::to_string(Operation operation, DataSize size) {
} }
} }
bool InstructionSet::x86::mnemonic_implies_data_size(Operation operation) {
switch(operation) {
default: return false;
case Operation::CMPS:
case Operation::LODS:
case Operation::MOVS:
case Operation::SCAS:
case Operation::STOS:
return true;
}
}
std::string InstructionSet::x86::to_string(DataSize size) {
constexpr char sizes[][6] = { "byte", "word", "dword", "?" };
return sizes[static_cast<int>(size)];
}
std::string InstructionSet::x86::to_string(Source source, DataSize size) { std::string InstructionSet::x86::to_string(Source source, DataSize size) {
switch(source) { switch(source) {
case Source::eAX: { case Source::eAX: {

View File

@ -399,6 +399,7 @@ constexpr int num_operands(Operation operation) {
case Operation::DAA: case Operation::DAS: case Operation::DAA: case Operation::DAS:
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::Invalid: case Operation::Invalid:
return 0; return 0;
} }
@ -419,6 +420,8 @@ constexpr int bit_size(DataSize size) {
return (8 << int(size)) & 0x3f; return (8 << int(size)) & 0x3f;
} }
std::string to_string(Operation, DataSize); std::string to_string(Operation, DataSize);
std::string to_string(DataSize);
bool mnemonic_implies_data_size(Operation);
enum class AddressSize: uint8_t { enum class AddressSize: uint8_t {
b16 = 0, b16 = 0,

View File

@ -131,32 +131,36 @@ constexpr char TestSuiteHome[] = "/Users/tharte/Projects/ProcessorTests/8088/v1"
instruction.operation_size() == InstructionSet::x86::DataSize::Byte ? 2 : 4 instruction.operation_size() == InstructionSet::x86::DataSize::Byte ? 2 : 4
); );
case Source::DirectAddress:
case Source::Indirect: { case Source::Indirect: {
std::stringstream stream; std::stringstream stream;
Source segment = Source::None; if(!InstructionSet::x86::mnemonic_implies_data_size(instruction.operation)) {
switch(instruction.data_segment()) { stream << InstructionSet::x86::to_string(instruction.operation_size()) << ' ';
default: segment = instruction.data_segment(); break;
case Source::None: segment = pointer.default_segment(); break;
}
if(segment != Source::None && segment != Source::DS) {
stream << InstructionSet::x86::to_string(segment, InstructionSet::x86::DataSize::None) << ':';
} }
Source segment = instruction.data_segment();
if(segment == Source::None) {
segment = pointer.default_segment();
if(segment == Source::None) {
segment = Source::DS;
}
}
stream << InstructionSet::x86::to_string(segment, InstructionSet::x86::DataSize::None) << ':';
stream << '['; stream << '[';
stream << InstructionSet::x86::to_string(pointer.base(), data_size(instruction.address_size())) << '+'; if(source == Source::Indirect) {
stream << InstructionSet::x86::to_string(pointer.index(), data_size(instruction.address_size())) << '+'; stream << InstructionSet::x86::to_string(pointer.base(), data_size(instruction.address_size()));
stream << std::setfill('0') << std::setw(4) << std::uppercase << std::hex << instruction.offset() << 'h'; stream << '+' << InstructionSet::x86::to_string(pointer.index(), data_size(instruction.address_size()));
if(instruction.offset()) {
stream << '+' << std::setfill('0') << std::setw(4) << std::uppercase << std::hex << instruction.offset() << 'h';
}
} else {
stream << to_hex(instruction.operand(), 4);
}
stream << ']'; stream << ']';
return stream.str(); return stream.str();
} }
case Source::DirectAddress:
return (std::stringstream() <<
'[' <<
to_hex(instruction.operand(), 4) <<
']'
).str();
} }
return operand; return operand;