flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
ManOfSteel 25 Jan 2014, 22:14
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 25 Jan 2014, 22:20
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 25 Jan 2014, 22:26
Code: call [puts] ... call [exit] |
|||
![]() |
|
Tyler 25 Jan 2014, 23:02
OHH!!! Yep. That did it. I forgot those stored pointers instead actually being the pointer I want. Thanks.
|
|||
![]() |
|
sinsi 26 Jan 2014, 06:39
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 26 Jan 2014, 07:12
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 26 Jan 2014, 07:18
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 26 Jan 2014, 07:48
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.