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

Adds a test for 0x83 and fixes sign extension.

ODA doesn't seem to accept 0x82, but testing 0x83 adds some confidence.
This commit is contained in:
Thomas Harte 2021-01-13 20:42:21 -05:00
parent a24ae727a7
commit 8c0e06e645
2 changed files with 17 additions and 2 deletions

View File

@ -142,7 +142,7 @@ namespace {
0x23, 0xaa, 0x2c, 0x5b, 0x2a, 0xd2, 0xf7, 0x5f, 0x18, 0x86, 0x90, 0x25, 0x64, 0xb7, 0xc3
}];
// 68 instructions are expected.
// 63 instructions are expected.
XCTAssertEqual(instructions.size(), 63);
// sub $0xea77,%ax
@ -301,4 +301,19 @@ namespace {
[self assert:instructions[62] operation:Operation::MOV size:1 operand:0xc3 destination:Source::BH];
}
- (void)test83 {
[self decode:{
0x83, 0x10, 0x80, // adcw $0xff80,(%bx,%si)
0x83, 0x3b, 0x04, // cmpw $0x4,(%bp,%di)
0x83, 0x2f, 0x09, // subw $0x9,(%bx)
}];
// 68 instructions are expected.
XCTAssertEqual(instructions.size(), 3);
[self assert:instructions[0] operation:Operation::ADC size:2 source:Source::Immediate destination:Source::IndBXPlusSI operand:0xff80];
[self assert:instructions[1] operation:Operation::CMP size:2 source:Source::Immediate destination:Source::IndBPPlusDI operand:0x4];
[self assert:instructions[2] operation:Operation::SUB size:2 source:Source::Immediate destination:Source::IndBX operand:0x9];
}
@end

View File

@ -585,7 +585,7 @@ std::pair<int, Instruction> Decoder::decode(const uint8_t *source, size_t length
// Sign extend if a single byte operand is feeding a two-byte instruction.
if(operation_size_ == 2) {
operand_ |= (operand_ & 0x80) ? 0xff : 0x00;
operand_ |= (operand_ & 0x80) ? 0xff00 : 0x0000;
}
break;
case 2: operand_ = inward_data_ >> 48; inward_data_ <<= 16; break;