flat assembler
Message board for the users of flat assembler.
Index
> Main > Bug in fasm 1.50? 
Author 

Tomasz Grysztar
During the first pass fasm doesn't know yet that you are going to use the "temp1" label, so that "if" block is skipped and the second one is processed, as the "VAR" is still not defined. After that the second block is always processed, even when first block is processed in the later passes, when fasm correctly predicts that "temp1" label will be used (the prediction mechanism is based on the history of the usage in the previous pass, if at the end of pass assembler detects that there was some misprediction, it does that pass again).


10 Dec 2003, 21:17 

Joshua
I think i understand this, but it doesn't feel logical, and i feel i shouldn't need to know the inner workings of the assembler to know what code will be generated...
Perhaps you have a solution for this problem? 

10 Dec 2003, 21:25 

Tomasz Grysztar
How would you interprete the expected result of such code:
Code: if alpha*alpha=alpha if ~ alpha alpha = 1 else alpha = beta+1 end if else alpha = alpha+1 end if if alpha beta=alpha1 end if without knowing the inner workings of assembler? I had to keep all such things in mind while designing fasm's multipass algorithms. There is no any universal logic that would be applied to sources when the "if"blocks can affect themselves; this is the similar problem to the classic antinomies of logic, which occur when you use some formulation talking about itself, like "the clause you are reading is false", etc. 

10 Dec 2003, 21:43 

Tomasz Grysztar
BTW, here is a small example how you can utilize fasm's multipass features even to solve equations
Code: macro solve equation_in_x,result { R equ result local t,X x equ X if ~ defined t t = 0 else x = t if ~ equation_in_x x = x+1 end if t = x end if R = t restore x,R } solve x*x*x31*x*x+311*x1001=0 ,t display '0'+t This example finds the smallest positive integer solution of the equation x^331x^2+311x1001=0 and displays the result (one digit number). That is not an example of serious programming, it's just a little bit of fun with playing with fasm's abilities. 

10 Dec 2003, 22:10 

comrade
Nice!


11 Dec 2003, 03:35 

scientica
w00t! (/jaw drops and hit the floor)
That is cool, I could't even imagine that fasm is this powerfull! _________________ ... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.  Bradley Kuhn 

11 Dec 2003, 05:43 

Tomasz Grysztar
This is not the best way to do it  I have written it as a demonstration how multipass resolving works. Similarly fasm can resolve such code:
Code: times x/2+4 nop x = $ If after some iterations it actually finds the value which is equal to its truncated half with four added (it's 7 in this case), it generates the code; otherwise it will stop at the limit of passes and say "code cannot be generated". In the previous solving example it would also search only up to the limit of passes. Much better would be singlepass method with manually set range, also the code is much cleaner and easier to understand in this case: Code: macro solve equation_in_x,result { x = RANGE_MIN repeat RANGE_MAXRANGE_MIN if ~ equation_in_x x = x + 1 end if end repeat if equation_in_x result = x end if } RANGE_MIN = 0 RANGE_MAX = 1000 solve x*x*x31*x*x+311*x1001=0 ,t display '0'+t 

11 Dec 2003, 09:03 

pelaillo
Amazing demonstration
You have shown a face of fasm that could open new scenarios. Amusing math contests. Sorry for Fermat, Gauss or Fourier. They haven't it (however, imagine what they could have done with it ) 

11 Dec 2003, 11:12 

Tommy
Impressive Privalov!


11 Dec 2003, 11:19 

< Last Thread  Next Thread > 
Forum Rules:

Copyright © 19992020, Tomasz Grysztar. Also on YouTube, Twitter.
Website powered by rwasa.