![]() |
|
Dynamic Interrupt Routine - Printable Version +- Boriel Basic Forum (https://forum.boriel.com) +-- Forum: Compilers and Computer Languages (https://forum.boriel.com/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://forum.boriel.com/forumdisplay.php?fid=11) +---- Forum: How-To & Tutorials (https://forum.boriel.com/forumdisplay.php?fid=13) +---- Thread: Dynamic Interrupt Routine (/showthread.php?tid=971) |
Dynamic Interrupt Routine - emook - 2020-08-18 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 asmRE: Dynamic Interrupt Routine - boriel - 2020-08-18 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... RE: Dynamic Interrupt Routine - emook - 2020-08-18 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. RE: Dynamic Interrupt Routine - boriel - 2020-08-18 Ah, I understand, thanks!!! RE: Dynamic Interrupt Routine - Duefectu - 2020-08-18 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. RE: Dynamic Interrupt Routine - boriel - 2020-08-19 (2020-08-18, 11: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'm working on a more generic implementation now that ZX Basic 2.x is on the way! Stay tuned!
RE: Dynamic Interrupt Routine - worcestersource - 2020-12-28 Woo! Version 2? I just joined today to make the game I always wanted to. Thank you for making your compiler.
|