Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Pushing immediate values Syntax

186 views
Skip to first unread message

Paul K. McKneely

unread,
Dec 29, 2011, 11:50:52 AM12/29/11
to
I only recently discovered that you can push immediate values
onto the stack. "push" works for byte and "pushw" pushes a
word. I am looking for the syntax for how to push 32-bit value
and 64-bit value. It appears from reading the AMD64 manuals
that you can't push a 64-bit value, only a 32-bit value sign-extended
to 64 bits.

Thanks.


Rugxulo

unread,
Dec 29, 2011, 4:31:56 PM12/29/11
to
Hi,

On Dec 29, 10:50 am, "Paul K. McKneely" <pkmckne...@sbcglobal.net>
wrote:
>
> I only recently discovered that you can push immediate values
> onto the stack.

Sure, introduced with the 80186.

http://en.wikipedia.org/wiki/80186

> "push" works for byte and "pushw" pushes a word.

No, you can't push only a byte size, and "pushw" isn't really a
mnemonic. Most assemblers just use "push" for all uses.

For instance, try under DEBUG:

push 5
pop al

(hint: it won't work, but "pop ax" is okay)

> I am looking for the syntax for how to push 32-bit value
> and 64-bit value. It appears from reading the AMD64 manuals
> that you can't push a 64-bit value, only a 32-bit value sign-extended
> to 64 bits.

You might want to ask on alt.lang.asm or (moderated) comp.lang.asm.x86
instead as you'll get more responders, esp. since I can't answer for
AMD64. But anyways, I'll quote from (old) NASM 0.98.39's manual:

PUSH reg16 ; o16 50+r [8086]
PUSH reg32 ; o32 50+r [386]

PUSH r/m16 ; o16 FF /6 [8086]
PUSH r/m32 ; o32 FF /6 [386]

PUSH CS ; 0E [8086]
PUSH DS ; 1E [8086]
PUSH ES ; 06 [8086]
PUSH SS ; 16 [8086]
PUSH FS ; 0F A0 [386]
PUSH GS ; 0F A8 [386]

PUSH imm8 ; 6A ib [186]
PUSH imm16 ; o16 68 iw [186]
PUSH imm32 ; o32 68 id [386]

Thorsten Schott

unread,
Jan 4, 2012, 5:28:34 PM1/4/12
to
Push works for all but 64-Bit!

The crazy fact is: the processor signextend's an 32-Bit Immed. and push
this self created 64-Bit Value onto the Stack, but isn't able to push an
64-Bit Immed.!

The easiest way I know is:

mov rax, 08877665544332211h
push rax

ready!

There are some limitations with 64-Bit Values even 64-Bit Offset's!

regards
thorsten
0 new messages