mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Prepare for greater nuance on testing sign extensions by text.
This commit is contained in:
parent
2d882d2153
commit
02aeec0173
@ -41,17 +41,44 @@ template <typename InstructionT>
|
|||||||
std::string to_string(InstructionSet::x86::DataPointer pointer, const InstructionT &instruction, int offset_length) {
|
std::string to_string(InstructionSet::x86::DataPointer pointer, const InstructionT &instruction, int offset_length) {
|
||||||
std::string operand;
|
std::string operand;
|
||||||
|
|
||||||
|
auto append = [](std::stringstream &stream, auto value, int length, const char *prefix) {
|
||||||
|
switch(length) {
|
||||||
|
case 0:
|
||||||
|
if(!value) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
[[fallthrough]];
|
||||||
|
case 2:
|
||||||
|
// If asked to pretend the offset was originally two digits then either of: an unsigned
|
||||||
|
// 8-bit value or a sign-extended 8-bit value as having been originally 8-bit.
|
||||||
|
//
|
||||||
|
// This kicks the issue of whether sign was extended appropriately to functionality tests.
|
||||||
|
if(
|
||||||
|
!(value & 0xff00) ||
|
||||||
|
((value & 0xff80) == 0xff80) ||
|
||||||
|
((value & 0xff80) == 0x0000)
|
||||||
|
) {
|
||||||
|
stream << prefix << to_hex(value, 2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
[[fallthrough]];
|
||||||
|
default:
|
||||||
|
stream << prefix << to_hex(value, 4);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
using Source = InstructionSet::x86::Source;
|
using Source = InstructionSet::x86::Source;
|
||||||
const Source source = pointer.source<false>();
|
const Source source = pointer.source<false>();
|
||||||
switch(source) {
|
switch(source) {
|
||||||
// to_string handles all direct register names correctly.
|
// to_string handles all direct register names correctly.
|
||||||
default: return InstructionSet::x86::to_string(source, instruction.operation_size());
|
default: return InstructionSet::x86::to_string(source, instruction.operation_size());
|
||||||
|
|
||||||
case Source::Immediate:
|
case Source::Immediate: {
|
||||||
return to_hex(
|
std::stringstream stream;
|
||||||
instruction.operand(),
|
append(stream, instruction.operand(), instruction.operation_size() == InstructionSet::x86::DataSize::Byte ? 2 : 4, "");
|
||||||
instruction.operation_size() == InstructionSet::x86::DataSize::Byte ? 2 : 4
|
return stream.str();
|
||||||
);
|
}
|
||||||
|
|
||||||
case Source::DirectAddress:
|
case Source::DirectAddress:
|
||||||
case Source::Indirect:
|
case Source::Indirect:
|
||||||
@ -91,25 +118,7 @@ std::string to_string(InstructionSet::x86::DataPointer pointer, const Instructio
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(addOffset) {
|
if(addOffset) {
|
||||||
switch(offset_length) {
|
append(stream, instruction.offset(), offset_length, "+");
|
||||||
case 0:
|
|
||||||
if(!instruction.offset()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
[[fallthrough]];
|
|
||||||
case 2:
|
|
||||||
// TODO: this mismatches some tests because it doesn't eliminate sign extensions.
|
|
||||||
// But when is it permissible to eliminate sign extensions? Always for now, and deal
|
|
||||||
// with it when testing actual execution?
|
|
||||||
if(!(instruction.offset() & 0xff00)) {
|
|
||||||
stream << '+' << to_hex(instruction.offset(), 2);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
[[fallthrough]];
|
|
||||||
default:
|
|
||||||
stream << '+' << to_hex(instruction.offset(), 4);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
stream << ']';
|
stream << ']';
|
||||||
return stream.str();
|
return stream.str();
|
||||||
@ -128,10 +137,10 @@ std::string to_string(InstructionSet::x86::DataPointer pointer, const Instructio
|
|||||||
|
|
||||||
- (NSArray<NSString *> *)testFiles {
|
- (NSArray<NSString *> *)testFiles {
|
||||||
NSString *path = [NSString stringWithUTF8String:TestSuiteHome];
|
NSString *path = [NSString stringWithUTF8String:TestSuiteHome];
|
||||||
NSSet *allowList = nil; /*
|
NSSet *allowList = nil;
|
||||||
[[NSSet alloc] initWithArray:@[
|
// [[NSSet alloc] initWithArray:@[
|
||||||
@"D0.5.json.gz",
|
// @"83.0.json.gz",
|
||||||
]]; */
|
// ]];
|
||||||
|
|
||||||
// Unofficial opcodes; ignored for now.
|
// Unofficial opcodes; ignored for now.
|
||||||
NSSet *ignoreList =
|
NSSet *ignoreList =
|
||||||
|
Loading…
Reference in New Issue
Block a user