diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2018-01-24 21:23:20 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2018-01-24 21:23:20 -0800 |
commit | 0e87e934786ca5c83e013e2043ea51e5ab04be4d (patch) | |
tree | 85ab24e5b4f0a00d9e676f10fd9b426c9f7f6270 | |
parent | bb62d65e5de791c9cb4e5923c90958e7e72a3e2d (diff) | |
download | mu-0e87e934786ca5c83e013e2043ea51e5ab04be4d.tar.gz |
4191
-rw-r--r-- | subx/014index_addressing.cc | 16 |
1 files changed, 15 insertions, 1 deletions
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 |