Jump to content
IGNORED

OS IRQ vectors, can they be nested?


Recommended Posts

A question for those who know both the 6502 and the Atari OS routines, I can't find a definite answer.

 

I know that for the 6502, IRQs can be nested, NMI's can't.

 

Does this translate to IRQ vectors exposed by the operating system? I am wondering if I could do an SIO call in the VINTER or VPROCED vectors, or if I need to just set a flag, and do the call outside the IRQ?

 

-Thom

Link to comment
Share on other sites

The standard IRQ dispatcher tail-calls into your routine, so yes, you can drop out of IRQ level by clearing the I flag. This effectively drops you to a priority level between mainline code and interrupt handlers. Afterward, you just RTI back to the original caller. Calling into SIOV should be perfectly fine from this as long as only application code was interrupted. Interrupting an OS routine may be less safe since that routine may be using variables overlapping with SIO. I'm not sure if interrupting E: or K: this way is safe.

 

This can be done from an NMI routine as long as you check the I flag of the interrupting routine. The OS SYSVBL does this and skips VBI stage 2 if an IRQ routine was interrupted. In theory it is possible to make this reliable by using the serial output complete IRQ to force an IRQ to happen under software control, thus allowing your routine to 'continue' after the interrupted IRQ routine has exited. Never had an opportunity to actually try this.

 

A 65C816 OS will throw an additional monkey wrench in here as it will have to do additional thunking between native and emulation mode to call your interrupt routine. This is more likely if you interrupt the OS display handler as it is likely to be written in native mode. When this happens, the native interrupt handler will push the full native state onto the stack before switching to emulation mode and calling the handler, then restore the native state on return. If you care about compatibility with these, then you should expect additional stack usage and ensure that you exit normally with RTI and don't attempt to bypass directly back to mainline from your interrupt code.

 

  • Like 2
Link to comment
Share on other sites

Note though that the interrupt flag at the source has to be cleared otherwise you'll get recursive interrupts - shouldn't happen if doing it using the OS but entirely possible if you take over the lower level generic handling.

 

I devised a good usage case for using SEROC during VBlank - it's handy if you want something like digital sound by IRQ as well as your Stage 2 VBlank to be run unconditionally every time - so good for a game where you want speech without pausing the gameplay.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...