flat assembler
Message board for the users of flat assembler.
Index
> Windows > MS64 COFF create message box |
Author |
|
Ariiio 07 Feb 2024, 21:16
I want to create a x64 program that opens a message box and says 'hello world'. I know I could use
Code: format PE64 GUI Code: fasm test.asm
gcc test.obj -o test
_________________ 🔨 |
|||||||||||
07 Feb 2024, 21:16 |
|
Ariiio 08 Feb 2024, 15:13
MatQuasar wrote: I tested OK if add this line to the beginning: could you explain why I need to reserve space on the stack before I call my function? I dont see any reason why I should do this since the function doesnt pop anything off the stack _________________ 🔨 |
|||
08 Feb 2024, 15:13 |
|
revolution 08 Feb 2024, 16:05
The FASTCALL convention dictates the stack alignment. Some of the API calls use the MOVDQA instruction to access the stack. So if RSP is not aligned then the code crashes.
|
|||
08 Feb 2024, 16:05 |
|
MatQuasar 08 Feb 2024, 17:02
Ariiio wrote:
I also learned from @revolution, here is his/her extra notes: revolution wrote: You don't need to continually use sub/add. You can do only at entry and exit as long as you reserve enough for the largest needed for any function call. Only in x64 Windows programming, in 32-bit I don't have to reserve stack space. Extra note: https://learn.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-170 wrote: Since 16 bytes is a common alignment size for XMM operations, this value should work for most code. |
|||
08 Feb 2024, 17:02 |
|
Furs 09 Feb 2024, 15:36
Ariiio wrote: could you explain why I need to reserve space on the stack before I call my function? I dont see any reason why I should do this since the function doesnt pop anything off the stack 64-bit ABI on Unix OSes doesn't have it and it's perfectly sane. |
|||
09 Feb 2024, 15:36 |
|
revolution 09 Feb 2024, 15:53
Furs wrote: 64-bit ABI on Unix OSes doesn't have it and it's perfectly sane. But not for the user space SYS-V libraries. Alignment is still a requirement. |
|||
09 Feb 2024, 15:53 |
|
Furs 10 Feb 2024, 20:10
Alignment ≠shadow space. Alignment is meh, but can be dealt with and not nearly as bad. You can still push args for instance (just an extra dummy push if alignment needs it, not a big deal).
|
|||
10 Feb 2024, 20:10 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.