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>2017-10-13 00:54:59 -0700
committerKartik K. Agaram <vc@akkartik.com>2017-10-13 00:54:59 -0700
commit280f5115465501464b2f7e9f4671f9e8f3b52147 (patch)
treeedf239245638eb309e63660ffea39af4ebff6962 /subx/012indirect_addressing.cc
parent7a219c68bae6dbe214aec69a051015e851e32400 (diff)
downloadmu-280f5115465501464b2f7e9f4671f9e8f3b52147.tar.gz
4055
subx: Implement 'and' for the addressing modes we've built so far.
Diffstat (limited to 'subx/012indirect_addressing.cc')
-rw-r--r--subx/012indirect_addressing.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/subx/012indirect_addressing.cc b/subx/012indirect_addressing.cc
index f9aafda5..6e9a5f01 100644
--- a/subx/012indirect_addressing.cc
+++ b/subx/012indirect_addressing.cc
@@ -79,3 +79,40 @@ case 0x2b: {  // subtract r/m32 from r32
   BINARY_ARITHMETIC_OP(-, Reg[arg1].i, *arg2);
   break;
 }
+
+//:: and
+
+:(scenario and_r32_with_mem_at_r32)
+% Reg[0].i = 0x60;
+% Mem.at(0x60) = 0x0d;
+% Mem.at(0x61) = 0x0c;
+% Mem.at(0x62) = 0x0b;
+% Mem.at(0x63) = 0x0a;
+% Reg[3].i = 0xff;
+# op  ModRM   SIB   displacement  immediate
+  21  18                                      # and EBX (reg 3) with *EAX (reg 0)
++run: and reg 3 with effective address
++run: effective address is mem at address 0x60 (reg 0)
++run: storing 0x0000000d
+
+//:
+
+:(scenario and_mem_at_r32_with_r32)
+% Reg[0].i = 0x60;
+% Mem.at(0x60) = 0xff;
+% Reg[3].i = 0x0a0b0c0d;
+# op  ModRM   SIB   displacement  immediate
+  23  18                                      # and *EAX (reg 0) with EBX (reg 3)
++run: and effective address with reg 3
++run: effective address is mem at address 0x60 (reg 0)
++run: storing 0x0000000d
+
+:(before "End Single-Byte Opcodes")
+case 0x23: {  // and r/m32 with r32
+  uint8_t modrm = next();
+  uint8_t arg1 = (modrm>>3)&0x7;
+  trace(2, "run") << "and effective address with reg " << NUM(arg1) << end();
+  const int32_t* arg2 = effective_address(modrm);
+  BINARY_BITWISE_OP(&, Reg[arg1].u, *arg2);
+  break;
+}