flat assembler
Message board for the users of flat assembler.

Index > Main > x64: How to use same calling convention as x32?

Author
Thread Post new topic Reply to topic
alorent



Joined: 05 Dec 2005
Posts: 221
alorent 13 Oct 2009, 20:02
Hello,

I have the following code in x64:

Code:
MyProc proc Param1, Param2

   mov  rcx, 0
   mov  rax, Param1
   mov  rbx, Param2
   ret

MyProc endp 

; call my above procedure 

stdcall MyProc, 1, 2    


The problem is that (of course!) it uses the fastcall convention and put the parameters on registers but I want them on the stack as like I have in 32-bit procedures. I'd like that "stdcall MyProc, 1, 2" generates:

Code:
push 2
push 1
call MyProc     


How this can be done? I have tried to do some hack on "PROC64.inc" but that's too advanced for me Smile

Would be great to have another calling convention to produce the above like:

Code:
old_stdcall MyProc, 1, 2    


Thanks!
Post 13 Oct 2009, 20:02
View user's profile Send private message Reply with quote
Fanael



Joined: 03 Jul 2009
Posts: 168
Fanael 13 Oct 2009, 20:12
Code:
macro old_stdcall proc, [args]
{
  common if ~ args eq
    reverse push args
  common end if
  common call proc
}    
If you want to make stdcall function, then you have to forget about existence of proc macro - in 64-bit mode it creates fastcall subroutine. Only way is doing all required things manually (or make your own version of proc macro, which makes stdcall function, but it's difficult thing to do).
Post 13 Oct 2009, 20:12
View user's profile Send private message Reply with quote
alorent



Joined: 05 Dec 2005
Posts: 221
alorent 14 Oct 2009, 09:01
Thanks a lot Fanael!! Very Happy
Post 14 Oct 2009, 09:01
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.