flat assembler
Message board for the users of flat assembler.

Index > Main > Two opcodes for push <imm>?

Author
Thread Post new topic Reply to topic
Plue



Joined: 15 Dec 2005
Posts: 151
Plue 22 Dec 2006, 12:42
How come these genrates different opcodes?
push dword 0
push 0

I want the short version when possible, but if I don't put dword after all of my pushes then fasm will error out on indirect memory references. Making my compiler check for this and have it sometimes generate "dword" and sometimes not when it always wants to push a dword seems a bit unneccesary. Can I tell fasm to prefer the short version?

_________________
Roses are red
Violets are blue
Some poems rhyme
And some don't.
Post 22 Dec 2006, 12:42
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 22 Dec 2006, 13:23
Yes, use the PUSHD mnemonic - it defaults to 32-bit while optimizes imm pushes just like the plain PUSH.
Post 22 Dec 2006, 13:23
View user's profile Send private message Visit poster's website Reply with quote
Plue



Joined: 15 Dec 2005
Posts: 151
Plue 03 Jul 2007, 16:07
If I do
Code:
v_s rb 4
pushd [v_s]    

it doesn't work, but with push dword [v_s] it works.
Post 03 Jul 2007, 16:07
View user's profile Send private message Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM 04 Jul 2007, 04:40
That's because you can't push a byte onto a dword stack; because you defined it as "rb 4". Change it to "rd 1" or "dd ?" and it should work. See the FASM principles (etc blah blah blah) in the Documentation section, Tomasz will surely link it Razz

The reasoning for this is that
Code:
 pushd [v_s]     
tries to push [v_s] straight onto a dword stack - which can't be done
Code:
 push dword [v_s]     
is overriding the byte assignment into a dword, which FASM allows to be pushed onto a dword stack.

Now, remember that
Code:
 pushd dword [v_s]     
is always available for less confusion - but it might also make it more confusing Razz

Hope you understood that. Very Happy

P.S. Please correct me if I'm wrong. I am at a friend's house, so no FASM to test Sad

_________________
This calls for... Ultra CRUNCHY Man!
Ta da!! *crunch*
Post 04 Jul 2007, 04:40
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.