From ce07871e946c204edb994e7522c12cd7ee72ea36 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 3 Jan 2018 23:16:30 -0800 Subject: 4180 Incomplete implementation of `xchg` since commit 4175. --- subx/011direct_addressing.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'subx/011direct_addressing.cc') 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; } -- cgit 1.4.1-2-gfad0