diff --git a/OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm b/OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm index a9ef904df..1ef7c754f 100644 --- a/OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm +++ b/OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm @@ -60,10 +60,12 @@ template void test_far(const InstructionT &instruction, // MARK: - Decoder -template std::vector::InstructionT> decode(const std::initializer_list &stream) { +template +std::vector::InstructionT> decode(const std::initializer_list &stream, bool set_32_bit = false) { // Decode by offering up all data at once. std::vector::InstructionT> instructions; InstructionSet::x86::Decoder decoder; + decoder.set_32bit_protected_mode(set_32_bit); instructions.clear(); const uint8_t *byte = stream.begin(); while(byte != stream.end()) { @@ -76,6 +78,7 @@ template std::vector: // Grab a byte-at-a-time decoding and check that it matches the previous. { InstructionSet::x86::Decoder decoder; + decoder.set_32bit_protected_mode(set_32_bit); auto previous_instruction = instructions.begin(); for(auto item: stream) { @@ -303,4 +306,22 @@ template std::vector: test_far(instructions[0], Operation::CALLF, 0x7856, 0x3412); } +- (void)testLDSLESEtc { + auto run_test = [](bool is_32, DataSize size) { + const auto instructions = decode({ + 0xc5, 0x33, // lds (%bp, %di), %si + 0xc4, 0x17, // les (%bx), %dx + 0x0f, 0xb2, 0x17, // lss edx, (edi) + }, is_32); + + XCTAssertEqual(instructions.size(), 3); + test(instructions[0], size, Operation::LDS, ScaleIndexBase(Source::eBP, Source::eDI), Source::eSI); + test(instructions[1], size, Operation::LES, ScaleIndexBase(Source::eBX), Source::eDX); + test(instructions[2], size, Operation::LSS, ScaleIndexBase(Source::eBX), Source::eDX); + }; + + run_test(false, DataSize::Word); + run_test(true, DataSize::DWord); +} + @end