flat assembler
Message board for the users of flat assembler.
Index
> Main > Assembling multiple source files |
Author |
|
bitshifter 17 May 2010, 03:50
You can have all the sections you want, but FASM has no internal linker.
|
|||
17 May 2010, 03:50 |
|
baldr 17 May 2010, 19:49
LnS,
Separate compile and link stages are OK with FASM (although you apparently will need linker). Import from DLLs usually requires import libraries for them (GoLink provides capability to use export directories of those DLLs to be used directly) and _/_imp_/@ name decoration in extrn directives: Code: ; coff1.fasm format MS COFF include "Win32AX.Inc" .code public _msg extrn "__imp__MessageBoxA@16" as MessageBox: dword proc _msg c lpText: dword, lpCaption: dword invoke MessageBox, HWND_DESKTOP, [lpText], [lpCaption], MB_OK ret endp Code: ; coff2.fasm format MS COFF include "Win32AX.Inc" .code public start start: extrn _msg ccall _msg, _text, _caption ret .data _text db "Hello, world!", 0 _caption db "extrn/public", 0 link /subsystem:windows /entry:start coff1.obj coff2.obj user32.lib or GoLink.exe coff1.obj coff2.obj user32.dll produces working PE (GoLink seems to understand _/_imp_/@ decoration). Matt Pietrek wrote nice explanation in his fine Under The Hood MSJ column relating this matter. |
|||
17 May 2010, 19:49 |
|
LnS 17 May 2010, 20:15
Thanks baldr, that's exactly what I was looking for!
Just one thing, in the definition for extrn "__imp__MessageBoxA@16" as MessageBox: dword , is the syntax supposed to reflect the following pattern: extrn "__imp__{ApiName}@{LengthInBytesOfAllArguments}" as {ExportName}: {ReturnType} for any given API? [/i] |
|||
17 May 2010, 20:15 |
|
LocoDelAssembly 17 May 2010, 21:08
It is more like "__imp__{ApiName}@{LengthInBytesOfAllArguments}" as {SymbolToBeUsedInSource}: {SymbolType}
Note that __imp__* are dword pointers to functions (for that reason baldr used invoke instead of stdcall) |
|||
17 May 2010, 21:08 |
|
baldr 18 May 2010, 03:27
LnS,
The pattern is simple:
|
|||
18 May 2010, 03:27 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.