flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Macroinstructions > Question about processing order fasmg

Author
Thread Post new topic Reply to topic
Jerry



Joined: 24 Dec 2016
Posts: 18
Location: Zeist, Netherlands
Question about processing order fasmg
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 dllp
                dd 000
                dd RVA dll#_nameRVA dll#_table
        end irp
        dd 00000
end macro

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

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

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


entry start
section '.text' code readable executable
start:
        sub rsp7*8

        mov rcx0
        call [GetModuleHandleA]
        
        mov rcx0
        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 [1macro parse_jump_operand [11macro parse_operand [27macro parse_operand_value [21macro parse_address [21]:
        ns.address = +addr
Processed@dest.address = +GetModuleHandleA
Errorsymbol '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
Assembly Artist


Joined: 16 Jun 2003
Posts: 6303
Location: Kraków, Poland
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
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
Assembly Artist


Joined: 16 Jun 2003
Posts: 6303
Location: Kraków, Poland
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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.