From the intel instruction reference:
68 id PUSH imm32
It means pushing dword-sized immediates is valid in 64-bit program.
So I wrote the following program:
section .text
global _start
_start:
call _foo
mov rax, 60
syscall
_foo:
push word 0xFFFF ;ok
pop ax ;ok
push dword 0xFFFFFFFF ; warning: signed dword value exceeds bounds
pop rax
call _bar
ret
_bar:
ret
Why did I get this warning? From the intel reference:
The operand size (16, 32, or 64 bits) determines the amount by which the stack pointer is decremented (2, 4 or 8). If the source operand is an immediate of size less than the operand size, a sign-extended value is pushed on the stack.
In my case the operand size is 32 bits. It's not less than operand size. So I expected everything was going to be okay. But, when executing the program after push dword 0xFFFFFFFF
the 64-bit sign extension of it was pushed actually.
Also it's not clear why do we have push imm32
instruction in 64-bit mode. If we try to
pop eax ;instruction not supported in 64-bit mode
So even if we could push 32-bit into the stack, we cannot pop it into 32-bit register.