diff --git a/InstructionSets/x86/Decoder.cpp b/InstructionSets/x86/Decoder.cpp index 432ec8507..19b75c4b7 100644 --- a/InstructionSets/x86/Decoder.cpp +++ b/InstructionSets/x86/Decoder.cpp @@ -629,7 +629,7 @@ std::pair::InstructionT> Decoder::decode(con displacement_size_ = sizes[mod]; memreg = Source::Indirect; - if(allow_sib_) { + if(address_size_ == AddressSize::b32) { // 32-bit decoding: the range of potential indirections is expanded, // and may segue into obtaining a SIB. sib_ = ScaleIndexBase(0, Source::None, reg_table[rm]); @@ -931,7 +931,6 @@ template void Decoder::set_32bit_protected_mode(bool enable return; } - allow_sib_ = enabled; if(enabled) { default_address_size_ = address_size_ = AddressSize::b32; default_data_size_ = data_size_ = DataSize::DWord; diff --git a/InstructionSets/x86/Decoder.hpp b/InstructionSets/x86/Decoder.hpp index 7c411423e..6c837df2a 100644 --- a/InstructionSets/x86/Decoder.hpp +++ b/InstructionSets/x86/Decoder.hpp @@ -196,7 +196,6 @@ template class Decoder { DataSize default_data_size_ = DataSize::Word; AddressSize address_size_ = AddressSize::b16; DataSize data_size_ = DataSize::Word; - bool allow_sib_ = false; /// Resets size capture and all fields with default values. void reset_parsing() { diff --git a/OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm b/OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm index 4cc5bdbbe..78f0689f1 100644 --- a/OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm +++ b/OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm @@ -333,13 +333,16 @@ std::vector::InstructionT> decode(c - (void)testSIB { const auto instructions = decode({ // add edx, -0x7d(ebp + eax*2) - 0x01, 0x54, 0x45, 0x83 + 0x01, 0x54, 0x45, 0x83, + + // add edx, -0x80(si) + 0x67, 0x01, 0x54, 0x80, }, true); - XCTAssertEqual(instructions.size(), 1); + XCTAssertEqual(instructions.size(), 2); test(instructions[0], DataSize::DWord, Operation::ADD, Source::eDX, ScaleIndexBase(1, Source::eAX, Source::eBP), 0x00, -125); - // Noting that a multiplier of 2 is a scale of 1, - // since the scale is in log2. + test(instructions[1], DataSize::DWord, Operation::ADD, Source::eDX, ScaleIndexBase(Source::eSI), 0x00, -128); + XCTAssertEqual(instructions[1].address_size(), AddressSize::b16); } @end