diff --git a/OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm b/OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm index f2a5711b7..eec2c5512 100644 --- a/OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm +++ b/OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm @@ -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 diff --git a/Processors/Decoders/x86/x86.cpp b/Processors/Decoders/x86/x86.cpp index 576a14487..25f05a7cd 100644 --- a/Processors/Decoders/x86/x86.cpp +++ b/Processors/Decoders/x86/x86.cpp @@ -585,7 +585,7 @@ std::pair 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;