From 7d4e351a0d1e3c4e71b58d3218b4e6b833f542f2 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 22 Sep 2018 23:19:39 -0700 Subject: 4503 Include LEA (load effective address) in the SubX subset of x86 ISA. --- subx/014indirect_addressing.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'subx/014indirect_addressing.cc') 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; +} -- cgit 1.4.1-2-gfad0