gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

ASM > Read user SP from inside an IRQ?

#158969 - Dwedit - Mon Jun 23, 2008 3:35 pm

How do I read the user mode stack pointer from within an interrupt handler?

Edit: I see that libgba's IRQ handler switches to System mode before jumping to an IRQ handler, do I just switch to system mode to read SP?

Edit: looks like the question was moot because I was in system mode anyway... oh well.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#159007 - eKid - Tue Jun 24, 2008 6:52 am

Yeah you just have to change the mode with the CPSR (low 5 bits)
http://nocash.emubase.de/gbatek.htm#cpuflags
Then the SP (and some other regs too) magically change to the registers of the new mode.
http://nocash.emubase.de/gbatek.htm#cpuregisterset