Version 1.42 is ready. This update was unexpected even for me, because the idea of improvement came today (I'm not sure from where, maybe I was inspired by something like green ray from space, I don't remember exactly ;)) I'm attaching two sources, which show why previous algorithm wasn't perfect. First case is not properly optimized by 1.41 (compare output with this generated by 1.42), second causes 1.41 to run out of memory, altough there are no good reasons for that.
Posted on 2002-12-04 09:50:57 by Tomasz Grysztar
An uppdate, you said you fixed a "run out of memory"-error. I've experenced a few such when using fasmw (v1.41) (after lot's of compiling, running and coding for some hour), if the error still exist I'll make a bug-report. :)
I made a quick test and it works flawless. :)

green ray from space

Stryker, was it you? :eek:
Posted on 2002-12-04 11:01:15 by scientica
When you are working with large projects in fasmw, make sure you have enough setting of memory in compiler options, the default is 4 MB and might be not enough for big programs.
Posted on 2002-12-04 11:44:45 by Tomasz Grysztar
Once again Privalov: Excellent work! ;)
Posted on 2002-12-04 12:14:38 by POW
I've set it to 32 Mb (increased it from 16 megs, after I got the first out of memory).

A little question, how big is big? I'm not kidding, is big a 10 kb or 100kb .asm-file? The sorce file is (at the moment) 10,7 kb, and requires 3 passes.

POW, I agree with you. :alright:
Posted on 2002-12-04 13:07:53 by scientica
You can have very little source needing much memory if you use large allocations using "rb" directive (because every space that is declared as reserved is allocated and zeroed at compile time, it is then cut (if possible) at the formatting stage.
Posted on 2002-12-04 14:06:33 by Tomasz Grysztar
I have shocked myself. Look at this!
Posted on 2002-12-04 14:40:17 by Tomasz Grysztar
Nice optimizations... Here is the result :

C:\Programmation\PureBasic\Compilers>fasm PureBasicTest.asm test.exe
flat assembler version 1.41.2
36 passes, 0.8 seconds, 134905 bytes.

C:\Programmation\PureBasic\Compilers>fasm PureBasicTest.asm test.exe
flat assembler version 1.42
31 passes, 0.5 seconds, 134893 bytes.


Fred - AlphaSND
Posted on 2002-12-04 14:58:21 by AlphaSND
Amazing! Otlichnaya rabota!
Posted on 2002-12-04 16:58:53 by comrade
Privet comrade.. did you read my PM?
Posted on 2002-12-04 17:50:15 by Maverick
little fun Privalov:

plz enter this series segregs.

cs ds es ss fs gs

Hey!, it allowed me to assemble :grin:
Posted on 2002-12-05 03:34:14 by Bi_Dark
I keep reading about "passes" all the time. What is it?
Posted on 2002-12-05 03:39:08 by Delight
In each pass assembler converts the source into machine code, instruction after instruction. The single pass is not enough if you do any of so called "forward references", that is when you use some label that is not yet defined, for example:

jmp finish
; some other code

When assembler encounters "jmp finish" instruction in the first pass, the address of "finish" is not yet known, therefore instruction cannot be correctly generated. So it's assembled with some temporarily assumed value for that address, and the second pass is needed. In the second pass assembler already knows all the addresses and this time code is filled with correct values. At this stage assembly process ends in the two-pass assemblers, that don't have size optimization features (NASM, for example). But FASM always tries to generate as small instructions as possible, and the size of instruction mainly depends on the immediate values (like "finish" address in the above example). If "finish" label is not too far from the "jmp finish" instruction, the short (2 bytes) form of this instruction can be generated, otherwise some longer form has to be used. Because FASM tries to generate smallest possible code, in the first pass generates shortest form of instructions, but in the second pass it may realize that "finish" label is too far and the instruction has to be changed into longer form. But in this case also the address of "finish" label (and all other labels after that instruction) will change! So FASM does the third pass also, and even more if some addresses have changed once again.
Posted on 2002-12-05 04:04:24 by Tomasz Grysztar
Thanks for your explanation Privalov, it's all clear to me now :alright:
Posted on 2002-12-05 04:20:37 by Delight