about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2017-12-30 23:20:15 -0800
committerKartik K. Agaram <vc@akkartik.com>2017-12-30 23:20:15 -0800
commit7db3c535215cbae9711f7d387e6f9cf5f332b86a (patch)
tree7204e4abb9d04d177e71948cd6af0fcc3d21733a /subx
parent708eae3109ca71f7a7178684aaaced7c16196559 (diff)
downloadmu-7db3c535215cbae9711f7d387e6f9cf5f332b86a.tar.gz
4175
Diffstat (limited to 'subx')
-rw-r--r--subx/011direct_addressing.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/subx/011direct_addressing.cc b/subx/011direct_addressing.cc
index 9e5f6e80..58576a42 100644
--- a/subx/011direct_addressing.cc
+++ b/subx/011direct_addressing.cc
@@ -215,6 +215,27 @@ case 0x89: {  // copy r32 to r/m32
   break;
 }
 
+//:: xchg
+
+:(scenario xchg_r32_with_r32)
+% Reg[3].i = 0xaf;
+# 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
+
+:(before "End Single-Byte Opcodes")
+case 0x87: {  // exchange r32 with r/m32
+  uint8_t modrm = next();
+  uint8_t reg2 = (modrm>>3)&0x7;
+  trace(2, "run") << "exchange reg " << NUM(reg2) << " with effective address" << end();
+  int32_t* arg1 = effective_address(modrm);
+  *arg1 = Reg[reg2].i;
+  trace(2, "run") << "storing 0x" << HEXWORD << *arg1 << end();
+  break;
+}
+
 //:: push
 
 :(scenario push_r32)