Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dynamic Interrupt Routine
#1
A simple dynamic IM routine, it will automatically find the nearest suitable IM jump from, ie you can compile at any address. Best to keep below $C000 if you have any paging plans. 

Code:
dim bx as ubyte

Sub SetUpIM()
asm
    di
    ld hl,IMvect
    ld de,IMvect+1
    ld bc,257
    ld a,h
    ld i,a
    ld (hl),a
    ldir
    ld h,a : ld l, a : ld a,$c3 : ld (hl),a : inc hl
    ld de,._ISR : ld (hl),e : inc hl : ld (hl),d
    IM 2
    ei
end asm
end sub


Sub fastcall ISR()

    asm
    push af : push bc : push hl : push de : push ix : push iy
    ex af,af'
    push af : exx
    
    end asm
    
    MyCustomIM()
    
    asm
    
    exx : pop af
    ex af,af'
    pop iy : pop ix : pop de : pop hl : pop bc : pop af
    ei
    'jp 56 uncomment for running with basic
    end asm

end sub

sub MyCustomIM()

    bx = bx + 1 BAND 7 : border bx

end sub

SetUpIM()
'stop uncomment for running in basic

Do
    For y  = 0 to 20
        print at y,0; "testing .... ";bx 
    next y
Loop

ISR()     ' call to ensure ISR doesn't get optimized!

Imtable:
ASM
    ALIGN 256
    IMvect:
    defs 257,0
end asm
Reply
#2
Some questions:

1) Why the JP 56?
2) You do exx but do not push /pop the EXXed registers?

Ah, one more thing: after discussing with other "hardware geeks", all agreed that the value should be always $FF in the table so, as you suggested, only the last value is taken into account. The thing is that only "bugged" (i.e. very old Kempston interfaces) places random (non $FF) values in the Bus, but well designed ones don't. So...
Reply
#3
JP 56 is for it you want to use while basic is still running, so you could have your interrupt running in the back ground while NORMAL basic is running. So you can set up an inerrupt using zxb then exit back to basic and have it running.

Didn't push the exx regs as I didn't need them in this instance.
Reply
#4
Ah, I understand, thanks!!!
Reply
#5
In my implementation, in every interrupt I read the $c000 page, switch to the music page (for example), run music, and then switch to the original page before return.

I thing it's important for Next developments where $c000 memory area are used for several resources, at leat in my implementation.
Duefectu
https://zx.duefectucorp.com
duefectucorp@gmail.com
Reply
#6
(08-18-2020, 10:38 PM)Duefectu Wrote: In my implementation, in every interrupt I read the $c000 page, switch to the music page (for example), run music, and then switch to the original page before return.

I thing it's important for Next developments where $c000 memory area are used for several resources, at leat in my implementation.

I'm working on a more generic implementation now that ZX Basic 2.x is on the way! Stay tuned! Cool
Reply
#7
Woo! Version 2? I just joined today to make the game I always wanted to. Thank you for making your compiler. Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)