03-14-2010, 11:02 AM
britlion Wrote:I was busy fixing -O3 up (I deeply rewrote some routines of the module). So I could only test this great program once I finished fixing it.boriel Wrote::o Wooow!
Don't know whether you use ZX BASIC to compile that. If you did, I guess -O3 won't work with this, as it won't probably understand IM2 routines, etc...
Again, astonishing!!!
I was wondering when you'd notice that little gem of fun.
britlion Wrote:Yes, it's ALL done with ZX Basic and as for -O3, I actually didn't, because I've been avoiding use of O3 etc - or was at that time; you want us to test it now :-)Ok, this is is something hard to do. I mean, if you use ORG XXXXX It will place the following code at that place, including the rest of the basic program.
It shouldn't make a difference, I think, because I sorta used a hammer to make it work. I used the routine listed above - which pokes the IM2 system into place the hard way. I couldn't find a way to let it allow me to put code where I wanted any other way.

- Capability to declare functions or sub at a given memory address, like when declaring a variable with DIM .. AT @.... Example:
Code:SUB MyInterrupt AT 0xFFE0h
[...]
END SUB - Capability to declare sub interrupts (this is already used in other compilers).
or more idiomaticCode:SUB INTERRUPT MyInterrupt : REM No parameters and no return. Must be a SUB
[...]
END SUB
Code:SUB Spritty AS INTERRUPT
[...]
END SUB
Britlion Wrote:Here's the actual whole program (and I know the IM2 bit isn't as efficient as it could be, it was a first pass, and hey, it worked):I also thought it was. Again, thank you!
britlion Wrote:[... code ... ]Nice to hear that.
O# Test: It does indeed compile without a hitch, and -O3 does indeed break it HARD!. At first it was because a lot of functions were not called; so I called them. Not quite sure what it's optimizing out that would break it now.
Anyway, that's how I did it; like I said sort of hammering it into place. But it definitely worked.
Ok

Having said that, I've thought some solutions:
- Put function calls at the end of the program, if you don't want them to be removed.
- The above does not prevent Variables to be removed, so if the ASM block write on basic variables,
this could lead to another problem. So we can tell the compiler which identifiers (Variables, SUBs, Functions) our ASM block requires:
or alikeCode:DIM MyVar1, MyVar2 as uInteger
SUB MyFunction
[...]
END SUB
ASM USES { MyFunction, MyVar1, MyVar2 }
[...]
call MyFunction
ld (MyVar1), hl
END ASM