about summary refs log tree commit diff stats
path: root/subx/014indirect_addressing.cc
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-09-22 23:19:39 -0700
committerKartik Agaram <vc@akkartik.com>2018-09-22 23:19:39 -0700
commit7d4e351a0d1e3c4e71b58d3218b4e6b833f542f2 (patch)
tree8f8b8e62848b76ce5debf3ef89ad6f0e1c381de8 /subx/014indirect_addressing.cc
parent2b36eee9b13eb16fb2e4b05d7e26f6d09f431912 (diff)
downloadmu-7d4e351a0d1e3c4e71b58d3218b4e6b833f542f2.tar.gz
4503
Include LEA (load effective address) in the SubX subset of x86 ISA.
Diffstat (limited to 'subx/014indirect_addressing.cc')
-rw-r--r--subx/014indirect_addressing.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/subx/014indirect_addressing.cc b/subx/014indirect_addressing.cc
index ccbf994c..b48cbd85 100644
--- a/subx/014indirect_addressing.cc
+++ b/subx/014indirect_addressing.cc
@@ -641,3 +641,26 @@ case 2:  // indirect + disp32 addressing
 +run: effective address is initially 0x61 (EAX)
 +run: effective address is 0x60 (after adding disp32)
 +run: storing 0x00000011
+
+//:: lea
+
+:(before "End Initialize Op Names(name)")
+put(name, "8d", "load effective address of memory in rm32 into r32");
+
+:(scenario lea)
+% Reg[EAX].u = 0x60;
+== 0x1
+# op  ModR/M  SIB   displacement  immediate
+  8d  18
+# ModR/M in binary: 00 (indirect mode) 011 (dest EBX) 000 (src EAX)
++run: lea into EBX
++run: effective address is 0x60 (EAX)
+
+:(before "End Single-Byte Opcodes")
+case 0x8d: {  // lea m32 to r32
+  uint8_t modrm = next();
+  uint8_t arg1 = (modrm>>3)&0x7;
+  trace(90, "run") << "lea into " << rname(arg1) << end();
+  Reg[arg1].u = effective_address_number(modrm);
+  break;
+}