flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > []

Author
Thread Post new topic Reply to topic
Spool



Joined: 08 Jan 2013
Posts: 151
Spool 27 Jan 2013, 05:00
[ Post removed by author. ]


Last edited by Spool on 17 Mar 2013, 04:33; edited 1 time in total
Post 27 Jan 2013, 05:00
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 27 Jan 2013, 07:10
Pass is one processing of the preprocessed source code from the start to the end. FASM makes multiply passes in order to resolve all forward references. Better read the FASM manual for the details.
Post 27 Jan 2013, 07:10
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Spool



Joined: 08 Jan 2013
Posts: 151
Spool 27 Jan 2013, 08:38
[ Post removed by author. ]


Last edited by Spool on 17 Mar 2013, 04:36; edited 1 time in total
Post 27 Jan 2013, 08:38
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 27 Jan 2013, 09:03
The number of passes can not be easy determined in advance. All the more, that in the different versions of FASM this count can be different.
Here is simple example that compiles for 3 passes, but it is empirically created:
Code:
        jmp     lbl1

        if (lbl1<100) & (flag=0)
         rb 100
        end if

        flag = 1

lbl1:    
Post 27 Jan 2013, 09:03
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 27 Jan 2013, 09:22
Spool,

Make more forward references.
Code:
VAR equ 1       ; value for last assignment
rept 10 {
forward
  local var     ; generate unique symbol
  VAR equ var   ; push it on «equ» stack
reverse
  restore VAR   ; drop current symbol to acquire previous
  var = VAR     ; make current dependent on previous
}    
Essentially it makes dependency chain like var9 = var8; var8 = var7; ... var1 = var0; var0 = 1;. Each pass forwards predicted value up the chain until all constants have correctly predicted values. Beware though that for default predicted value of 0 it takes only two passes to have solution (one to assign and another to check).

Is that swaps macroinstruction a replacement for trivial xchg instruction?
Post 27 Jan 2013, 09:22
View user's profile Send private message Reply with quote
Spool



Joined: 08 Jan 2013
Posts: 151
Spool 27 Jan 2013, 09:41
[ Post removed by author. ]


Last edited by Spool on 17 Mar 2013, 04:36; edited 1 time in total
Post 27 Jan 2013, 09:41
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 27 Jan 2013, 10:15
Spool,

Try VAR equ 0 for some surprise. Wink
Post 27 Jan 2013, 10:15
View user's profile Send private message Reply with quote
Spool



Joined: 08 Jan 2013
Posts: 151
Spool 27 Jan 2013, 11:30
[ Post removed by author. ]


Last edited by Spool on 17 Mar 2013, 04:37; edited 1 time in total
Post 27 Jan 2013, 11:30
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 27 Jan 2013, 14:10
Spool,

I didn't mean VAR equ 0 alone. What I really meant was
Code:
rept 1'000'000 i {
reverse
  rept 1 j:i-1 \{ var#i = var\#j \}
}
var0 = 0    
Result:
Code:
flat assembler  version 1.71.07  (500000 kilobytes memory)
2 passes, 11.3 seconds, 0 bytes.    
I had to rewrite example so it wouldn't require enormous amount of time to compile (original example took ~100 seconds for 100k vars). Evidently it wouldn't compile with var0 = 1.
Post 27 Jan 2013, 14:10
View user's profile Send private message Reply with quote
Spool



Joined: 08 Jan 2013
Posts: 151
Spool 27 Jan 2013, 22:43
[ Post removed by author. ]


Last edited by Spool on 17 Mar 2013, 04:37; edited 1 time in total
Post 27 Jan 2013, 22:43
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 27 Jan 2013, 23:00
Spool,

Those examples do not generate output, they're just causing compiler to do particular number of passes.
Code:
rept 100 i {
reverse
  rept 1 j:i-1 \{ var#i = var\#j \}
}
var0 = 1    
Compilation:
Code:
>fasm multipass.fasm
flat assembler  version 1.71.07  (1890955 kilobytes memory)
error: code cannot be generated.

>fasm multipass.fasm -p 101
flat assembler  version 1.71.07  (1886339 kilobytes memory)
101 passes, 0 bytes.    
Post 27 Jan 2013, 23:00
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.