From: Herbert Kleebauer on
Frank Kotler wrote:
> bwaichu(a)yahoo.com wrote:

> > port equ 10
> >
> > and I want to push 10 onto the stack, I would just write:
> >
> > push word port
> >
> > Is this correct? Is the size required?
>
> Again, not good in 32-bit code. The "word" is required if you really
> want to push a word, if you omit the size, Nasm will default to pushing
> a dword.
>
> Nasm will *also* default to storing the 10 in 4 bytes. There's a shorter
> form of "push imm" if the parameter will fit in a signed byte (-128 -
> +127). In spite of the fact that you can't push a byte on the stack -
> only 2 bytes or 4 bytes - the syntax to get the short form is "push byte
> 10" or "push byte port". Easier to use the "-O" switch on the command
> line, and let Nasm worry about it. But that's a different issue.

And don't forget the funny NASM syntax for the short form of the
16 bit push:

o16 push byte 10
From: Frank Kotler on
Herbert Kleebauer wrote:
> Frank Kotler wrote:
>
>>bwaichu(a)yahoo.com wrote:
>
>
>>>port equ 10
>>>
>>>and I want to push 10 onto the stack, I would just write:
>>>
>>>push word port
>>>
>>>Is this correct? Is the size required?
>>
>>Again, not good in 32-bit code. The "word" is required if you really
>>want to push a word, if you omit the size, Nasm will default to pushing
>>a dword.
>>
>>Nasm will *also* default to storing the 10 in 4 bytes. There's a shorter
>>form of "push imm" if the parameter will fit in a signed byte (-128 -
>>+127). In spite of the fact that you can't push a byte on the stack -
>>only 2 bytes or 4 bytes - the syntax to get the short form is "push byte
>>10" or "push byte port". Easier to use the "-O" switch on the command
>>line, and let Nasm worry about it. But that's a different issue.
>
>
> And don't forget the funny NASM syntax for the short form of the
> 16 bit push:
>
> o16 push byte 10

Oh, no! How could I have forgotten to explain that to a beginner? :)

Lindela expresses it much more intuitively, I'm sure.

o16 = 66, since this is presumed to be 32-bit code. In 16-bit code, it
wouldn't emit anything.

push byte = 6A

10 = 0A

What's the problem?

Best,
Frank

P.S. Nice post on the "relocation" issue, Herbert!
From: Wolfgang Kern on

Frank Kotler wrote:
....
> o16 = 66, since this is presumed to be 32-bit code. In 16-bit code, it
> wouldn't emit anything.

Shouldn't it ?

> push byte = 6A
> 10 = 0A

> What's the problem?

use16:
6a 10 push SX-byte to word sp-2
66 6a 10 push SX byte to dword sp-4
use32:
6a 10 push SX-byte to dword sp-4
66 6a 10 push SX-byte to word sp-2

> P.S. Nice post on the "relocation" issue, Herbert!

Yes.

__
wolfgang