From 9ecbcc552ee4646bdec8181bb6a8757a7b0fd700 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 18 Oct 2017 02:00:44 -0700 Subject: 4082 subx: correct a 'copy' ('mov') instruction as well to get its operand right from the opcode. --- subx/011direct_addressing.cc | 2 +- subx/013immediate_addressing.cc | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'subx') diff --git a/subx/011direct_addressing.cc b/subx/011direct_addressing.cc index 827ce41e..a8f3fe7e 100644 --- a/subx/011direct_addressing.cc +++ b/subx/011direct_addressing.cc @@ -235,7 +235,7 @@ case 0x53: case 0x54: case 0x55: case 0x56: -case 0x57: { +case 0x57: { // push r32 to stack uint8_t reg = op & 0x7; trace(2, "run") << "push reg " << NUM(reg) << end(); const int32_t val = Reg[reg].u; diff --git a/subx/013immediate_addressing.cc b/subx/013immediate_addressing.cc index 14121d42..4773e75f 100644 --- a/subx/013immediate_addressing.cc +++ b/subx/013immediate_addressing.cc @@ -332,14 +332,20 @@ case 7: { :(scenario copy_imm32_to_r32) # op ModRM SIB displacement immediate - b8 03 0a 0b 0c 0d # copy 0x0d0c0b0a to EBX (reg 3) + bb 0a 0b 0c 0d # copy 0x0d0c0b0a to EBX (reg 3) +run: copy imm32 0x0d0c0b0a to reg 3 :(before "End Single-Byte Opcodes") -case 0xb8: { // copy imm32 to r32 - uint8_t modrm = next(); +case 0xb8: +case 0xb9: +case 0xba: +case 0xbb: +case 0xbc: +case 0xbd: +case 0xbe: +case 0xbf: { // copy imm32 to r32 + uint8_t reg1 = op & 0x7; int32_t arg2 = imm32(); - uint8_t reg1 = modrm&0x7; // ignore mod bits trace(2, "run") << "copy imm32 0x" << HEXWORD << arg2 << " to reg " << NUM(reg1) << end(); Reg[reg1].i = arg2; break; -- cgit 1.4.1-2-gfad0