flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Windows > fastcall and RSP usage

Author
Thread Post new topic Reply to topic
system error



Joined: 01 Sep 2013
Posts: 477
fastcall and RSP usage
Not an expert on macro but I took it that FASM's fastcall allocating shadow space before populating the arguments instead of after? No?


Code:
fastcall [printf],fmt,rsp

vs

mov rdx,rsp
mov rcx,fmt
sub rsp,0x20
call [printf]
add rsp,0x20
...
...
fmt db '%016llX",0




The fastcall version is off by 32 bytes. Not saying this is wrong or not, just want to know if this is the intended behaviour / design.
Post 03 Nov 2016, 02:32
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14784
Location: Not in LAX
Any usage of RSP is not guaranteed to work. Basically if you use RSP then it is your own responsibility to make sure you get what you intend. This caveat the same for any call method; ccall, stdcall, etc.
Post 03 Nov 2016, 02:36
View user's profile Send private message Visit poster's website Reply with quote
system error



Joined: 01 Sep 2013
Posts: 477
hmmm... okay. Thanks mom.
Post 03 Nov 2016, 02:40
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14784
Location: Not in LAX
If you still want to use RSP directly and take advantage of the fastcall macro you could do this:

Code:
mov rdx,rsp
fastcall [printf],fmt,rdx

But it would still be prudent to check the disassembly to make sure it does what you expect.
Post 03 Nov 2016, 05:59
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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.