News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

question about push IMMEDIATE

Started by *DEAD*, December 17, 2007, 06:38:17 AM

Previous topic - Next topic

*DEAD*

Hi, hope i got the terminology right above
anyway, ive just written a small snippet of code for doing a prime test on a number. Now i want this to be called (i dont know if im still allowed to call it a function in asm, lol) and i want to push either a 0 or 1 on the stack depending on the result of the test. Now, i just though about this, but if i simply go
push 1
then what goes on the stack. Is it a BYTE, WORD, DWORD ect. This would of course be useful to know when popping the value again in the calling function.

MichaelW

In 32-bit code a DWORD would be pushed.

print uhex$(esp),13,10
push 1
print uhex$(esp),13,10
pop eax
print uhex$(eax),13,10


0012FFC0
0012FFBC
00000001

eschew obfuscation


sinsi

And, of course, in 16-bit code a WORD is always pushed - you can't PUSH a BYTE

.data
  a_byte db 1
.code
  push a_byte

error A2070: invalid instruction operands

But with INVOKE, you can (indirectly)

my_proc proto c x:byte
.data
  a_byte db 1
.code
  invoke my_proc,a_byte
;the invoke gets translated as
;  mov al,a_byte
;  push ax
;  call my_proc

Light travels faster than sound, that's why some people seem bright until you hear them.