flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > [fasmg] How process undefined symbol?

Thread Post new topic Reply to topic

Joined: 07 May 2015
Posts: 1
Hi, i triyng to processate the next line of code:

Var a,b,c,d:DWORD    

But the symbols "a", "b", "c" and "d" are not defined in the code. When i try to compare a symbol:

if a eq ,
end if    

Fasm G shows me (for example) "symbol 'a' is undefined or out of scope". But my intention is define this symbol after, because i need use it in an expression.

I am new with this macro-proccessor and i dont known exactly how i need use it. This is my code until now...

macro print text*
        local s
        s = text
        display s,13,10
end macro

macro inc? symbol,step:1
        symbol = symbol + step
end macro

macro parse_var_line return,line&
        local buffer,last,needdatatype,varcount,item
        ;return.COUNT_MEMBER = return.COUNT_MEMBER or 0
        ;return.SCAN_MEMBER = return.COUNT_MEMBER
        last = 0
        needdatatype = 0
        varcount = 0
        define buffer line
        while 1
            ; Splits on tokens and put one in "item".
                match f rest,buffer
                        redefine item f
                        define buffer rest
                        match f,buffer
                                last = 1
                        end match
                end match
                ; To evade code duplication inside of "matchs", i write the "item" verification here.
                ; Item can't be comparated with anything, because is not defined.
                if item eq symbol
                        if needdatatype = 1
                                ;if item eq DWORD
                                ;       return.member#return.COUNT_MEMBER#.type = `DWORD
                                ;end if
                                repeat return.COUNT_MEMBER i:return.SCAN_MEMBER
                                        return.member#i#.type = `item
                                end repeat
                                needdatatype = 0
                                return.member#return.COUNT_MEMBER#.name = `item
                                inc varcount
                        end if
                else if item eq ,
                        inc return.COUNT_MEMBER
                else if item = @
                        return.member#return.COUNT_MEMBER#.ispointer = 1
                else if item = :
                        needdatatype = 1
                end if
                if last = 1
                end if
        end while
end macro

define G_VARS

macro var? line&
        parse_var_line G_VARS,line
end macro

; Code to process.
var a,b,c:DWORD

; Shows in console the number of members or "variables" defined.

; Shows variable names.
        print G_VARS.member#%#.name
end repeat    

Edit: I tried to use "defined", but the "item" symbol can be a (for example) comma (,) and this makes an error.

Sorry for my bad english. And thanks for your help.

Last edited by Yuki on 10 Aug 2019, 09:04; edited 1 time in total
Post 10 Aug 2019, 08:47
View user's profile Send private message Reply with quote
Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 7782
Location: Kraków, Poland
Tomasz Grysztar
In fasmg EQ can only be used to compare values of evaluated expressions. To compare text tokens you need MATCH. Please take a look at the "What are the means of parsing the arguments of an instruction?" section in the Introduction to fasmg.
Post 10 Aug 2019, 08:59
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.