flat assembler
Message board for the users of flat assembler.

Index > Windows > tasm to fasm syntax help

Author
Thread Post new topic Reply to topic
r22



Joined: 27 Dec 2004
Posts: 805
r22 18 Jan 2005, 05:22
push dword ptr fs:[0] 64 67 FF 36 00 00
\/
how do i do it in fasm?
fasm
push dword ptr fs:[0] 64 FF 34 00 00 00 00
makes it a large dword ptr fs:0

any help would be appreciated
Post 18 Jan 2005, 05:22
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 18 Jan 2005, 07:33
Code:
    push  dword [fs:0]

; or 

    pushd  [fs:0]
    
Post 18 Jan 2005, 07:33
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 18 Jan 2005, 14:01
And if you are under 32bit there is no hint needed.
just push [fs:0]
^o) or is there sth I missed (I think there should be no harm even if FSelector is 16bit)

EDIT: There is a bug. According to manuals - FASM should choose the shortest one, but PUSH DWORD[FS:0] assembles to:
Code:
64:FF35 00000000    

which is 7 bytes
The shortest form of this instruction is:
Code:
64:67:FF36 0000    

with 6 bytes (WOW - it uses TWO prefixes)
I think that assembler get fooled by this 2pre+2decode byte, but HERE the extra prefix pays off because the 0-data is 2 bytes shorter.
Strange thing is that I checked and even OllyDbg doesn't know this short form. It disassembles, when it meets it, but if you assemble with OllyDbg, it assembles to 7-byte version (I think its faster because of one less prefix).
Post 18 Jan 2005, 14:01
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 18 Jan 2005, 17:10
fasm doesn't use 16-bit addressing in 32-bit mode unless you tell to do it (with "push [fs:word 0]"), because the prefixed instructions even if shorted, usually were decoded slower. The earliest versions of fasm did such optimization, but later I've decided that this was the bad choice.

However I have just noticed that in the latest releases, during making the changes to adapt the assembler for future integration of AMD64 support, I have introduced a small bug, which caused fasm to ignore the size operator for address (so "push [fs:word 0]" is by fasm 1.56 assembled exactly the same as "push [fs:0]). I am fixing it now, look out for the new release.
Post 18 Jan 2005, 17:10
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 18 Jan 2005, 22:58
If I understood correctly - push [fs:word 0] should assemble to 6-byte operation/command, but it still pushes DWORD to the stack.
To my knowledge this command should push word (I mean written exactly as push [fs:word 0]), but I fear to argue here because I know that ADD, SUB, AND, ... have shorter forms but still dealing with 4-byte variables (m32/r32).

Just checking - did I understand correctly?

_________________
My updated idol Very Happy http://www.agner.org/optimize/
Post 18 Jan 2005, 22:58
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 19 Jan 2005, 00:23
johnfound: i thought "pushd" is just a macro


Last edited by vid on 19 Jan 2005, 11:54; edited 1 time in total
Post 19 Jan 2005, 00:23
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 19 Jan 2005, 08:35
Quote:
If I understood correctly - push [fs:word 0] should assemble to 6-byte operation/command, but it still pushes DWORD to the stack.

As I wrote above, there is a bug in 1.56 causing it - check with some earlier release, or with the 1.57 - which is coming out.

Quote:
To my knowledge this command should push word (I mean written exactly as push [fs:word 0])

To push word use the "push word [fs:0]" command, everything inside the square brackets define the address on which you operate, so if you put size operator there, it applies to address size.
Post 19 Jan 2005, 08:35
View user's profile Send private message Visit poster's website 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.