08-17-2020, 11:56 PM
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