But what if you want to be able to pass a call on to the vector's previous claimant? Worse, what if the previous claimant was another extended vector?
And what if you want to claim IRQ1V/IRQ2V? The extended vector mechanism exits with an RTS, not an RTI.
Acorn spent a bunch of OS workspace on the extended vector table, and a bunch of ROM on the entry trampolines for all those vectors. They must have had some kind of aspiration that they be useful for stuff other than filing systems... right?
So what's the workaround? Sometimes, if you're wanting to stash details of a vector's previous claimant, you're going to need to claim some workspace for your ROM anyway, at which point you could just drop your own trampoline into RAM and avoid the whole thorny problem. But suppose you want to avoid claiming workspace and have somewhere else you can stash data - sideways RAM, for example. Now what?
I can't see any solution which doesn't involve using the forbidden knowledge that, on entry to your extended vector, the stack contains the return address to the extended vector mechanism (hereinafter "XVRA"), the previous ROM number ("PR#"), two junk bytes then the return address to the caller.
Even armed with that knowledge, what you'd have to do is pretty grim:
- To pass the call on to a previous non-extended claimant: stack two more bytes. Shuffle XVRA and PR# up by two bytes. Insert previous_claimant - 1 into the gap. RTS.
- To pass the call on to a previous extended claimant: stack seven more bytes. Copy XVRA. Insert the ROM number of the previous claimant and previous_claimant - 1 into the gap. RTS.
- To return from an interrupt: Decrement the caller address which is below the stack frame. Yoink the saved P up from below the frame. Shuffle XVRA and PR# down by a byte. Restore P manually. RTS.