flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > pp/compiler equ bug

Author
Thread Post new topic Reply to topic
maurifull



Joined: 05 Sep 2004
Posts: 10
Location: Argentina
maurifull 05 Sep 2004, 18:12
Hi
Latest fasm has bug replacing symbolic constants, you can check it with this code:

Code:
MYDEF1 equ 2if MYDEF1 eq 1        display "MYDEF2=A",13,10    MYDEF2 equ 'A'else if MYDEF1 eq 2 display "MYDEF2=B",13,10    MYDEF2 equ 'B'else if MYDEF1 eq 3 display "MYDEF2=C",13,10    MYDEF2 equ 'C'end ifdisplay "Compiler says MYDEF=", MYDEF2,13,10    


As you can see, MYDEF1 is defined as 2, so fasm should output 'MYDEF=B' and 'Compiler says MYDEF=B', but see compiler output:

Quote:

flat assembler version 1.55
MYDEF2=B
Compiler says MYDEF=C
1 passes, 0 bytes.


So, it seems fasm inconditionally search last line defining a symbol, wherever that code is applicable or not.
Post 05 Sep 2004, 18:12
View user's profile Send private message Reply with quote
Dragontamer



Joined: 24 Aug 2003
Posts: 84
Dragontamer 05 Sep 2004, 19:05
Yes. That is true.
equ is ignored by if statements.

I think this is known already though.
Post 05 Sep 2004, 19:05
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8349
Location: Kraków, Poland
Tomasz Grysztar 05 Sep 2004, 19:35
Read the FAQ!!!

In FASM = symbol should be used for such purposes, EQU is more like a macro and works different way.
Post 05 Sep 2004, 19:35
View user's profile Send private message Visit poster's website Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 05 Sep 2004, 19:45
maurifull wrote:
Latest fasm has bug replacing symbolic constants


This worked before in previous FASM?

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 05 Sep 2004, 19:45
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
maurifull



Joined: 05 Sep 2004
Posts: 10
Location: Argentina
maurifull 05 Sep 2004, 20:15
Privalov wrote:
Read the FAQ!!!

In FASM = symbol should be used for such purposes, EQU is more like a macro and works different way.


Sorry, I'm very new to fasm, but isn't = symbol for numeric constants only?

I just posted an small sample, what I'm actually using is TARGET equ <one of DOS, Linux, Win32> and then conditionally defining other symbols & assembling code based on that define.

Sorry if it is a nonsense, I'll continue my fasm studying Wink
Post 05 Sep 2004, 20:15
View user's profile Send private message Reply with quote
maurifull



Joined: 05 Sep 2004
Posts: 10
Location: Argentina
maurifull 05 Sep 2004, 20:17
comrade wrote:
maurifull wrote:
Latest fasm has bug replacing symbolic constants


This worked before in previous FASM?


I don't know, stating 'last xxx project' is a report costume to inform one is using the latest version
Post 05 Sep 2004, 20:17
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8349
Location: Kraków, Poland
Tomasz Grysztar 05 Sep 2004, 20:23
maurifull wrote:
Sorry, I'm very new to fasm, but isn't = symbol for numeric constants only?

Yes, but your sample was also using numbers only.
Post 05 Sep 2004, 20:23
View user's profile Send private message Visit poster's website Reply with quote
maurifull



Joined: 05 Sep 2004
Posts: 10
Location: Argentina
maurifull 05 Sep 2004, 20:31
Privalov wrote:
maurifull wrote:
Sorry, I'm very new to fasm, but isn't = symbol for numeric constants only?

Yes, but your sample was also using numbers only.


I know, that's why I stated I use it another way

Here you have an example
Code:
if _PLATFORM_ eq Linux
   eol equ 10
else if _PLATFORM_ eq Win32 | _PLATFORM_ eq DOS
   eol equ 13,10
end if    


How can you make such definition by not using equ?
Post 05 Sep 2004, 20:31
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8349
Location: Kraków, Poland
Tomasz Grysztar 05 Sep 2004, 20:35
Yes, for such case conditional preprocessing is needed - I saw you have already found this thread.

PS. Use slashes, not backslashes, to end the BBCode tags - I was correcting it in your posts.
Post 05 Sep 2004, 20:35
View user's profile Send private message Visit poster's website Reply with quote
maurifull



Joined: 05 Sep 2004
Posts: 10
Location: Argentina
maurifull 05 Sep 2004, 20:40
Privalov wrote:
Yes, for such case conditional preprocessing is needed - I saw you have already found this thread.


Hehe, I'm going everywhere Wink
I'll take a new look.

Privalov wrote:
PS. Use slashes, not backslashes, to end the BBCode tags - I was correcting it in your posts.


Thanks, I noticed some things were not displaying right.
Post 05 Sep 2004, 20:40
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8349
Location: Kraków, Poland
Tomasz Grysztar 05 Sep 2004, 20:43
maurifull wrote:
Hehe, I'm going everywhere Wink

I commend it. Smile
Post 05 Sep 2004, 20:43
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.