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. --- html/subx/013immediate_addressing.cc.html | 104 ++++++++++++++++-------------- 1 file changed, 55 insertions(+), 49 deletions(-) (limited to 'html/subx/013immediate_addressing.cc.html') diff --git a/html/subx/013immediate_addressing.cc.html b/html/subx/013immediate_addressing.cc.html index 6215b01c..80939a21 100644 --- a/html/subx/013immediate_addressing.cc.html +++ b/html/subx/013immediate_addressing.cc.html @@ -396,58 +396,64 @@ if ('onhashchange' in window) { 332 333 :(scenario copy_imm32_to_r32) 334 # op ModRM SIB displacement immediate -335 b8 03 0a 0b 0c 0d # copy 0x0d0c0b0a to EBX (reg 3) +335 bb 0a 0b 0c 0d # copy 0x0d0c0b0a to EBX (reg 3) 336 +run: copy imm32 0x0d0c0b0a to reg 3 337 338 :(before "End Single-Byte Opcodes") -339 case 0xb8: { // copy imm32 to r32 -340 uint8_t modrm = next(); -341 int32_t arg2 = imm32(); -342 uint8_t reg1 = modrm&0x7; // ignore mod bits -343 trace(2, "run") << "copy imm32 0x" << HEXWORD << arg2 << " to reg " << NUM(reg1) << end(); -344 Reg[reg1].i = arg2; -345 break; -346 } -347 -348 //: -349 -350 :(scenario copy_imm32_to_mem_at_r32) -351 % Reg[3].i = 0x60; -352 # op ModRM SIB displacement immediate -353 c7 03 0a 0b 0c 0d # copy 0x0d0c0b0a to *EBX (reg 3) -354 +run: copy imm32 0x0d0c0b0a to effective address -355 +run: effective address is mem at address 0x60 (reg 3) -356 -357 :(before "End Single-Byte Opcodes") -358 case 0xc7: { // copy imm32 to r32 -359 uint8_t modrm = next(); -360 int32_t arg2 = imm32(); -361 trace(2, "run") << "copy imm32 0x" << HEXWORD << arg2 << " to effective address" << end(); -362 int32_t* arg1 = effective_address(modrm); -363 *arg1 = arg2; -364 break; -365 } -366 -367 //:: push -368 -369 :(scenario push_imm32) -370 % Reg[ESP].u = 0x14; -371 # op ModRM SIB displacement immediate -372 68 af 00 00 00 # push *EAX (reg 0) to stack -373 +run: push imm32 0x000000af -374 +run: ESP is now 0x00000010 -375 +run: contents at ESP: 0x000000af -376 -377 :(before "End Single-Byte Opcodes") -378 case 0x68: { -379 int32_t val = imm32(); -380 trace(2, "run") << "push imm32 0x" << HEXWORD << val << end(); -381 Reg[ESP].u -= 4; -382 *reinterpret_cast<uint32_t*>(&Mem.at(Reg[ESP].u)) = val; -383 trace(2, "run") << "ESP is now 0x" << HEXWORD << Reg[ESP].u << end(); -384 trace(2, "run") << "contents at ESP: 0x" << HEXWORD << *reinterpret_cast<uint32_t*>(&Mem.at(Reg[ESP].u)) << end(); -385 break; -386 } +339 case 0xb8: +340 case 0xb9: +341 case 0xba: +342 case 0xbb: +343 case 0xbc: +344 case 0xbd: +345 case 0xbe: +346 case 0xbf: { // copy imm32 to r32 +347 uint8_t reg1 = op & 0x7; +348 int32_t arg2 = imm32(); +349 trace(2, "run") << "copy imm32 0x" << HEXWORD << arg2 << " to reg " << NUM(reg1) << end(); +350 Reg[reg1].i = arg2; +351 break; +352 } +353 +354 //: +355 +356 :(scenario copy_imm32_to_mem_at_r32) +357 % Reg[3].i = 0x60; +358 # op ModRM SIB displacement immediate +359 c7 03 0a 0b 0c 0d # copy 0x0d0c0b0a to *EBX (reg 3) +360 +run: copy imm32 0x0d0c0b0a to effective address +361 +run: effective address is mem at address 0x60 (reg 3) +362 +363 :(before "End Single-Byte Opcodes") +364 case 0xc7: { // copy imm32 to r32 +365 uint8_t modrm = next(); +366 int32_t arg2 = imm32(); +367 trace(2, "run") << "copy imm32 0x" << HEXWORD << arg2 << " to effective address" << end(); +368 int32_t* arg1 = effective_address(modrm); +369 *arg1 = arg2; +370 break; +371 } +372 +373 //:: push +374 +375 :(scenario push_imm32) +376 % Reg[ESP].u = 0x14; +377 # op ModRM SIB displacement immediate +378 68 af 00 00 00 # push *EAX (reg 0) to stack +379 +run: push imm32 0x000000af +380 +run: ESP is now 0x00000010 +381 +run: contents at ESP: 0x000000af +382 +383 :(before "End Single-Byte Opcodes") +384 case 0x68: { +385 int32_t val = imm32(); +386 trace(2, "run") << "push imm32 0x" << HEXWORD << val << end(); +387 Reg[ESP].u -= 4; +388 *reinterpret_cast<uint32_t*>(&Mem.at(Reg[ESP].u)) = val; +389 trace(2, "run") << "ESP is now 0x" << HEXWORD << Reg[ESP].u << end(); +390 trace(2, "run") << "contents at ESP: 0x" << HEXWORD << *reinterpret_cast<uint32_t*>(&Mem.at(Reg[ESP].u)) << end(); +391 break; +392 } -- cgit 1.4.1-2-gfad0