flat assembler
Message board for the users of flat assembler.

Index > Windows > [fasmg] Problem creating a MS COFF

Author
Thread Post new topic Reply to topic
alorent



Joined: 05 Dec 2005
Posts: 205
alorent 30 Nov 2022, 05:55
Hi,

I'm moving from FASM to FASMG but I have a problem creating a COFF .obj file.

I'm still learning about all the possible "include" files to include in fasmg, but I'm a bit confused yet.

This is my code to create a simple "MS COFF" OBJ:

Code:
include 'format/format.inc'

format MS COFF

include 'win32ax.inc'

public MyFunction as '_Myfunction@4'

.code 

MyFunction proc param1
    
    mov eax, [param1]
    ret 

MyFunction endp
    


But I get the following error:


Code:
macro format?.MS? [3]:
        COFF.Settings.Characteristics = IMAGE_FILE_32BIT_MACHINE or IMAGE_FILE_LINE_NUMS_STRIPPED or IMAGE_FILE_BYTES_REVERSED_LO
Processed: COFF.Settings.Characteristics = IMAGE_FILE_32BIT_MACHINE or IMAGE_FILE_LINE_NUMS_STRIPPED or IMAGE_FILE_BYTES_REVERSED_LO

Error: symbol 'IMAGE_FILE_32BIT_MACHINE' is undefined or out of scope.
    


I have played a lot with it, but no luck yet. I guess that I'm putting "format" and include lines in the wrong order or duplicated?

Thanks!
Post 30 Nov 2022, 05:55
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8103
Location: Kraków, Poland
Tomasz Grysztar 30 Nov 2022, 07:00
WIN32AX.INC was designed to work with PE output, and I forgot to consider that it may have worked with other formats. Both fasm's and fasmg's version automatically set up PE format unless it was already selected, but they do so in different ways, hence incompatibility.

The version for fasm was doing this:
Code:
virtual at 0
 xchg eax,eax
 detected_16bit = $-1
end virtual

if detected_16bit
 format PE GUI 4.0
end if    
Detecting a default "use16" setting and in such case setting up default PE output. This worked with COFF as well, because selecting COFF was also switching to "use32" code.

In case of fasmg this logic would not work, because there might not be instruction set at all in the beginning, so it might not be possible to determine the mode in such way. That's why fasmg's version simply checks whether PE format has been set up already:
Code:
if ~ definite PE
        format PE GUI 4.0
end if    
I should go back to this and consider some changes, perhaps it could also check for presence of x86 instruction set:
Code:
if ~ definite PE & ~ definite x86.mode
        format PE GUI 4.0
end if    
Post 30 Nov 2022, 07:00
View user's profile Send private message Visit poster's website Reply with quote
alorent



Joined: 05 Dec 2005
Posts: 205
alorent 30 Nov 2022, 08:14
Thanks Tomasz!

You are right, that line causes the problem.

I have removed that code from WIN32AX.INC and not it assembles correctly.

Thanks again
Post 30 Nov 2022, 08:14
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-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.