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

Undo broken extension-word DS assumption.

8 failures.
This commit is contained in:
Thomas Harte 2023-09-28 22:17:14 -04:00
parent a24e17c320
commit b76899f2bc
2 changed files with 25 additions and 17 deletions

View File

@ -906,9 +906,6 @@ template<bool is_32bit> class Instruction {
++extension; ++extension;
} }
if(has_length_extension()) { if(has_length_extension()) {
// As per the rule stated for segment(), this class provides ::DS for any instruction
// that doesn't have a segment override.
if(segment_override == Source::None) segment_override = Source::DS;
extensions_[extension] = ImmediateT( extensions_[extension] = ImmediateT(
(length << 6) | (int(repetition) << 4) | ((int(segment_override) & 7) << 1) | int(lock) (length << 6) | (int(repetition) << 4) | ((int(segment_override) & 7) << 1) | int(lock)
); );

View File

@ -146,7 +146,7 @@ std::string to_string(
- (NSArray<NSString *> *)testFiles { - (NSArray<NSString *> *)testFiles {
NSString *path = [NSString stringWithUTF8String:TestSuiteHome]; NSString *path = [NSString stringWithUTF8String:TestSuiteHome];
NSSet *allowList = [NSSet setWithArray:@[ NSSet *allowList = [NSSet setWithArray:@[
@"F6.7.json.gz", // @"F6.7.json.gz",
]]; ]];
// Unofficial opcodes; ignored for now. // Unofficial opcodes; ignored for now.
@ -286,7 +286,7 @@ std::string to_string(
return [[NSString stringWithUTF8String:operation.c_str()] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; return [[NSString stringWithUTF8String:operation.c_str()] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
} }
- (bool)applyDecodingTest:(NSDictionary *)test file:(NSString *)file { - (bool)applyDecodingTest:(NSDictionary *)test file:(NSString *)file assert:(BOOL)assert {
using Decoder = InstructionSet::x86::Decoder<InstructionSet::x86::Model::i8086>; using Decoder = InstructionSet::x86::Decoder<InstructionSet::x86::Model::i8086>;
Decoder decoder; Decoder decoder;
@ -306,15 +306,17 @@ std::string to_string(
}; };
const auto decoded = decoder.decode(data.data(), data.size()); const auto decoded = decoder.decode(data.data(), data.size());
XCTAssert( if(assert) {
decoded.first == [encoding count], XCTAssert(
"Wrong length of instruction decoded for %@ — decoded %d rather than %lu from %@; file %@", decoded.first == [encoding count],
test[@"name"], "Wrong length of instruction decoded for %@ — decoded %d rather than %lu from %@; file %@",
decoded.first, test[@"name"],
(unsigned long)[encoding count], decoded.first,
hex_instruction(), (unsigned long)[encoding count],
file hex_instruction(),
); file
);
}
if(decoded.first != [encoding count]) { if(decoded.first != [encoding count]) {
return false; return false;
} }
@ -365,7 +367,16 @@ std::string to_string(
--adjustment; --adjustment;
} }
XCTAssert(isEqual, "%@ doesn't match %@ or similar, was %@ within %@", test[@"name"], [decodings anyObject], hex_instruction(), file); if(assert) {
XCTAssert(
isEqual,
"%@ doesn't match %@ or similar, was %@ within %@",
test[@"name"],
[decodings anyObject],
hex_instruction(),
file
);
}
return isEqual; return isEqual;
} }
@ -380,11 +391,11 @@ std::string to_string(
NSUInteger successes = 0; NSUInteger successes = 0;
for(NSDictionary *test in testsInFile) { for(NSDictionary *test in testsInFile) {
// A single failure per instruction is fine. // A single failure per instruction is fine.
if(![self applyDecodingTest:test file:file]) { if(![self applyDecodingTest:test file:file assert:YES]) {
[failures addObject:file]; [failures addObject:file];
// Attempt a second decoding, to provide a debugger hook. // Attempt a second decoding, to provide a debugger hook.
[self applyDecodingTest:test file:file]; [self applyDecodingTest:test file:file assert:NO];
break; break;
} }