JSR Indirect Address
Posted: Wed May 31, 2017 12:25 am
As best as I can tell, this isn't possible natively, but I thought someone might have an idea...
Basically, I want to do "JSR (a)". Obviously this doesn't exist - JSR only does "JSR a". I could perhaps synthesize it using by constructing the appropriate values on the stack before using "JMP (a)"? But that seems messy.
Its for a my bios IRQ handler, an outline of which is in the code block below.
Essentially, I want to make it so the user program can specify a custom IRQ handler, without necessarily disabling the native BIOS IRQ handler functionality. Any ideas, thoughts, comments etc extremely welcome.
P.S. There seems to be a bizarre bug in the Assembler on the line "BBS0 biosIrqMode, ?HandlerPrologue" - it states that "biosIrqMode" is an invalid addressing mode... It doesn't complain for the same line with BBS1 or BBR0.... since they're all effectively the same instructions, I am very puzzled.
Basically, I want to do "JSR (a)". Obviously this doesn't exist - JSR only does "JSR a". I could perhaps synthesize it using by constructing the appropriate values on the stack before using "JMP (a)"? But that seems messy.
Its for a my bios IRQ handler, an outline of which is in the code block below.
Essentially, I want to make it so the user program can specify a custom IRQ handler, without necessarily disabling the native BIOS IRQ handler functionality. Any ideas, thoughts, comments etc extremely welcome.
Code: Select all
CODE
IrqHandler:
; If bit 1 of biosIrqMode = 0 then skip custom IRQ handler
BBR1 biosIrqMode, ?HandlerImpl
JSR (biosIrqHandler)
?HandlerImpl:
; If bit 0 of biosIrqMode = 1 then skip the BIOS IRQ functionality
BBS0 biosIrqMode, ?HandlerPrologue
PHA
PHX
PHY
; .... ETC
PLY
PLX
PLA
?HandlerPrologue:
BBR2 biosIrqMode, ?HandlerEnd
JSR (biosIrqHandler)
?HandlerEnd:
RTI
ENDS
PAGE0
biosIrqHandler dw ; Address for the custom IRQ handler subroutine
biosNmiHandler dw ; Address for the custom NMI handler subroutine
biosIrqMode db ; Bitfield for customizing the BIOS' interrupt functionality
; Bit 0: Disable BIOS IRQ functionality
; Bit 1: Enable custom IRQ handler before BIOS IRQ functionality
; Bit 2: Enable custom IRQ handler after BIOS IRQ functionality
; Bit 3: Enable custom NMI handler
ENDS