flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Unrecoverable label redifinition and numeric variable forwar

Author
Thread Post new topic Reply to topic
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 01 Apr 2012, 00:09
Good day. Would it be a good idea to make label redefinition and numeric variables forward referencing to be recoverable errors, so that fasm is able to compile the following code samples?
Code:
display x,13,10
if ~ defined y
        x = 'a'
end if
label y
x = 'b'    

Code:
if ~ defined y
        label x
end if
label x
label y    

IMHO this should not break anything, but would allow fasm to solve a wider range of problems.
Post 01 Apr 2012, 00:09
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 01 Apr 2012, 09:17
It might be possible in theory, but it wouldn't go well with fasm's implementation. It would have incomplete track of some of the values and it would no longer be able to guarantee the correctness of generated solution.
Post 01 Apr 2012, 09:17
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 01 Apr 2012, 11:06
Tomasz Grysztar
Could you provide an example of what exactly would be tracked incompletely? Because I see no crucial difference between the subject and e.g. rb -1.
Post 01 Apr 2012, 11:06
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 01 Apr 2012, 13:23
l_inc wrote:
Because I see no crucial difference between the subject and e.g. rb -1.
Tracking of label values is what the fasm's resolving algorithm relies on, and this is that crucial difference.

However, I think I found out a possible way to get this working correctly. I'm trying to make a formal proof - if I succeed in proving its correctness, I will implement such improvement.
Post 01 Apr 2012, 13:23
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 01 Apr 2012, 13:37
BTW, "out of scope" has always been recoverable, for example this resolved without error:
Code:
if ~ defined y
  dd a
end if
a = 1
a = 3
label y    
You were deceived by the fact that currently after fasm sees numerical constant redefined once, it never allows it to be forward referenced, even in future passes - but this is a separate problem.
Post 01 Apr 2012, 13:37
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 01 Apr 2012, 13:47
Tomasz Grysztar
Quote:
Tracking of label values is what the fasm's resolving algorithm relies on, and this is that crucial difference.

Label values are not constant between the passes. Thus forward referencing a label or numeric constant, that changes it's value after it has already been used, seems to be equivalent to forward referencing a numeric constant, that later becomes a numeric variable. So the final decision about the error can be made the same way after the numeric variability has been stabilized.

And label redefinition seems to be equivalent to a numeric constant becoming a numeric variable.

Quote:
You were deceived by the fact that currently after fasm sees numerical constant redefined once, it never allows it to be forward referenced

Well, I never talked about the "out of scope" error as such. I talked about the numeric variable forward referencing. However in this case it's more reasonable to talk about unrecoverable state than about an unrecoverable error.

P.S.
Quote:
I'm trying to make a formal proof

Cool. Smile It's good know, fasm is partially based on formal correctness proofs.
Post 01 Apr 2012, 13:47
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 01 Apr 2012, 14:48
Well, it not go well, as I was afraid it would. After I ensured correctness, fasm started to go into infinite loops ("code cannot be generated") instead of signalizing simple errors.
Post 01 Apr 2012, 14:48
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 01 Apr 2012, 14:59
Tomasz Grysztar
A negative result is also a result. Thank you for the attempt.

P.S. I'd probably try it by myself, but this requires deep understanding of fasm sources which lays beyond my abilities.
Post 01 Apr 2012, 14:59
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.