diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2017-10-12 22:28:06 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2017-10-12 22:31:02 -0700 |
commit | ed3c266e2d782ffe2857402f6fb3cee339a0f447 (patch) | |
tree | 407ec83cdb8da05fb3aa99f2688e02afe7929b3c /subx | |
parent | 763396e53328bc31d68e791ae729159b646cf013 (diff) | |
download | mu-ed3c266e2d782ffe2857402f6fb3cee339a0f447.tar.gz |
4044
subx: now starting on subtraction instructions.
Diffstat (limited to 'subx')
-rw-r--r-- | subx/010core.cc | 3 | ||||
-rw-r--r-- | subx/011add.cc | 17 |
2 files changed, 18 insertions, 2 deletions
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; +} |