flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > 64bit fastcall string literals and vararg

Author
Thread Post new topic Reply to topic
johnsa



Joined: 31 Jul 2013
Posts: 1
johnsa 28 Feb 2015, 23:33
Hey,

I've recently moved to using fasm from masm etc.

How would I go about using 64bit fastcall macro and support some form of string literals and vararg ?

for example:

Code:
fastcall myFunction, "a message"

; (normally in masm and jwasm I would use:

invoke myFunction, CStr("a message")
    


And how would a vararg work?

Code:

; I'm used to

myFunction proc frame uses rsi arguments:VARARG
ret
endp

; and then rcx = count and arguments are on the stack 

    
[/code]
Post 28 Feb 2015, 23:33
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20460
Location: In your JS exploiting you and your system
revolution 01 Mar 2015, 01:43
johnsa wrote:
How would I go about using 64bit fastcall macro and support some form of string literals and vararg ?
Code:
include 'win64ax.inc'

.code

proc start
        fastcall func,'string1','string2'
        fastcall ExitProcess,0
endp

proc func arg1,arg2,arg3,arg4,more_args
        mov     [arg1],rcx
        mov     [arg2],rdx
        mov     [arg3],r8
        mov     [arg4],r9
        ;...
        ret
endp

.end start    
johnsa wrote:
... and then rcx = count and arguments are on the stack
fastcall does not support using rcx as the argument count because the first argument is placed in rcx. You can of course modify the fasm macros to place the count in rcx (or rax, or whatever) but it is then no longer a fastcall under the normal definition.
Post 01 Mar 2015, 01:43
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.