flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > fasmg distribution problems

Thread Post new topic Reply to topic

Joined: 24 Oct 2018
Posts: 17
I have just updated fasm and downloaded fasmg.jj14.zip from the official download page and found several problems with the distribution:

1. The files fasmg and fasmg.x64 are not executable. zip file format supports access permission, so if the package was made with correct options, then they would be executable after unpacking.

2. To make the executable files, I have tried to compile it with original fasm for linux x86_64. I have this error message. The file struct.inc isn't available neither from fasm, nor from fasmg distribution.
$ fasm fasmg.asm 
flat assembler  version 1.73.29  (16384 kilobytes memory, x64)
fasmg.asm [4]:
        include 'macro/struct.inc'
fasmg.asm [4] match [2]:
        include 'macro/struct.inc'
error: file not found.

3. While fasm package has a directory in its root, named fasm, the fasmg package doesn't have a directory in its root, so you'd need to use three commands when unpacking it, first make the directory with mkdir, cd to it and then unpack it with unzip, while regular fasm only needs one command to unpack it.

Though it would me more correct to name the directory fasm-1.73.29 instead of just fasm, so that unpacking it would not conflict with unpacking other fasm versions without manual renaming. Same goes to fasmg package.
Post 30 Dec 2021, 16:51
View user's profile Send private message Reply with quote
Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 7957
Location: Kraków, Poland
Tomasz Grysztar
al_Fazline wrote:
The file struct.inc isn't available neither from fasm, nor from fasmg distribution.
I'm adding a simplified struct.inc into the source tree. It is not intended for general use, it implements just bare minimum features needed to assemble fasmg.

As for the file permissions, ZIP files created with tools capable of including them cause compatibility problems with some of my uses (including, but not limited to, MS-DOS), so I'd prefer to keep the basic universal distribution as it is.

Update: Grom PE suggested how I can patch the ZIP file myself to add the Unix permissions without breaking compatibility. It seems to work, so I'm adding this to my build scripts:
@goto equ

        virtual at 0
                Entry                   db 'PK',1,2
                .VersionMadeBy          dw ?
                .VersionToExtract       dw ?
                .GeneralPurpose         dw ?
                .CompressionMethod      dw ?
                .FileTime               dw ?
                .FileDate               dw ?
                .Crc32Offset2           dd ?
                .CompressedSize         dd ?
                .UncompressedSize       dd ?
                .FileNameLength         dw ?
                .ExtraFieldLength       dw ?
                .CommentLength          dw ?
                .DiskNumber             dw ?
                .FileAttributes         dw ?
                .FileAttributesExt      dd ?
                .LocalHeaderOffset      dd ?
        end virtual

        file ZIPFILE

        offset = $ - 22

        while offset > 0
                load signature:8 from offset
                if signature = 'PK' + 5 shl 16 + 6 shl 24
                        load size:4 from offset + 12
                        tail = offset
                        offset = offset - size

                        while offset < tail
                                load signature:4 from offset
                                if signature <> 'PK' + 1 shl 16 + 2 shl 24
                                end if

                                load FileNameLength:2 from offset + Entry.FileNameLength
                                load ExtraFieldLength:2 from offset + Entry.ExtraFieldLength
                                load CommentLength:2 from offset + Entry.CommentLength

                                load FileName:FileNameLength from offset + Entry.FileName
                                if FileName eq 'fasmg' |\
                                   FileName eq 'fasmg.x64' |\
                                   FileName eq 'source/macos/fasmg' |\
                                   FileName eq 'source/macos/x64/fasmg'

                                        store 3:1 at offset + Entry.VersionMadeBy+1
                                        store 81EDh:2 at offset + Entry.FileAttributesExt+2

                                end if

                                offset = offset + Entry.FileName + FileNameLength + ExtraFieldLength + CommentLength
                        end while

                end if
                offset = offset - 1
        end while

        macro ?! line&
        end macro


@echo off
if not exist "%~1" goto info

fasmg "%~f0" "%~1" -i"ZIPFILE='%1'"

goto end


echo Please provide a name of ZIP file containing fasmg distribution.


As for the directory envelope - I know that people have various build/update scripts made around the existing structure, so I would need a really good reason to change it. Traditionally all the ZIP files I publish have files directly in the root, as this has always been my personal preference (going back to DOS days).
Post 30 Dec 2021, 21:21
View user's profile Send private message Visit poster's website Reply with quote

Joined: 24 Oct 2018
Posts: 17
Thanks for fixing the bug. I am not sure if I was supposed to create a new thread for that or not, since it's not about fasmg, but in fasm package, there is a file with incorrect encoding: fasm/examples/elfexe/hello64.asm
The most of file is actually ASCII, but this line:

; (thanks to Franti|�ek G|�bri|�)

I think the best solution would be transliterate the name into plain ASCII, but otherwise second best option would be to encode it as UTF-8, since it's the most common character encoding nowadays, so most text editors, viewers and browsers would open it in that encoding by default on every modern OS.

Also I was thinking, do you think that since fasm is supposed to work as cross-assembler (such as it could produce executables of any type from any type, do you think, it would make sense to have just one universal distribution instead of splitting fasm into multiple packages: Windows, Linux, DOS, libc? People using other operating systems might want to try and build executables for different systems out of example directories. The source should be the same, Linux users can read PDF file as easily as window's and so on. The only thing other platform users won't need would be binaries, but they are relatively small and rather easy to delete after unpacking, if needed.

I also think that DOS and Windows users could benefit from renaming all files to lower case, as, at least for me, they look better aesthetically and those systems are case-insensitive anyway so it shouldn't break compilation.

Also, Happy New Year!
Post 01 Jan 2022, 01:58
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 © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.