flat assembler
Message board for the users of flat assembler.
Index
> Windows > fasm procedure called in masm |
Author |
|
JohnFound 03 Dec 2010, 10:21
You better separate only the needed procedure and compile it to COFF. Then you can link the object file with your program.
Read more here: http://flatassembler.net/docs.php?article=manual#2.4.3 |
|||
03 Dec 2010, 10:21 |
|
flapjack 03 Dec 2010, 14:41
thanks john, but i don't know how to do that
also, when i said i want to call a procedure, i was refering to the whole snippet so the question was supposed to be: how to compile that snippet into a library or something that i will use in masm to call that snippet with something like : invoke fasm_snippet i really appreciate your help, but maybe some compiling instructions (step by step) would make my day. thanks |
|||
03 Dec 2010, 14:41 |
|
JohnFound 03 Dec 2010, 15:03
The above snipped will be compiled to .exe file. That the directive "format PE" means.
You simply can't use it in this form, except you need windows PE file. That's why, you should change "format PE" to something more suitable for invoke from external code. Here you can two options - "format PE DLL" in order to create DLL and "format COFF" ("format MS COFF") in order to compile it to object file, that later can be linked with your application. It is highly recommended to read FASM manual and especially the section about format directive. The rest is very easy - load the edited code in FASMW and start "Compile" from the menu. Then get the created object (or DLL) file and use it with MASM linker to build the application. |
|||
03 Dec 2010, 15:03 |
|
baldr 03 Dec 2010, 15:21
flapjack,
Are you familiar with compile/link? Here's example: Code: ; SaySomething.fasm format MS COFF include "Win32A.Inc" section ".text" executable readable code proc SaySomething stdcall something: dword invoke MessageBox, HWND_DESKTOP, [something], NULL, MB_OK ret endp public SaySomething as "_SaySomething@4"; stdcall decoration extrn "__imp__MessageBoxA@16" as MessageBox: dword; dllimport stdcall decoration Code: ; GottaSaySomething.masm .386 .model flat, stdcall externdef SaySomething: proto stdcall something: dword .data something db "Hello, world!", 0 .code here: invoke SaySomething, ADDR something ret end here |
|||
03 Dec 2010, 15:21 |
|
flapjack 05 Dec 2010, 18:24
baldr wrote: flapjack, i compiled the fasm code, i got one.obj i compiled the masm code, i got two.obj then when i tried to link them into an .exe, i got an error: unresolved external symbol __imp__messageboxa@16 i tried to make the exe in masm linker with the following line: \masm32\bin\link.exe /SUBSYSTEM:WINDOWS /OUT:three.exe one.obj two.obj now i know i may have a linker problem. any suggestions? |
|||
05 Dec 2010, 18:24 |
|
baldr 05 Dec 2010, 18:59
flapjack,
MessageBox() is somewhat external to both source files, did you use user32.lib in link's command line? There is at least one method to tell linker about it in the source, you may apply any of them. |
|||
05 Dec 2010, 18:59 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.