flat assembler
Message board for the users of flat assembler.

Index > Main > offset differences fasm1 and fasm2

Author
Thread Post new topic Reply to topic
anotherone



Joined: 18 Jun 2026
Posts: 2
anotherone 28 Jun 2026, 18:13
Hello,

I'm new to fasm and while finding out if I should develop with fasm1 or 2 I found a vital difference. I have to say that I'm working under Linux with the latest available versions. I also use the includes from the Windows package (with converted lowercase filenames) with the Linux version.
The minimal working examples for both assemblers, the only difference being the struc curly braces vs 'end struc':

Code:
; fasm1 example
use64

include 'win64w.inc'

    mov rcx, [rcx + SOMETHING.Second]
    retn

struc int32 {
    align 4
    . dd ?
}

struc int64 {
    align 8
    . dq ?
}

struct SOMETHING
    First     int32
    Second    int64
ends
    


Code:
;fasm2 example
use64

include 'win64w.inc'

    mov rcx, [rcx + SOMETHING.Second]
    retn

struc int32
    align 4
    . dd ?
end struc

struc int64
    align 8
    . dq ?
end struc

struct SOMETHING
    First     int32
    Second    int64
ends
    


The disassemblies show a difference in alignment of struct members:

Code:
ndisasm fasm1.bin
00000000  48                dec ax
00000001  8B4904            mov cx,[bx+di+0x4]
00000004  C3                ret
ndisasm fasm2.bin
00000000  48                dec ax
00000001  8B4908            mov cx,[bx+di+0x8]
00000004  C3                ret
    


What am I doing wrong here or is this a bug?
Post 28 Jun 2026, 18:13
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8543
Location: Kraków, Poland
Tomasz Grysztar 29 Jun 2026, 03:53
The implementation of "struct" macro that comes with classic headers for fasm 1 supports only a limited set of data directives (you can see it when look at its definition in macro/struct.inc), and "align" is not a supported statement (there now exists a third-party implementation that expands it, though).

On the other hand, fasm2 uses a more capable CALM-based implementation that integrates all kinds of statements.
Post 29 Jun 2026, 03:53
View user's profile Send private message Visit poster's website Reply with quote
Jessé



Joined: 03 May 2025
Posts: 128
Location: Brazil
Jessé 29 Jun 2026, 16:15
I'm a bit biased to talk about, but I should recommend you focus on 'fasm2' (for x86-64), because, it does all stuff fasm1 already does, and as an added bonus, you have - with fasm2 - a very, very powerful preprocessor language, flexible enough to do almost anything, including defining an assembler for other architectures (fasmg, the base of fasm2 assembler is essentialy this, an assembly engine). Everything on fasm2 (including instructions) is defined in its headers, which are basically headers written in fasmg language.

In my personal experience, fasm1 has speed - as also stated by Tomasz - as its advantage factor. They seem to be - considering only pure x86-64 assembly - almost equal. Have that in mind. They mostly differ in their preprocessor language, which fasm2 ("backended" by fasmg) even having two native languages that can complement the standard assembly language in a very useful way, which are the common directives and also CALM instructions. I'm saying that because I found some limitations when trying to do some things with fasm1 preprocessor language. Almost none on fasm2.

I must mention that I experiment very little with fasm1 preprocessor language, so, my thoughts about it may be inaccurate.
Post 29 Jun 2026, 16:15
View user's profile Send private message Visit poster's website 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 © 1999-2026, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.