vdub_bobby Posted December 20, 2007 Share Posted December 20, 2007 I'm trying to port Squish 'Em from the A8 to the 5200 and it keeps crashing when it returns from an interrupt. Judging from the trace log, the stack pointer is getting bunged up somewhere. Do the 5200 and the A8 handle interrupts differently? Quote Link to comment Share on other sites More sharing options...
Rybags Posted December 21, 2007 Share Posted December 21, 2007 For starters, the RAM based vector locations are different. But, looking at a disassembly http://atarihq.com/danb/files/5200BIOS.txt Things aren't too much different. Both machines on IRQ jump through an immediate IRQ vector, without doing anything to the registers (although XL and later performs a CLD). Both machines push A to the stack in their immediate IRQ routine. Then later on also push X. So, an IRQ routine would need to take action dependant on it's type (nothing, pull A, pull X and A). NMI routines seeem to be an entire different matter. Both machines do nothing if it's a DLI - giving the user control without any register saving. But: in a VBI, the 5200 does not save any registers before passing through the Immediate VBlank vector, where the computer saves all registers. So, on the computer, you return from VBlank simply by jumping either to $E45F or $E462. On the 5200, you are responsible for saving/restoring any registers you use. Quote Link to comment Share on other sites More sharing options...
vdub_bobby Posted December 22, 2007 Author Share Posted December 22, 2007 (edited) For starters, the RAM based vector locations are different. But, looking at a disassembly http://atarihq.com/danb/files/5200BIOS.txt Things aren't too much different. Both machines on IRQ jump through an immediate IRQ vector, without doing anything to the registers (although XL and later performs a CLD). Both machines push A to the stack in their immediate IRQ routine. Then later on also push X. So, an IRQ routine would need to take action dependant on it's type (nothing, pull A, pull X and A). NMI routines seeem to be an entire different matter. Both machines do nothing if it's a DLI - giving the user control without any register saving. But: in a VBI, the 5200 does not save any registers before passing through the Immediate VBlank vector, where the computer saves all registers. So, on the computer, you return from VBlank simply by jumping either to $E45F or $E462. On the 5200, you are responsible for saving/restoring any registers you use. OK, thanks - that must be it. In the VBI it is screwing up the registers since it isn't saving them and then screwing up the stack pointer since it pulls three values off the stack (that it didn't push to begin with) before returning. I think the only interrupts in Squish 'Em are a (giant) DLI, a VBI, and the keyboard. So I think if I add code to save the registers at the beginning of the VBI I should fix that problem. Thanks again. Edited December 22, 2007 by vdub_bobby Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.