flat assembler
Message board for the users of flat assembler.
Index
> Windows > Question on FASM format for an STDCALL object module. |
Author |
|
LocoDelAssembly 23 Dec 2006, 02:20
So if you want to manually do the code why "ret numArgs*4" isn't enough?
Including "macro\proc32.inc" or one of the win32*.inc includes you can use the proc macro which automatically adjust the stack accordingly to the selected calling convention when you use "ret" since "ret" is defined as a macro in the context of the procedure and performs the appropiate epilogue sequence. Check http://flatassembler.net/docs.php?article=win32 for more info. If nothing of this helps you then sorry you have not provided enough code to see what exactly you want (I speak for myself of course). |
|||
23 Dec 2006, 02:20 |
|
hutch-- 23 Dec 2006, 03:32
The assembler code is the simple part, what I could not find in the reference is how to set the module to STDCALL convention. If I write a conventional C calling convention with the notation I posted in the first post, it works fine.
Now as before this leading code produces a successful C calling convention module. Code: format MS COFF section '.text' code readable executable public _your_proc_name _your_proc_name: ; assembler code goes here. What I could not find in the reference material was a combination of the "public" directive to make the procedure visible AND the label name that would produce a valid STDCALL object module. It is NOT code analysis or assistance that I need, its a specific FASM format that will generate a valid object module that is visible to a linker using STDCALL. |
|||
23 Dec 2006, 03:32 |
|
hutch-- 23 Dec 2006, 03:41
hutch-- wrote: The assembler code is the simple part, what I could not find in the reference is how to set the module to STDCALL convention. If I write a conventional C calling convention with the notation I posted in the first post, it works fine. |
|||
23 Dec 2006, 03:41 |
|
LocoDelAssembly 23 Dec 2006, 05:38
Hutch, just in case you want a semi-automatized way then this may help you
Code: macro public symbol, size { if 1 match size, size ; To ensure that size will be the actual value \{ if ~ size eqtype 1 display "Integer spected",13,10 err end if public symbol as \`symbol \# '@' \# \`size else \} public symbol end if } format MS COFF section '.text' code readable executable ProcSize equ 4 public _ProcName, ProcSize public addNums, 8 _ProcName: ; assembler code goes here addNums: mov eax, [esp+4] add eax, [esp+8] ret 8 PS: BTW, thanks for posting your question, it helped me to found a fasm bug |
|||
23 Dec 2006, 05:38 |
|
vid 23 Dec 2006, 09:55
hutch: in FASM, you can export symbol under different name than it has in source. Great feature.
Code: public ProcName as '_ProcName@16' This doesn't impose any HLL rules on you. So there is nothing like "stdcall module" or "ccall module" - just a MSCOFF file, with code as you like at, and exports as you like them |
|||
23 Dec 2006, 09:55 |
|
hutch-- 23 Dec 2006, 10:44
vid,
Thanks, its a cleaner solution than the one I found. Regards, hutch at movsd dot com |
|||
23 Dec 2006, 10:44 |
|
LocoDelAssembly 23 Dec 2006, 16:20
My macro does exactly the same that vid does in "public symbol as \`symbol \# '@' \# \`size". With "public addNums, 8" produces "public addNums as 'addNums@8'" and if you don't specify size argument it produces "public addNums".
|
|||
23 Dec 2006, 16:20 |
|
hutch-- 23 Dec 2006, 23:38
LocoDelAssembly,
Thanks for the offer, your macro looks fine but in the context of the test library that I have up and going, I need to keep it at its most basic notation as I am not all that familiar with specific FASM notation. Regards, hutch at movsd dot com |
|||
23 Dec 2006, 23:38 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.