From ed3c266e2d782ffe2857402f6fb3cee339a0f447 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 12 Oct 2017 22:28:06 -0700 Subject: 4044 subx: now starting on subtraction instructions. --- subx/010core.cc | 3 +-- subx/011add.cc | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'subx') diff --git a/subx/010core.cc b/subx/010core.cc index b59f745e..058cc065 100644 --- a/subx/010core.cc +++ b/subx/010core.cc @@ -83,7 +83,7 @@ End_of_program = 0; +load: 4 -> 0c +load: 5 -> 0d +run: add imm32 0x0d0c0b0a to reg EAX -+reg: storing 0x0d0c0b0a in reg EAX ++run: storing 0x0d0c0b0a :(code) // helper for tests: load a program into memory from a textual representation @@ -107,7 +107,6 @@ void run_one_instruction() { int32_t arg2 = imm32(); trace(2, "run") << "add imm32 0x" << HEXWORD << arg2 << " to reg EAX" << end(); BINARY_ARITHMETIC_OP(+, Reg[EAX].i, arg2); - trace(98, "reg") << "storing 0x" << HEXWORD << Reg[EAX].i << " in reg EAX" << end(); break; } // End Single-Byte Opcodes diff --git a/subx/011add.cc b/subx/011add.cc index 0d2eef31..5fe3523b 100644 --- a/subx/011add.cc +++ b/subx/011add.cc @@ -118,3 +118,20 @@ case 0x03: { // add r/m32 to r32 BINARY_ARITHMETIC_OP(+, Reg[arg1].i, *arg2); break; } + +//: + +:(scenario sub_imm32_from_eax) +% Reg[EAX].i = 0x0d0c0baa; +# op ModR/M SIB displacement immediate + 2d 0a 0b 0c 0d # subtract 0x0d0c0b0a from EAX (reg 0) ++run: subtract imm32 0x0d0c0b0a from reg EAX ++run: storing 0x000000a0 + +:(before "End Single-Byte Opcodes") +case 0x2d: { // subtract imm32 from EAX + int32_t arg2 = imm32(); + trace(2, "run") << "subtract imm32 0x" << HEXWORD << arg2 << " from reg EAX" << end(); + BINARY_ARITHMETIC_OP(-, Reg[EAX].i, arg2); + break; +} -- cgit 1.4.1-2-gfad0