AN2109 Freescale Semiconductor / Motorola, AN2109 Datasheet - Page 20

no-image

AN2109

Manufacturer Part Number
AN2109
Description
MPC555 Interrupts
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
5 Determining Which Registers to Save and Where to Save Them
Comply with stack conventions [EABI] used by compiler and debug tools
(recommended)
Additional exceptions, including debug breakpoints), are allowed during the
exception.
Use LR, (e.g., for calling an assembler or C routine handler) for an interrupt
source
Call assembler routines only (no floating point in ISR)
Call C routine (no floating point in ISR)
Complete context switch, such as with an RTOS (no floating point)
Use floating point registers in assembly routines only
Use floating point in C routine
Use floating point with complete context switch, as with an RTOS
Before writing software for the interrupt service routine (ISR), you must determine how much “context”
to save and where to save it. In general, any registers that could be modified during in the ISR should
be saved on the stack.
How much is saved can vary dramatically among applications. For example, if all software executed
during the interrupt exception is written in assembler, then only those few registers used can be easily
identified and saved on the stack.
However, if the ISR calls a C routine, then the compiler could use the scratch registers (called volatile
registers) as defined in the EABI. Therefore, all volatile registers must be saved because it cannot be
predict which registers the compiler will use. Other registers that a compiler might use will need to be
saved also, such as XER (which has the carry), CR (for compares) and CTR (for counter/branch uses).
Some applications may want to even save timer values.
Table 14
Registers should be saved in a stack frame, as defined in the
frames are created by decrementing the stack pointer by a size that can be used to store all the regis-
ters. Stack frames must be modulo eight bytes, so four bytes of padding may be required.
Table 15
volatile registers are saved.
is an example checklist to help determine what to save.
lists the EABI stack frame organization and a sample ISR stack frame. In this example, the
ISR Requirement
Freescale Semiconductor, Inc.
For More Information On This Product,
Table 14 Register Save Checklist
Rev. 0, 26 July 2001
MPC555 Interrupts
Go to: www.freescale.com
Section 2.7 EABI
Per EABI, save all volatile gprs (gpr0,
gpr3:12) plus any other registers that
a C routine could change (e.g., XER,
CR, CTR)
All gprs (gpr0:31) plus any other
registers that a C routine could
change (e.g., XER, CR, CTR)
Register(s) to be Saved
All volatile fprs (fpr0:13)
gprs used in routines
fprs used in routine
All fprs (fprs 0:31)
SRR0:1
SP
LR
Standard. Stack
MOTOROLA
20

Related parts for AN2109