Posts: 1,766
Threads: 55
Joined: Aug 2019
Reputation:
24
This version fix -O3 bug related to bit-rotation routines (mostly used in graphics and scroll routines).
Download here: <!-- m --><a class="postlink" href="http://www.boriel.com/files/zxb/zxbasic-1.2.5r1513c.msi">http://www.boriel.com/files/zxb/zxbasic-1.2.5r1513c.msi</a><!-- m -->
If you previously experienced any problem with -O3, you should try now with this new release.
Also, for people wanting to send me some test code: you may also send me the code in a private message attachment (e.g. you have a game you don't want others to see before it's finished, or even a commercial game, etc...)
Posts: 805
Threads: 135
Joined: Apr 2009
Reputation:
5
With this update, the 42 character printing seems to work now (I'm using the original version at this point); but the graphics banner does not work at all. It looks the same as the previous version.
What's a very pretty FA League banner with no optimization is a little garbage and mostly blank, though the attribute section works fine!
Incidentally, I had to uninstall before it would let me reinstall, again.
Posts: 1,766
Threads: 55
Joined: Aug 2019
Reputation:
24
britlion Wrote:With this update, the 42 character printing seems to work now (I'm using the original version at this point); but the graphics banner does not work at all. It looks the same as the previous version. The final version is identical, except by the FASTCALL tag and a mention to you (by the way, if you have a web page or something, tell me).
britlion Wrote:What's a very pretty FA League banner with no optimization is a little garbage and mostly blank, though the attribute section works fine! If possible, send me a *private* message, attaching a ZIP file with the failing code, so I can debug it.
Posts: 805
Threads: 135
Joined: Apr 2009
Reputation:
5
Posts: 1,766
Threads: 55
Joined: Aug 2019
Reputation:
24
Well, finally fixed :wink:
Please, download ZX Basic v.1.2.5-r1513d: <!-- m --><a class="postlink" href="http://www.boriel.com/files/zxb/zxbasic-1.2.5r1513d.msi">http://www.boriel.com/files/zxb/zxbasic-1.2.5r1513d.msi</a><!-- m -->
and look for more bugs (I'm exhausted :!: )
Posts: 805
Threads: 135
Joined: Apr 2009
Reputation:
5
I bet you are. Well done!
Can you say what the bug was?
Posts: 1,766
Threads: 55
Joined: Aug 2019
Reputation:
24
Ok, I will try: in function calls, local variables and parameters are mostly managed using (ix+n) indirections. So, when doing var = var + 1, the compiler will emmit this code (if var is declared as Ubyte/Byte):
Code: ld a, (ix + n)
add a, 1
ld (ix + n), a
The compiler does successive optimizations. The first one is obvious. ADD A, 1 ==> INC A
Code: ld a, (ix + n)
inc a
ld (ix + n), a
The 2nd one is less obvious: This block can be replaced by
... but only if A register is not used later; this is the hard part for the compiler, because "later" is something we must define.
The problem is the latter condition was not being checked, so A register was not being preserved when it was required.
Posts: 805
Threads: 135
Joined: Apr 2009
Reputation:
5
Ah ha! Clever stuff.
This is all leaning towards my conviction that ZX Basic will utterly out awesome any of the older compilers, by virtue of having LOTS of memory and cpu time to do such optimizations...
That said... I have a fast computer. Why does Footy take 3 minutes to compile?? It seems a long time to make 14K of code...
Am I wrong to worry that it takes so long?
The biggest issue is that line numbers can't be trusted (there's a problem with asm blocks and getting the line number right. There really is.), and error messages are... not so helpful. "Unexpected end of file" tells me there's an unclosed bracket, or a missed END IF or END SUB out there.... but no clue where it could be. As a result, coding starts to get slower, because I can't write more than about 3 lines of code without recompiling, in case there's a problem - I need to know where. If I only wrote a tiny amount of code, it must be there.
I forgot to say - even though it takes 3 minutes - it compiles PERFECTLY with -O3!!! WOOOO! Very very well done, Boriel.
Posts: 1,766
Threads: 55
Joined: Aug 2019
Reputation:
24
britlion Wrote:Ah ha! Clever stuff.
This is all leaning towards my conviction that ZX Basic will utterly out awesome any of the older compilers, by virtue of having LOTS of memory and cpu time to do such optimizations...
That said... I have a fast computer. Why does Footy take 3 minutes to compile?? It seems a long time to make 14K of code...
Am I wrong to worry that it takes so long? To be honest, I was also surprised the time it takes to compile in my machine: I have a 8Gb quad Core computer, and psyco installed (a python accelerator, to use JIT compilation whenever possible). It also took near 2 minutes. After tracing the problem, I found out it was not the compiler stage which was lasting so long, but the *assembling* one. That is: It's the assembler which is taking most of the time. I will check it later.
Commenting out most of your main file except the printlogo( ) call, resulted in a fast compilation. I guess the problem with slow compilation is related to your main .BAS module. A first workaround could be to compile all your defs in a single separate asm file (not .bas), with zxbasm file.asm and then use incbin to include the binary data in a single step so you needn't to recompile the defb more than once.
Posts: 805
Threads: 135
Joined: Apr 2009
Reputation:
5
boriel Wrote:To be honest, I was also surprised the time it takes to compile in my machine: I have a 8Gb quad Core computer, and psyco installed (a python accelerator, to use JIT compilation whenever possible). It also took near 2 minutes. After tracing the problem, I found out it was not the compiler stage which was lasting so long, but the *assembling* one. That is: It's the assembler which is taking most of the time. I will check it later.
Commenting out most of your main file except the printlogo( ) call, resulted in a fast compilation. I guess the problem with slow compilation is related to your main .BAS module. A first workaround could be to compile all your defs in a single separate asm file (not .bas), with zxbasm file.asm and then use incbin to include the binary data in a single step so you needn't to recompile the defb more than once.
I have noted that I can make a .asm file very quickly indeed (that's a workaround for test builds).
Is the assembler documented somewhere? I didn't know incbin was actually a valid command.
That might help a lot for some things like graphics and audio, which I was working very hard to turn into DEFB statements...
Posts: 1,766
Threads: 55
Joined: Aug 2019
Reputation:
24
At this moment, there's no documentation about zxbasm.
I think DEFB can be optimized, maybe. Let me have a look...
Posts: 805
Threads: 135
Joined: Apr 2009
Reputation:
5
If you're having a look at the assembler, you might want to take a glance at the directives in
<!-- m --><a class="postlink" href="http://www.worldofspectrum.org/forums/showthread.php?t=27451">http://www.worldofspectrum.org/forums/s ... hp?t=27451</a><!-- m -->
Some of those features are rather nice. The ability to pad to the next 256 byte boundary had me salivating :-)
|