flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > fasm macro bug?

Author
Thread Post new topic Reply to topic
lazer1



Joined: 24 Jan 2006
Posts: 185
lazer1 26 Jan 2006, 16:52
Hi,

after many hours trying to locate a bug, I think
the bug is in fasm's macros, Confused

if you compile bug1.asm and run it,

it wrongly echoes 'b' Sad

but if you change

rx__ equ ax

to

rx__ equ bx

it now correctly echoes 'a' Razz

I think this is a bug because if you study the code
you will see the read__ macro ignores rx__ as
rx__ is only used if an argument is non register,

so changing rx__ shouldnt change anything in this example,

or have I misunderstood something? Rolling Eyes


Description:
Download
Filename: bug2.asm
Filesize: 551 Bytes
Downloaded: 568 Time(s)

Post 26 Jan 2006, 16:52
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 26 Jan 2006, 17:10
You should define "registers__" this way:
Code:
registers__ equ ax,bx,cx,dx,cs,ds,es,fs,gs,ss,si,di    

or, even better, using "define".
The macroinstructions are like instruction mnemonics, they are recognized only when in beginning of the line (not counting the initial colon-followed labels). Each macroinstruction with its parameters spans the entire line and generates the full lines as its result - it cannot be used like symbolic constants.
Post 26 Jan 2006, 17:10
View user's profile Send private message Visit poster's website Reply with quote
lazer1



Joined: 24 Jan 2006
Posts: 185
lazer1 26 Jan 2006, 17:41
ok,

I tried that and it functioned, Razz

I have to look at the other macros I'm using. Shocked

can you make fasm give an error message for
the wrong usage I tried? Cool


(the example I uploaded shouldnt have had the
"include fasm.i", so delete that Confused )
Post 26 Jan 2006, 17:41
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 26 Jan 2006, 17:53
It's not really the wrong usage, you can have both the "registers__" macro and "registers__" symbolic constant at the same time, so assembler is not able to tell whether it was what you intended or not.
Post 26 Jan 2006, 17:53
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 26 Jan 2006, 19:26
yeah, but defining "registers__" after a macro via equ is not possible because macroinstruction is processed before equ.. you have to use define:

Code:
define registers__ ax,bx,cx,dx,cs,ds,es,fs,gs,ss,si,di    

and when you use restore it goes back to macroinstruction. Wink
Post 26 Jan 2006, 19:26
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.