From 0e87e934786ca5c83e013e2043ea51e5ab04be4d Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 24 Jan 2018 21:23:20 -0800 Subject: 4191 --- subx/014index_addressing.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'subx') diff --git a/subx/014index_addressing.cc b/subx/014index_addressing.cc index f457c761..666b775d 100644 --- a/subx/014index_addressing.cc +++ b/subx/014index_addressing.cc @@ -30,7 +30,7 @@ uint32_t effective_address_from_sib(uint8_t mod) { } else { // base == EBP && mod == 0 - addr = imm32(); + addr = imm32(); // ignore base trace(2, "run") << "effective address is initially 0x" << std::hex << addr << " (disp32)" << end(); } uint8_t index = (sib>>3)&0x7; @@ -59,3 +59,17 @@ uint32_t effective_address_from_sib(uint8_t mod) { +run: effective address is initially 0x5e (EAX) +run: effective address is 0x60 (after adding ECX*1) +run: storing 0x00000011 + +:(scenario add_r32_to_mem_at_displacement_using_sib) +% Reg[3].i = 0x10; // source +% Reg[0].i = 0x5e; // dest base +% Reg[1].i = 0x2; // dest index +% SET_WORD_IN_MEM(0x60, 1); +# op ModR/M SIB displacement immediate + 01 1c 25 60 00 00 00 # add EBX to *0x60 +# ModR/M in binary: 00 (indirect mode) 011 (src EBX) 100 (dest in SIB) +# SIB in binary: 00 (scale 1) 100 (no index) 101 (not EBP but disp32) ++run: add EBX to r/m32 ++run: effective address is initially 0x60 (disp32) ++run: effective address is 0x60 ++run: storing 0x00000011 -- cgit 1.4.1-2-gfad0