Callback instructions
SPLat provides a mechanism for returning from a subroutine, then later resuming the subroutine at the next instruction. Here’s an example:
wCallbackAddress defWORD ;memory to hold the resume address
...
GoSub subMySubroutine ;start the subroutine
(Suspend brings us back to here)
...
GoSub subDoCB ;go jump to the registered routine
(Will Return here)
...
subDoCB:
Resume wCallbackAddress ;jump back to the subroutine
(if we're here, it means there was no callback, ie wCallbackAddress is 0)
Return
subMySubroutine:
...
Suspend wCallbackAddress ;save the address in the variable
(Will Resume here)
fLoadW 0 ;you can erase the callback address..
FixToMem16U wCallbackAddress ;..if you don't want it called again
...
Return ;exit the subroutine, goes back to the Resume