mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-15 14:27:29 +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:
@@ -142,7 +142,7 @@ namespace {
|
|||||||
0x23, 0xaa, 0x2c, 0x5b, 0x2a, 0xd2, 0xf7, 0x5f, 0x18, 0x86, 0x90, 0x25, 0x64, 0xb7, 0xc3
|
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);
|
XCTAssertEqual(instructions.size(), 63);
|
||||||
|
|
||||||
// sub $0xea77,%ax
|
// sub $0xea77,%ax
|
||||||
@@ -301,4 +301,19 @@ namespace {
|
|||||||
[self assert:instructions[62] operation:Operation::MOV size:1 operand:0xc3 destination:Source::BH];
|
[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
|
@end
|
||||||
|
@@ -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.
|
// Sign extend if a single byte operand is feeding a two-byte instruction.
|
||||||
if(operation_size_ == 2) {
|
if(operation_size_ == 2) {
|
||||||
operand_ |= (operand_ & 0x80) ? 0xff : 0x00;
|
operand_ |= (operand_ & 0x80) ? 0xff00 : 0x0000;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2: operand_ = inward_data_ >> 48; inward_data_ <<= 16; break;
|
case 2: operand_ = inward_data_ >> 48; inward_data_ <<= 16; break;
|
||||||
|
Reference in New Issue
Block a user