From 0cbb481fa41c47f1bec95fe96fb734ec11e38ae1 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 8 Mar 2022 14:56:27 -0500 Subject: [PATCH] Add a formal SIB test. --- OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm b/OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm index 206070194..4cc5bdbbe 100644 --- a/OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm +++ b/OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm @@ -330,4 +330,16 @@ std::vector::InstructionT> decode(c run_test(true, DataSize::DWord); } +- (void)testSIB { + const auto instructions = decode({ + // add edx, -0x7d(ebp + eax*2) + 0x01, 0x54, 0x45, 0x83 + }, true); + + XCTAssertEqual(instructions.size(), 1); + 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. +} + @end