diff options
Diffstat (limited to 'subx')
-rw-r--r-- | subx/011direct_addressing.cc | 23 | ||||
-rw-r--r-- | subx/012indirect_addressing.cc | 35 | ||||
-rw-r--r-- | subx/013immediate_addressing.cc | 37 |
3 files changed, 92 insertions, 3 deletions
diff --git a/subx/011direct_addressing.cc b/subx/011direct_addressing.cc index a12b5541..f474ac99 100644 --- a/subx/011direct_addressing.cc +++ b/subx/011direct_addressing.cc @@ -149,7 +149,7 @@ case 0xf7: { // xor r32 with r/m32 break; } -//:: compare +//:: compare (cmp) :(scenario compare_r32_with_r32_greater) % Reg[0].i = 0x0a0b0c0d; @@ -193,3 +193,24 @@ case 0x39: { // set SF if r/m32 < r32 +run: compare reg 3 with effective address +run: effective address is reg 0 +run: SF=0; ZF=1; OF=0 + +//:: copy (mov) + +:(scenario copy_r32_to_r32) +% Reg[3].i = 0xaf; +# op ModRM SIB displacement immediate + 89 d8 # copy EBX (reg 3) to EAX (reg 0) ++run: copy reg 3 to effective address ++run: effective address is reg 0 ++run: storing 0x000000af + +:(before "End Single-Byte Opcodes") +case 0x89: { // copy r32 to r/m32 + uint8_t modrm = next(); + uint8_t reg2 = (modrm>>3)&0x7; + trace(2, "run") << "copy reg " << NUM(reg2) << " to effective address" << end(); + int32_t* arg1 = effective_address(modrm); + *arg1 = Reg[reg2].i; + trace(2, "run") << "storing 0x" << HEXWORD << *arg1 << end(); + break; +} diff --git a/subx/012indirect_addressing.cc b/subx/012indirect_addressing.cc index 546df707..3b2944b2 100644 --- a/subx/012indirect_addressing.cc +++ b/subx/012indirect_addressing.cc @@ -193,7 +193,7 @@ case 0x33: { // xor r/m32 with r32 +run: effective address is mem at address 0x60 (reg 3) +run: storing 0xf0f0ff00 -//:: compare +//:: compare (cmp) :(scenario compare_mem_at_r32_with_r32_greater) % Reg[0].i = 0x60; @@ -272,3 +272,36 @@ case 0x3b: { // set SF if r32 < r/m32 +run: compare effective address with reg 3 +run: effective address is mem at address 0x60 (reg 0) +run: SF=0; ZF=1; OF=0 + +//:: copy (mov) + +:(scenario copy_r32_to_mem_at_r32) +% Reg[3].i = 0xaf; +% Reg[0].i = 0x60; +# op ModRM SIB displacement immediate + 89 18 # copy EBX (reg 3) to *EAX (reg 0) ++run: copy reg 3 to effective address ++run: effective address is mem at address 0x60 (reg 0) ++run: storing 0x000000af + +//: + +:(scenario copy_mem_at_r32_to_r32) +% Reg[0].i = 0x60; +% SET_WORD_IN_MEM(0x60, 0x000000af); +# op ModRM SIB displacement immediate + 8b 18 # copy *EAX (reg 0) to EBX (reg 3) ++run: copy effective address to reg 3 ++run: effective address is mem at address 0x60 (reg 0) ++run: storing 0x000000af + +:(before "End Single-Byte Opcodes") +case 0x8b: { // copy r32 to r/m32 + uint8_t modrm = next(); + uint8_t reg1 = (modrm>>3)&0x7; + trace(2, "run") << "copy effective address to reg " << NUM(reg1) << end(); + int32_t* arg2 = effective_address(modrm); + Reg[reg1].i = *arg2; + trace(2, "run") << "storing 0x" << HEXWORD << *arg2 << end(); + break; +} diff --git a/subx/013immediate_addressing.cc b/subx/013immediate_addressing.cc index c370217a..dd1ce4c0 100644 --- a/subx/013immediate_addressing.cc +++ b/subx/013immediate_addressing.cc @@ -229,7 +229,7 @@ case 6: { break; } -//:: compare +//:: compare (cmp) :(scenario compare_imm32_with_eax_greater) % Reg[0].i = 0x0d0c0b0a; @@ -331,3 +331,38 @@ case 7: { +run: combine imm32 0x0d0c0b0a with effective address +run: effective address is mem at address 0x60 (reg 3) +run: SF=0; ZF=1; OF=0 + +//:: copy (mov) + +:(scenario copy_imm32_to_r32) +# op ModRM SIB displacement immediate + b8 03 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(); + 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; +} + +//: +:(scenario copy_imm32_to_mem_at_r32) +% Reg[3].i = 0x60; +# op ModRM SIB displacement immediate + c7 03 0a 0b 0c 0d # copy 0x0d0c0b0a to *EBX (reg 3) ++run: copy imm32 0x0d0c0b0a to effective address ++run: effective address is mem at address 0x60 (reg 3) + +:(before "End Single-Byte Opcodes") +case 0xc7: { // copy imm32 to r32 + uint8_t modrm = next(); + int32_t arg2 = imm32(); + trace(2, "run") << "copy imm32 0x" << HEXWORD << arg2 << " to effective address" << end(); + int32_t* arg1 = effective_address(modrm); + *arg1 = arg2; + break; +} |