flat assembler
Message board for the users of flat assembler.

flat assembler > Windows > Changing from MASM to FASM

Thread Post new topic Reply to topic

Joined: 06 Dec 2003
Posts: 5
Are there any tutorials for those experienced with MASM who are interested in using FASM? I found a few tutorials on this site however they explained the basics of assembly language rather than delving into where FASM differs from MASM in its usage and syntax.

To get myself acquainted I had a play around with a simple MessageBox example this afternoon. I wanted to use the commandline Win32 version of FASM as its easier to integrate this with my editor than the Windowed version (which appears to have a different syntax for its import section). I originally started with the following:
format PE GUI 4.0 include '%fasminc%/windows.inc' section '.data' data readable writeable MsgCaption db "Iczelion's tutorial no.2",0 MsgBoxText db "Win32 Assembly is Great!",0 section '.code' code readable executable entry start start: push MB_OK push MsgCaption push MsgBoxText push 0 call [MessageBox] push 0 call [ExitProcess] section '.idata' import data readable writeable dd 0,0,0,RVA kernel_name,RVA kernel_table dd 0,0,0,RVA user_name,RVA user_table dd 0,0,0,0,0 kernel_table: ExitProcess dd RVA _ExitProcess dd 0 user_table: MessageBox dd RVA _MessageBoxA dd 0 kernel_name db 'KERNEL32.DLL',0 user_name db 'USER32.DLL',0 _ExitProcess dw 0 db 'ExitProcess',0 _MessageBoxA dw 0 db 'MessageBoxA',0 section '.reloc' fixups data readable discardable

I added a simple macro that would work in a similar fashion to the MASM Invoke directive. So, after the 'include' line above I entered:
macro invoke proc, [arg] { reverse push arg common call [proc] }

I then changed the push... call ... instructions to:
invoke MessageBox, NULL, .... (etc.).

However one thing had me scratching my head. This was the syntax of the import data section. RVA is obviously an acronym for Relative Virtual Address. It appears to me that this section creates some kind of lookup table for the procedure names used in the code. Could someone elaborate further? I have a few references on the PE file format, but would like to understand in depth how this section works.


Last edited by andrewk on 20 Jan 2004, 22:24; edited 1 time in total
Post 20 Jan 2004, 03:58
View user's profile Send private message Reply with quote

Joined: 16 Jun 2003
Posts: 1114
Location: Russian Federation
invoke macro is already defined, see includes

comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 20 Jan 2004, 04:26
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar
Assembly Artist

Joined: 16 Jun 2003
Posts: 6876
Location: Kraków, Poland
There are no differences in syntax between different fasm releases (DOS/Win32 console/Win32 GUI/Linux), every version will process every your source in the same way, giving you the same output. There are only a bit different sets of examples coming with each release - with Win32 console version you've got some low-level PE coding examples, while with Win32 GUI version you've got the macro-driven simplified Win32 programming examples. So to see how the "invoke", "import" and similar macros are used, see the examples that are included in the Win32 GUI release.
Post 20 Jan 2004, 06:18
View user's profile Send private message Visit poster's website Reply with quote

Joined: 06 Dec 2003
Posts: 5
Thanks for your replies. I had a quick re-read of the PE file format information I had and discovered the format of the idata section maps exactly to its representation in the PE file format. This is actually very cool. Privalov, the more I play around with FASM the more I like it - thanks for such a great piece of software.
Post 20 Jan 2004, 22:48
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  

< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum

Copyright © 2004-2018, Tomasz Grysztar.

Powered by rwasa.