Hi all,
I've also posted this question on the gbadev.org forums so I apologise
if you've also read this there.
Anyway, I'm using interrupts in my code and most of the time it works
fine. However, I have begun noticing occasional random problems. I've
just been looking at the CowBite spec, and it says that the first thing
the BIOS does when it is called by an interrupt is put r0-r3, r12 and
LR_irq on the stack.
I believe this might be the source of the problems because inside some
of my routines I'm storing the stack (r13) and then using it as a
general purpose register. Of course, I restore the stack before
returning or calling another function so there's not normally a problem.
However, if an interrupt were to occur whilst r13 contained something
other than the stack then random areas of memory would be corrupted.
First of all, is my understanding correct? If it is, is there any way to
change this behaviour? In other words, I need chance to set r13 to a
suitable value before the BIOS is called. Or, failing that, if I switch
off interrupts whilst r13 is mangled will any interrupts that would have
occured whilst interrupts were switched off be called instantly or will
they be missed completely? If the latter is the case, can anyone suggest
a way around this problem (apart from rewriting the code so that r13 is
always the stack)?
Any help would be greatly appreciated!
Thanks,
James.
--
/\ apex James Daniels
//\\ designs james.daniels@...
//__\\ http://www.apex-designs.net