flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
ManOfSteel
It's been ages since I last coded something for Windows, so don't quote me on this.
I believe you must pass those arguments through the stack, not registers. In other words, push all those arguments (in reverse order) and then call the function. Or just use the invoke macro provided by fasmw (invoke puts,hello). |
|||
![]() |
|
Tyler
IIRC, that's exactly correct for stdcall. But I'm trying to learn 64 bit. MS (and all others that I know of) use register based calling conventions on AMD64. (http://en.wikipedia.org/wiki/X86_calling_conventions#Microsoft_x64_calling_convention)
|
|||
![]() |
|
sinsi
Code: call [puts] ... call [exit] |
|||
![]() |
|
Tyler
OHH!!! Yep. That did it. I forgot those stored pointers instead actually being the pointer I want. Thanks.
|
|||
![]() |
|
sinsi
Code: ; setup shadow space sub rsp, 32 You need a minimum of 4 slots but you haven't aligned the stack to 16. When your program starts the stack is 8-aligned because of the "call entry" the loader does. Code: ; setup shadow space sub rsp, 32+8 I think win64ax can take care of the aligning via "invoke" but I've never used it. |
|||
![]() |
|
revolution
sinsi wrote: I think win64ax can take care of the aligning via "invoke" but I've never used it. Code: macro .code { section '.text' code readable executable entry $ sub rsp,8 local main,code entry equ main if main <> code jmp main end if code: } macro .end value { label entry at value ;... |
|||
![]() |
|
Tyler
I didn't know that, thanks. I don't think the 32+8 will do it. If it's 8 aligned, it could also be 16 aligned (like 64) If it is both, then subtracting 40 would make it 8 aligned. It would work if the stack happened to be 8 aligned and not 16 aligned (like 48 ), but that presumably only happens 50% of the time.
I think Code: shr rsp,4 shl rsp,4 EDIT: Nevermind, I was thinking of it mathematically. I just tested it and it appears to always be 8 aligned and never 16 aligned. |
|||
![]() |
|
revolution
Tyler wrote: EDIT: Nevermind, I was thinking of it mathematically. I just tested it and it appears to always be 8 aligned and never 16 aligned. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.