about summary refs log tree commit diff stats
path: root/subx/013immediate_addressing.cc
diff options
context:
space:
mode:
Diffstat (limited to 'subx/013immediate_addressing.cc')
-rw-r--r--subx/013immediate_addressing.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/subx/013immediate_addressing.cc b/subx/013immediate_addressing.cc
index dd1ce4c0..2e4b459a 100644
--- a/subx/013immediate_addressing.cc
+++ b/subx/013immediate_addressing.cc
@@ -350,6 +350,7 @@ case 0xb8: {  // copy imm32 to r32
 }
 
 //:
+
 :(scenario copy_imm32_to_mem_at_r32)
 % Reg[3].i = 0x60;
 # op  ModRM   SIB   displacement  immediate
@@ -366,3 +367,24 @@ case 0xc7: {  // copy imm32 to r32
   *arg1 = arg2;
   break;
 }
+
+//:: push
+
+:(scenario push_imm32)
+% Reg[ESP].u = 0x14;
+# op  ModRM   SIB   displacement  immediate
+  68                              af 00 00 00  # push *EAX (reg 0) to stack
++run: push imm32 0x000000af
++run: ESP is now 0x00000010
++run: contents at ESP: 0x000000af
+
+:(before "End Single-Byte Opcodes")
+case 0x68: {
+  int32_t val = imm32();
+  trace(2, "run") << "push imm32 0x" << HEXWORD << val << end();
+  Reg[ESP].u -= 4;
+  *reinterpret_cast<uint32_t*>(&Mem.at(Reg[ESP].u)) = val;
+  trace(2, "run") << "ESP is now 0x" << HEXWORD << Reg[ESP].u << end();
+  trace(2, "run") << "contents at ESP: 0x" << HEXWORD << *reinterpret_cast<uint32_t*>(&Mem.at(Reg[ESP].u)) << end();
+  break;
+}