; code: lang=asm-collection tabSize=8 ; macros for placing interrupt vectors in the middle of a block of threaded code SPT_SKIP_INTVEC .macro dw spt_jp, .intvec_continue ; continue after the NMI vector PLACE_INTVEC ; ld sp,0 reti .intvec_continue: .endm SPT_SKIP_NMIVEC .macro dw spt_jp, .nmivec_continue ; continue after the NMI vector ; PLACE_NMIVEC PLACE_VEC $66 ; ld sp,0 ; on model 1, NMI is connected to reset button retn .nmivec_continue: .endm ; Start a threaded-code section by pointing to it with SP and issuing RET ; immediately following this macro should be the addresses (and optionally, ; parameters) for the threaded code SPTHREAD_BEGIN .macro .local threadstart ld sp,.`threadstart ret .`threadstart: .endm ; At the end of the threaded code section, place an address just beyond ; the list of addresses, to jump back to conventional code SPTHREAD_END .macro dw $+2 .endm ; Save the stack pointer into the stack registers. This is analogous ; to pushing SP onto the (simulated) stack. The shadow registers hold ; two copies of SP, and effectively become a 2-element stack. This means ; that there can be up to two threaded code stack frames saved. The ; innermost threaded stack frame can call a third-level machine-code ; subroutine, but that subroutine can't make any further calls or run ; threaded code itself. SPTHREAD_SAVE .macro exx ex af,af' ; save flags because of the add hl,sp instruction ex de,hl ld hl,0 ; copy old sp to iy add hl,sp ex af,af' exx .endm ; The opposite of SPTHREAD_SAVE. Pops SP off the simulated stack in ; preparation for returning to the enclosing threaded stack frame. SPTHREAD_RESTORE .macro exx ld sp,hl ; resume from the thread location saved in hl' ex de,hl exx .endm ; The prologue for a subroutine that contains threaded code. SPTHREAD_ENTER .macro SPTHREAD_SAVE SPTHREAD_BEGIN .endm ; The epilogue for a subroutine that contains threaded code. To be followed by RET SPTHREAD_LEAVE .macro SPTHREAD_END SPTHREAD_RESTORE .endm MAC_SPT_CON_GOTO .macro row,col dw spt_con_goto, VBASE+(row*VLINE)+col .endm MAC_SPT_CON_OFFSET .macro row,col dw VBASE+(row*VLINE)+col .endm