mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-07 05:30:30 +00:00
Largely resolve the operation-name problem.
This commit is contained in:
parent
9d9194f194
commit
710017ada2
@ -10,6 +10,117 @@
|
|||||||
|
|
||||||
using namespace InstructionSet::x86;
|
using namespace InstructionSet::x86;
|
||||||
|
|
||||||
|
std::string InstructionSet::x86::to_string(Operation operation, DataSize size) {
|
||||||
|
switch(operation) {
|
||||||
|
case Operation::AAA: return "aaa";
|
||||||
|
case Operation::AAD: return "aad";
|
||||||
|
case Operation::AAM: return "aam";
|
||||||
|
case Operation::AAS: return "aas";
|
||||||
|
case Operation::DAA: return "daa";
|
||||||
|
case Operation::DAS: return "das";
|
||||||
|
|
||||||
|
case Operation::CBW: return "cbw";
|
||||||
|
case Operation::CWD: return "cwd";
|
||||||
|
case Operation::ESC: return "esc";
|
||||||
|
|
||||||
|
case Operation::HLT: return "hlt";
|
||||||
|
case Operation::WAIT: return "wait";
|
||||||
|
|
||||||
|
case Operation::ADC: return "adc";
|
||||||
|
case Operation::ADD: return "add";
|
||||||
|
case Operation::SBB: return "sbb";
|
||||||
|
case Operation::SUB: return "sub";
|
||||||
|
case Operation::MUL: return "mul";
|
||||||
|
case Operation::IMUL_1: return "imul";
|
||||||
|
case Operation::DIV: return "div";
|
||||||
|
case Operation::IDIV: return "idiv";
|
||||||
|
|
||||||
|
case Operation::INC: return "inc";
|
||||||
|
case Operation::DEC: return "dec";
|
||||||
|
|
||||||
|
case Operation::IN: return "in";
|
||||||
|
case Operation::OUT: return "out";
|
||||||
|
|
||||||
|
case Operation::JO: return "jo";
|
||||||
|
case Operation::JNO: return "jno";
|
||||||
|
case Operation::JB: return "jb";
|
||||||
|
case Operation::JNB: return "jnb";
|
||||||
|
case Operation::JE: return "jo";
|
||||||
|
case Operation::JNE: return "jne";
|
||||||
|
case Operation::JBE: return "jbe";
|
||||||
|
case Operation::JNBE: return "jnbe";
|
||||||
|
case Operation::JS: return "js";
|
||||||
|
case Operation::JNS: return "jns";
|
||||||
|
case Operation::JP: return "jp";
|
||||||
|
case Operation::JNP: return "jnp";
|
||||||
|
case Operation::JL: return "jl";
|
||||||
|
case Operation::JNL: return "jnl";
|
||||||
|
case Operation::JLE: return "jle";
|
||||||
|
case Operation::JNLE: return "jnle";
|
||||||
|
|
||||||
|
case Operation::IRET: return "iret";
|
||||||
|
case Operation::JMPabs: return "jmp word";
|
||||||
|
case Operation::JPCX: return "jpcx";
|
||||||
|
case Operation::INT: return "int";
|
||||||
|
case Operation::INTO: return "into";
|
||||||
|
|
||||||
|
case Operation::LAHF: return "lahf";
|
||||||
|
case Operation::SAHF: return "sahf";
|
||||||
|
case Operation::LDS: return "lds";
|
||||||
|
case Operation::LES: return "les";
|
||||||
|
case Operation::LEA: return "lea";
|
||||||
|
|
||||||
|
case Operation::CMPS: {
|
||||||
|
constexpr char sizes[][6] = { "cmpsb", "cmpsw", "cmpsd", "?" };
|
||||||
|
return sizes[static_cast<int>(size)];
|
||||||
|
}
|
||||||
|
case Operation::LODS: return "lods";
|
||||||
|
case Operation::MOVS: return "movs";
|
||||||
|
case Operation::SCAS: return "scas";
|
||||||
|
case Operation::STOS: return "stos";
|
||||||
|
|
||||||
|
case Operation::LOOP: return "loop";
|
||||||
|
case Operation::LOOPE: return "loope";
|
||||||
|
case Operation::LOOPNE: return "loopne";
|
||||||
|
|
||||||
|
case Operation::MOV: return "mov";
|
||||||
|
case Operation::NEG: return "neg";
|
||||||
|
case Operation::NOT: return "not";
|
||||||
|
case Operation::AND: return "and";
|
||||||
|
case Operation::OR: return "or";
|
||||||
|
case Operation::XOR: return "xor";
|
||||||
|
case Operation::NOP: return "nop";
|
||||||
|
case Operation::POP: return "pop";
|
||||||
|
case Operation::POPF: return "popf";
|
||||||
|
case Operation::PUSH: return "push";
|
||||||
|
case Operation::PUSHF: return "pushf";
|
||||||
|
case Operation::RCL: return "rcl";
|
||||||
|
case Operation::RCR: return "rcr";
|
||||||
|
case Operation::ROL: return "rol";
|
||||||
|
case Operation::ROR: return "ror";
|
||||||
|
case Operation::SAL: return "sal";
|
||||||
|
case Operation::SAR: return "sar";
|
||||||
|
case Operation::SHR: return "shr";
|
||||||
|
|
||||||
|
case Operation::CLC: return "clc";
|
||||||
|
case Operation::CLD: return "cld";
|
||||||
|
case Operation::CLI: return "cli";
|
||||||
|
case Operation::STC: return "stc";
|
||||||
|
case Operation::STD: return "std";
|
||||||
|
case Operation::STI: return "sti";
|
||||||
|
case Operation::CMC: return "cmc";
|
||||||
|
|
||||||
|
case Operation::CMP: return "cmp";
|
||||||
|
case Operation::TEST: return "test";
|
||||||
|
|
||||||
|
case Operation::XCHG: return "xchg";
|
||||||
|
case Operation::XLAT: return "xlat";
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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: {
|
||||||
|
@ -340,6 +340,12 @@ enum class Operation: uint8_t {
|
|||||||
MOVtoTr, MOVfromTr,
|
MOVtoTr, MOVfromTr,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constexpr int num_operands(Operation operation) {
|
||||||
|
switch(operation) {
|
||||||
|
default: return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enum class DataSize: uint8_t {
|
enum class DataSize: uint8_t {
|
||||||
Byte = 0,
|
Byte = 0,
|
||||||
Word = 1,
|
Word = 1,
|
||||||
@ -354,6 +360,7 @@ constexpr int byte_size(DataSize size) {
|
|||||||
constexpr int bit_size(DataSize size) {
|
constexpr int bit_size(DataSize size) {
|
||||||
return (8 << int(size)) & 0x3f;
|
return (8 << int(size)) & 0x3f;
|
||||||
}
|
}
|
||||||
|
std::string to_string(Operation, DataSize);
|
||||||
|
|
||||||
enum class AddressSize: uint8_t {
|
enum class AddressSize: uint8_t {
|
||||||
b16 = 0,
|
b16 = 0,
|
||||||
|
@ -23,7 +23,7 @@ namespace {
|
|||||||
|
|
||||||
// The tests themselves are not duplicated in this repository;
|
// The tests themselves are not duplicated in this repository;
|
||||||
// provide their real path here.
|
// provide their real path here.
|
||||||
constexpr char TestSuiteHome[] = "/Users/thomasharte/Projects/ProcessorTests/8088/v1";
|
constexpr char TestSuiteHome[] = "/Users/tharte/Projects/ProcessorTests/8088/v1";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ constexpr char TestSuiteHome[] = "/Users/thomasharte/Projects/ProcessorTests/808
|
|||||||
NSSet *allowList = nil;
|
NSSet *allowList = nil;
|
||||||
// [[NSSet alloc] initWithArray:@[
|
// [[NSSet alloc] initWithArray:@[
|
||||||
// @"00.json.gz",
|
// @"00.json.gz",
|
||||||
// ]];
|
// ]];∂
|
||||||
|
|
||||||
NSArray<NSString *> *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:nil];
|
NSArray<NSString *> *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:nil];
|
||||||
files = [files filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSString* evaluatedObject, NSDictionary<NSString *,id> *) {
|
files = [files filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSString* evaluatedObject, NSDictionary<NSString *,id> *) {
|
||||||
@ -88,14 +88,12 @@ constexpr char TestSuiteHome[] = "/Users/thomasharte/Projects/ProcessorTests/808
|
|||||||
log_hex();
|
log_hex();
|
||||||
|
|
||||||
// Repeat the decoding, for ease of debugging.
|
// Repeat the decoding, for ease of debugging.
|
||||||
Decoder straw_man;
|
Decoder().decode(data.data(), data.size());
|
||||||
straw_man.decode(data.data(), data.size());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Form string version, compare.
|
// Form string version, compare.
|
||||||
std::string operation;
|
std::string operation;
|
||||||
const bool is_byte_operation = decoded.second.operation_size() == InstructionSet::x86::DataSize::Byte;
|
|
||||||
|
|
||||||
using Repetition = InstructionSet::x86::Repetition;
|
using Repetition = InstructionSet::x86::Repetition;
|
||||||
switch(decoded.second.repetition()) {
|
switch(decoded.second.repetition()) {
|
||||||
@ -104,18 +102,9 @@ constexpr char TestSuiteHome[] = "/Users/thomasharte/Projects/ProcessorTests/808
|
|||||||
case Repetition::RepNE: operation += "repne "; break;
|
case Repetition::RepNE: operation += "repne "; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int operands = 0;
|
operation += to_string(decoded.second.operation, decoded.second.operation_size());
|
||||||
using Operation = InstructionSet::x86::Operation;
|
|
||||||
switch(decoded.second.operation) {
|
|
||||||
case Operation::SUB: operation += "sub"; operands = 2; break;
|
|
||||||
case Operation::CMP: operation += "cmp"; operands = 2; break;
|
|
||||||
case Operation::CMPS:
|
|
||||||
operation += is_byte_operation? "cmpsb" : "cmpsw";
|
|
||||||
break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto to_string = [is_byte_operation] (InstructionSet::x86::DataPointer pointer, const auto &instruction) -> std::string {
|
auto to_string = [] (InstructionSet::x86::DataPointer pointer, const auto &instruction) -> std::string {
|
||||||
std::string operand;
|
std::string operand;
|
||||||
|
|
||||||
using Source = InstructionSet::x86::Source;
|
using Source = InstructionSet::x86::Source;
|
||||||
@ -140,6 +129,7 @@ constexpr char TestSuiteHome[] = "/Users/thomasharte/Projects/ProcessorTests/808
|
|||||||
return operand;
|
return operand;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const int operands = num_operands(decoded.second.operation);
|
||||||
if(operands > 1) {
|
if(operands > 1) {
|
||||||
operation += " ";
|
operation += " ";
|
||||||
operation += to_string(decoded.second.destination(), decoded.second);
|
operation += to_string(decoded.second.destination(), decoded.second);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user