flat assembler
Message board for the users of flat assembler.
Index
> Windows > MS COFF and help converting NASM to fasm Goto page 1, 2 Next |
Author |
|
revolution 20 Nov 2016, 12:26
There is an MSCOFF.ASM example file in the download:
Code: ; example of making Win32 COFF object file format MS COFF extrn '__imp__MessageBoxA@16' as MessageBox:dword section '.text' code readable executable public _demo _demo: push 0 push _caption push _message push 0 call [MessageBox] ret section '.data' data readable writeable _caption db 'Win32 assembly',0 _message db 'Coffee time!',0 |
|||
20 Nov 2016, 12:26 |
|
Manos 20 Nov 2016, 12:53
I know the above example.
But instead of: extrn '__imp__MessageBoxA@16' as MessageBox:dword I want to use: include 'C:\Fasm\INCLUDE\win32ax.inc' and instead of pushing the parameters on the stack and calling the function, I want to use: invoke MessageBox, etc, just like MASM projects. Manos. |
|||
20 Nov 2016, 12:53 |
|
revolution 20 Nov 2016, 13:00
You don't need to include the entire win32 set. Just this might be all you need:
Code: include 'macro/proc32.inc' |
|||
20 Nov 2016, 13:00 |
|
Manos 20 Nov 2016, 13:33
revolution wrote: You don't need to include the entire win32 set. Just this might be all you need: It is not enough. Try to assemble the following code: format MS COFF include 'C:\Fasm\INCLUDE\win32ax.inc' .code start: invoke MessageBox,HWND_DESKTOP,"Hi! I'm the example program!",0,MB_OK invoke ExitProcess,0 .end start Manos. |
|||
20 Nov 2016, 13:33 |
|
revolution 20 Nov 2016, 13:38
You don't need ".end" with COFF. The linker will set the entry address. And don't use win32ax, try the include I posted above.
Code: format MS COFF include 'macro/proc32.inc' extrn '__imp__MessageBoxA@16' as MessageBox:dword section '.text' code readable executable public MyCode MyCode: invoke MessageBox,0,caption,message,0 ret section '.data' data readable writeable caption db 'Win32 assembly',0 message db 'Coffee time!',0 |
|||
20 Nov 2016, 13:38 |
|
Manos 20 Nov 2016, 13:58
Hi revolution.
I know your above example. But because I am building an IDE for plain C, MASM and FASM, I would like to avoid the: extrn '__imp__MessageBoxA@16' as MessageBox:dword. I want to use: 'C:\Fasm\INCLUDE\win32ax.inc', like I do in MASM. Manos. |
|||
20 Nov 2016, 13:58 |
|
revolution 20 Nov 2016, 14:10
win32ax won't work for you. You will need to write some type of macro or include file to create all the import names. You will need the extrn's to be included somewhere in the source that fasm sees. Currently there is no file that will do that for you in the fasm download.
|
|||
20 Nov 2016, 14:10 |
|
Manos 20 Nov 2016, 15:44
Yes, you are right.
I have to implement my own include files. Thank you for your replies, Manos. |
|||
20 Nov 2016, 15:44 |
|
Manos 21 Nov 2016, 21:38
In NASM there is the expression: times ($$-$) & 3 nop
How can I phrase the above in FASM ? Thanks, Manos. |
|||
21 Nov 2016, 21:38 |
|
revolution 22 Nov 2016, 03:08
Replace & with and
|
|||
22 Nov 2016, 03:08 |
|
Manos 22 Nov 2016, 11:53
revolution wrote: Replace & with Thang you, it is correct, but I have also to replace the: $$-$ with: $-$$ The correct is: times ($-$$) and 3 nop Manos. |
|||
22 Nov 2016, 11:53 |
|
revolution 22 Nov 2016, 13:05
Manos wrote: The correct is: times ($-$$) and 3 nop Code: align 4 Last edited by revolution on 22 Nov 2016, 13:38; edited 1 time in total |
|||
22 Nov 2016, 13:05 |
|
Manos 22 Nov 2016, 13:37
revolution wrote:
I thought to use: align 4, but I prefer to avoid macros, because my C compiler can emit plain FASM code. My C compiler, (wcc32), accepts also inline assembly. Because my IDE use wcc32, I wish my IDE to mix C and assembly modules. I have implemented, also a linker, named wlink32 and a RC compiler, but I have upload only wlink32 for now. Have a look there: http://www.manoscoder.gr/w32cc/viewtopic.php?f=12&t=24 Thank you, Manos. |
|||
22 Nov 2016, 13:37 |
|
revolution 22 Nov 2016, 13:38
Align is not a macro in fasm.
|
|||
22 Nov 2016, 13:38 |
|
Manos 22 Nov 2016, 13:40
OK.
I 'll test this later. Manos. |
|||
22 Nov 2016, 13:40 |
|
revolution 22 Nov 2016, 13:40
Oh wait. $-$$ gives you the offset. I think that $$-$ is what you wanted, the negative offset.
|
|||
22 Nov 2016, 13:40 |
|
Manos 22 Nov 2016, 13:50
revolution wrote: Oh wait. $-$$ gives you the offset. I think that $$-$ is what you wanted, the negative offset. The first worked fine. I 'll test for the $$-$ Manos. |
|||
22 Nov 2016, 13:50 |
|
revolution 22 Nov 2016, 14:05
Manos wrote:
|
|||
22 Nov 2016, 14:05 |
|
Manos 22 Nov 2016, 14:13
revolution wrote:
Yes, you are right. I tested the: $$-$ and it works OK also. Finally, I 'll use the: $$-$ Thank you again. P.S. Did you download my wlink32 ? Manos. |
|||
22 Nov 2016, 14:13 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.