about summary refs log tree commit diff stats
path: root/subx/011direct_addressing.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2018-01-03 23:16:30 -0800
committerKartik K. Agaram <vc@akkartik.com>2018-01-03 23:16:30 -0800
commitce07871e946c204edb994e7522c12cd7ee72ea36 (patch)
tree1974e7d2080c878994b5d3f3441b0016b7f2ac9f /subx/011direct_addressing.cc
parentacce384bcc88d5b300b913c14b9872081a182155 (diff)
downloadmu-ce07871e946c204edb994e7522c12cd7ee72ea36.tar.gz
4180
Incomplete implementation of `xchg` since commit 4175.
Diffstat (limited to 'subx/011direct_addressing.cc')
-rw-r--r--subx/011direct_addressing.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/subx/011direct_addressing.cc b/subx/011direct_addressing.cc
index 58576a42..00e0e877 100644
--- a/subx/011direct_addressing.cc
+++ b/subx/011direct_addressing.cc
@@ -219,11 +219,13 @@ case 0x89: {  // copy r32 to r/m32
 
 :(scenario xchg_r32_with_r32)
 % Reg[3].i = 0xaf;
+% Reg[0].i = 0x2e;
 # op  ModRM   SIB   displacement  immediate
   87  d8                                      # exchange EBX (reg 3) with EAX (reg 0)
 +run: exchange reg 3 with effective address
 +run: effective address is reg 0
-+run: storing 0x000000af
++run: storing 0x000000af in effective address
++run: storing 0x0000002e in reg 3
 
 :(before "End Single-Byte Opcodes")
 case 0x87: {  // exchange r32 with r/m32
@@ -231,8 +233,11 @@ case 0x87: {  // exchange r32 with r/m32
   uint8_t reg2 = (modrm>>3)&0x7;
   trace(2, "run") << "exchange reg " << NUM(reg2) << " with effective address" << end();
   int32_t* arg1 = effective_address(modrm);
+  int32_t tmp = *arg1;
   *arg1 = Reg[reg2].i;
-  trace(2, "run") << "storing 0x" << HEXWORD << *arg1 << end();
+  Reg[reg2].i = tmp;
+  trace(2, "run") << "storing 0x" << HEXWORD << *arg1 << " in effective address" << end();
+  trace(2, "run") << "storing 0x" << HEXWORD << Reg[reg2].i << " in reg " << NUM(reg2) << end();
   break;
 }