about summary refs log tree commit diff stats
path: root/subx/012indirect_addressing.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2018-01-24 21:34:25 -0800
committerKartik K. Agaram <vc@akkartik.com>2018-01-24 21:38:08 -0800
commit3639efce2021fce6c49f34ce90a6f84fbe6f8fa6 (patch)
tree3ca7adc4bc9f95b4929a8d78d0c32534eff9d35d /subx/012indirect_addressing.cc
parentdcfbf7a4f5fca29865b3119c474589b18e8dd8b6 (diff)
downloadmu-3639efce2021fce6c49f34ce90a6f84fbe6f8fa6.tar.gz
4193
Diffstat (limited to 'subx/012indirect_addressing.cc')
-rw-r--r--subx/012indirect_addressing.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/subx/012indirect_addressing.cc b/subx/012indirect_addressing.cc
index 579c5255..a01b03f8 100644
--- a/subx/012indirect_addressing.cc
+++ b/subx/012indirect_addressing.cc
@@ -408,3 +408,23 @@ case 0x8f: {  // pop stack into r/m32
   }
   break;
 }
+
+//:: special-case for loading address from disp32 rather than register
+
+:(scenario add_r32_to_mem_at_displacement)
+% Reg[3].i = 0x10;  // source
+% SET_WORD_IN_MEM(0x60, 1);
+# op  ModR/M  SIB   displacement  immediate
+  01  1d            60 00 00 00              # add EBX to *0x60
+# ModR/M in binary: 00 (indirect mode) 011 (src EBX) 101 (dest in disp32)
++run: add EBX to r/m32
++run: effective address is 0x60 (disp32)
++run: storing 0x00000011
+
+:(before "End Mod 0 Special-cases")
+case 5: {  // exception: mod 0b00 rm 0b101 => incoming disp32
+  uint32_t addr = imm32();
+  result = reinterpret_cast<int32_t*>(&Mem.at(addr));
+  trace(2, "run") << "effective address is 0x" << std::hex << addr << " (disp32)" << end();
+  break;
+}