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


Messages In This Thread
Dynamic Interrupt Routine - by emook - 08-17-2020, 11:56 PM
RE: Dynamic Interrupt Routine - by boriel - 08-18-2020, 04:18 PM
RE: Dynamic Interrupt Routine - by emook - 08-18-2020, 04:32 PM
RE: Dynamic Interrupt Routine - by boriel - 08-18-2020, 10:35 PM
RE: Dynamic Interrupt Routine - by Duefectu - 08-18-2020, 10:38 PM
RE: Dynamic Interrupt Routine - by boriel - 08-19-2020, 08:27 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)