Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Interrupt Mode 2
#8
britlion Wrote:
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.
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.

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 :-)

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.
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.
Idea Idea: Why don't you put this in the wishlist (yes, it will take MUCH time, but not discarded)? For example:
  • 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).
    Code:
    SUB INTERRUPT MyInterrupt : REM No parameters and no return. Must be a SUB
         [...]
         END SUB
    or more idiomatic
    Code:
    SUB Spritty AS INTERRUPT
         [...]
         END SUB
Some compilers allows to declare several interrupts and chain them, but I think one should suffice.
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 ... ]

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
Nice to hear that. Tongue Regarding to the routines being removed by -On, yes this is a problem I'm addressing. The compiler does not know anything about user's ASM block content (that's at the assembling stage). The reason is this is a "generic architecture" compiler (or a wanna be). So, for example, if I port the compiler to Commodore or PS3 (yes, it could be done, in fact), the assembler will be completely different. -O3 module has problem with this, because it's the nexus between BASIC layer (frontend) and asm/target machine layer (backend). In fact, such module must be completely rewritten for every architecture.

Having said that, I've thought some solutions:
  1. Put function calls at the end of the program, if you don't want them to be removed.
  2. 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:
    Code:
    DIM MyVar1, MyVar2 as uInteger

        SUB MyFunction
        [...]
        END SUB

        ASM USES { MyFunction, MyVar1, MyVar2 }
        [...]
        call MyFunction
        ld (MyVar1), hl
        END ASM
    or alike
What do you think? If you like this, please, add it in the wishlist :wink:
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)