about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
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)
' href='#n129'>129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211