AGB Programming Manual
AGB System Calls
©1999 - 2001 Nintendo of America Inc.
167
D.C.N. AGB-06-0001-002B4
17.1.2 Multiple Calls
1) When an argument is required for the system call used, after reading to
the registers, R0-R3, call the monitor ROM system call with the
“SWI<Number>”.
2) Save the registers, SPSR_svc (formerly CPSR), R12, LR_svc (formerly
PC) to the system call stack with the monitor ROM.
SP_usr
SP_irq
03007FA0
03007F00
03007F00
IRQ Stack
SVC Stack
USR Stack
4 WORDS
03007FE0
03007FA0
SP_svc
3) Switch from CPU mode to system mode. The status of the IRQ Disable
Flag prior to the call is kept in System ROM. The previous conditions will
be continued.
4) Save the R2 and LR_usr registers to the user stack. Other registers will
be saved with each system call.
LR_usr
SP_irq
SP_usr
Save with each
System Call
03007FA0
03007F00
03007F00
IRQ Stack
SVC Stack
Usr Stack
4 WORDS
03007FE0
03007FA0
R2
SP_svc
5) Interrupt occurs while executing system call.
LR_usr
SP_usr
6 WORDS
Save with each
System Call
03007FA0
03007F00
03007F00
IRQ Stack
SVC Stack
USR Stack
4 WORDS
03007FE0
03007FA0
R2
SP_irq
SP_svc
6) User interrupt processing is done. (You can reference the cause of the
interrupt with the IF Register.) The CPU mode is changed to System Mode
(User Mode with privilege) in order to solve the problem with stacks (to
reference interrupt processing).
LR_usr
SP_usr
6 WORDS
03007FA0
03007F00
IRQ Stack
SVC Stack
USR Stack
4 WORDS
03007FE0
03007FA0
User Interrupt
Processing
Save with each
System Call
03007F00
R2
SP_irq
SP_svc
à
If System Call occurs during User interrupt processing, the System Call
is called using Multiple Calls.