about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2017-10-12 22:17:28 -0700
committerKartik K. Agaram <vc@akkartik.com>2017-10-12 22:17:28 -0700
commit763396e53328bc31d68e791ae729159b646cf013 (patch)
tree94e4c9d554180d69004966875ddd14d161bd5f3e
parentea09c910658e04784488d680111cd91cef1ab514 (diff)
downloadmu-763396e53328bc31d68e791ae729159b646cf013.tar.gz
4043
-rw-r--r--subx/010core.cc1
-rw-r--r--subx/011add.cc26
2 files changed, 25 insertions, 2 deletions
diff --git a/subx/010core.cc b/subx/010core.cc
index 61ae583e..b59f745e 100644
--- a/subx/010core.cc
+++ b/subx/010core.cc
@@ -61,6 +61,7 @@ SF = ZF = OF = false;
 vector<uint8_t> Mem;
 uint32_t End_of_program = 0;
 :(before "End Reset")
+Mem.clear();
 Mem.resize(1024);
 End_of_program = 0;
 
diff --git a/subx/011add.cc b/subx/011add.cc
index f0f37f85..0d2eef31 100644
--- a/subx/011add.cc
+++ b/subx/011add.cc
@@ -4,7 +4,7 @@
 % Reg[3].i = 0x10;
 % Reg[0].i = 0x60;
 # word in addresses 0x60-0x63 has value 1
-% Mem[0x60] = 1;
+% Mem.at(0x60) = 1;
 # op  ModR/M  SIB   displacement  immediate
   01  18                                     # add EBX (reg 3) to *EAX (reg 0)
 +run: add reg 3 to effective address
@@ -90,9 +90,31 @@ case 3:
 
 :(scenario add_imm32_to_mem_at_r32)
 % Reg[3].i = 0x60;
-% Mem[0x60] = 1;
+% Mem.at(0x60) = 1;
 # op  ModR/M  SIB   displacement  immediate
   81  03                          0a 0b 0c 0d  # add 0x0d0c0b0a to *EBX (reg 3)
 +run: add imm32 0x0d0c0b0a to effective address
 +run: effective address is mem at address 0x60 (reg 3)
 +run: storing 0x0d0c0b0b
+
+//:
+
+:(scenario add_mem_at_r32_to_r32)
+% Reg[0].i = 0x60;
+% Reg[3].i = 0x10;
+% Mem.at(0x60) = 1;
+# op  ModR/M  SIB   displacement  immediate
+  03  18                                      # add *EAX (reg 0) to EBX (reg 3)
++run: add effective address to reg 3
++run: effective address is mem at address 0x60 (reg 0)
++run: storing 0x00000011
+
+:(before "End Single-Byte Opcodes")
+case 0x03: {  // add r/m32 to r32
+  uint8_t modrm = next();
+  uint8_t arg1 = (modrm>>3)&0x7;
+  trace(2, "run") << "add effective address to reg " << NUM(arg1) << end();
+  const int32_t* arg2 = effective_address(modrm);
+  BINARY_ARITHMETIC_OP(+, Reg[arg1].i, *arg2);
+  break;
+}