flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Question about processing order fasmg

Author
Thread Post new topic Reply to topic
Jerry



Joined: 24 Dec 2016
Posts: 18
Location: Zeist, Netherlands
Jerry 28 Dec 2016, 11:27
Hello,

I think i don't understand the processing order regarding fasmg.
Using fasmg hll54, this source does not compile for me :

Code:
include 'format/format.inc'
format PE64 CONSOLE

macro library p&
        irp dll, p
                dd 0, 0, 0
                dd RVA dll#_name, RVA dll#_table
        end irp
        dd 0, 0, 0, 0, 0
end macro

macro import dll, p& ; import functions
        dll#_name db \     ; 'name.dll'
                `dll, '.DLL', 0
        dll#_table:        ; table

        irp name, p        ; import rvas
                if used name
                        name dq RVA _#name
                end if
        end irp
        dq 0

        irp name, p        ; import names
                if used name
                        _#name dw 0      ; ordinal=0
                        db `name, 0      ; 'name'
                end if
  end irp
end macro


entry start
section '.text' code readable executable
start:
        sub rsp, 7*8

        mov rcx, 0
        call [GetModuleHandleA]
        
        mov rcx, 0
        call [ExitProcess]

section '.idata' import data readable writeable
        library KERNEL32
        include 'kernel.inc'
        
        ;import KERNEL32, \
        ;       ExitProcess,\
        ;       GetModuleHandleA
    


The error i get is :

Code:
win64.asm [39]:
        call [GetModuleHandleA]
macro call [1] macro parse_jump_operand [11] macro parse_operand [27] macro parse_operand_value [21] macro parse_address [21]:
        ns.address = +addr
Processed: @dest.address = +GetModuleHandleA
Error: symbol 'GetModuleHandleA' is undefined or out of scope.
    


If i comment the line "'kernel.inc'" and uncomment the import lines, it does compile and produces a valid application.
The kernel.inc contains one long import statement with all the imports for KERNEL32.DLL, nothing more.
So the include statement gets processed later than i expected i guess ?

Thanks in advance.
Post 28 Dec 2016, 11:27
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 28 Dec 2016, 12:13
Can you attach your kernel.inc file so that we have a complete source to reproduce the problem?
Also, please try increasing the number of errors shown with the "-e" switch (like "-e100"), perhaps the real underlying error is somewhere else.
Post 28 Dec 2016, 12:13
View user's profile Send private message Visit poster's website Reply with quote
Jerry



Joined: 24 Dec 2016
Posts: 18
Location: Zeist, Netherlands
Jerry 28 Dec 2016, 13:04
Hello Tomasz,

I'm sorry, it was a really stupid mistake, i overlooked something simple.
After using the -e100 switch it showed me it could not find kernel.inc, that's correct because it is called kernel32.inc, after correcting that everything compiles just fine.
The confusion i had was that the short error tells me the cause is a unknown symbol whilst the entire file to include was missing.

Thank you for responding so quickly.

Regards.
Post 28 Dec 2016, 13:04
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 28 Dec 2016, 13:28
This is the reason why I implemented a multiple error collecting into fasmg. I originally chose to display only one error in fasm 1 (and fasmg does the same by default) to avoid "error avalanches" that happen when a single mistake causes tons of error in the rest of the source, burying the original error in a flood of messages. However, since forward-referencing is a central theme to fasm, it is not unusual that a mistake causes errors earlier in the source text and that the first error encountered is not the original error. The option to trace multiple errors is then very helpful.
Post 28 Dec 2016, 13:28
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.