flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > @F. A bug or not a bug?

Author
Thread Post new topic Reply to topic
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 19 May 2011, 23:40
May be it's just too late for my undersleeping exhausted brain, because the following example is too simple to remain unnoticed for so long. So I'm just throwing it in, and please someone tell me, I'm mistaken
Code:
jmp @F

if defined @B
        display 'defined',13,10
end if

@@:    

This piece of code produces "error: undefined symbol" on the instruction "jmp @F". Am I wrong expecting this code to be compiled faultless?
Best regards.
Post 19 May 2011, 23:40
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 20 May 2011, 02:13
Just to add, FASM 1.64 faults at "if defined @B" with "Error: invalid value" message.

On FASM 1.69.31 I get the same error as reported, except for "if defined @F" which makes the code compile fine.
Post 20 May 2011, 02:13
View user's profile Send private message Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 21 May 2011, 10:41
Well... if none (including well slept me) disagrees, then I'd like to show another occurrence of probably same bug. Compiling the following code
Code:
jmp @FFF

if defined @FF
  display '@FF defined',13,10
       label @FFF at @FF
end if
if defined @F
        display '@F defined',13,10
        label @FF at @F
end if

@@:    

produces the following output:
Code:
@FF defined
@F defined
C:\test.asm [1]:
jmp @FFF
error: undefined symbol '@FFF'.    

, which is weird, because if "@FF defined", then @FFF must also be defined.
Does fasm forget to make one more pass to resolve the label?
Post 21 May 2011, 10:41
View user's profile Send private message Reply with quote
idle



Joined: 06 Jan 2011
Posts: 440
Location: Ukraine
idle 22 May 2011, 17:18
so, does every label definition require a new pass?
won't the chaining suspend fasm in real situations: jmps, ands, ors, xors etc adds, subs, etc?

Code:
jmp i_have_a_car_and_the_car_is_mine:

if the_car_is_mine:
    i_have_a_car_and_the_car_is_mine:
end if

if i_have_a_car:
    the_car_is_mine:
end if

i_have_a_car:
    
Post 22 May 2011, 17:18
View user's profile Send private message Reply with quote
idle



Joined: 06 Jan 2011
Posts: 440
Location: Ukraine
idle 22 May 2011, 17:38
old expert systems such as TProlog or Guru would do:

;well, mark unresolved#1 and continue
jmp i_have_a_car_and_the_car_is_mine:

;mark unresolved#2 and continue
if the_car_is_mine:

;mark unresolved#3 and continue
if i_have_a_car:

;fix knowledge base
i_have_a_car:

;go last unresolved i.e. #3
Post 22 May 2011, 17:38
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 15 Sep 2011, 21:23
Both the bugs are fixed in 1.69.33.
Post 15 Sep 2011, 21:23
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 16 Sep 2011, 11:48
Tomasz Grysztar
Thank you very much! Smile Now it's possible to do the following kind of nasty things.
Code:
macro def@@ ..@F
{
  macro @@ [args]
     \{
            \common \local ..@BB, ..@FF, matched, remainder
           
            define matched -
            match : rem, args
               \\{
                  restore matched
                     define matched +
            \\}
          match :, args
           \\{
                  restore matched
                     define matched +
            \\}
          match +, matched
            \\{
                  restore @BB
                 @BB equ ..@BB

                   if defined @B
                               label ..@BB at @B
                   end if
                      
                    purge @@
                    @@:
                     
                    restore @FF
                 @FF equ ..@FF
                       def@@ ..@FF
                         
                    if defined @F
                               label ..@F at @F
                    end if

                  match : rem, args \\\{ remainder equ rem \\\}
                   match :, args \\\{ remainder equ \\\}
                   remainder
                   restore remainder
           \\}
          restore matched
     \}
}
match any,any
{
       local ..@FF
 restore @FF
 @FF equ ..@FF
       def@@ ..@FF
}    

There were some humble requests for this feature, but as far as I understood, there had been no working solutions provided.
Usage example:
Code:
@@: jmp @FF
@@: jmp @B
@@: jmp @BB
jmp @BB
jmp @B    


Kind regards

P.S. It seems to work with previous versions either. I was so badly waiting for this update. Sad
Post 16 Sep 2011, 11:48
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.