MSC100ABIRM Motorola / Freescale Semiconductor, MSC100ABIRM Datasheet - Page 24

no-image

MSC100ABIRM

Manufacturer Part Number
MSC100ABIRM
Description
SC100 Application Binary Interface Reference Manual
Manufacturer
Motorola / Freescale Semiconductor
Datasheet
Low-Level Binary Interface
2.3.3 Optimized Calling Sequences
A stackless convention may be used when calling functions that are not re-entrant, if this technique
generates more efficient code than other conventions. However, this convention can be used only if the
function is not visible to external code. When using the stackless convention, locals may be allocated
statically (i.e., not on a stack). Functions whose lifetime is mutually exclusive may share space for their
locals.
The calling function places actual parameters at locations allocated in the called function for the formal
parameters. The compiler is free to use registers and memory locations when allocating locations for the
formal parameters. Under this calling convention, all registers are classified as caller-saved. Return values
from functions will be placed in the space allocated in the calling function for the function return value.
The compiler is free to use a register or a memory location as the space for the function return value.
2.3.4 Interrupt Handlers
Using an implementation-dependent pragma, functions requiring no parameters and returning no result can
be designated as interrupt functions. The interrupt handler function will always follow the stack-based
calling convention. When an interrupt function is called, the interrupt handler will save all registers and
other resources that are modified by the function. Upon returning from the function, all registers and
hardware loop state saved at entry will be restored to their original state.
Locals will be saved on the stack. Interrupt handlers that are known to be noninterruptible may allocate
data statically as well. Return from interrupt will be implemented using an RTE instruction.
2.3.5 Stack Frame Layout
The stack pointer points to the top (high address) of the stack frame. Space at higher addresses than the
stack pointer is considered invalid and may actually be unaddressable. The stack pointer value must always
be a multiple of eight.
Figure 2-2 shows typical stack frames for a function and indicates the relative position of local variables,
parameters, and return addresses. The outbound argument block is located at the top (higher addresses) of
the frame. Any incoming argument spill generated for varargs and stdags processing must be at the bottom
(lower addresses) of the frame.
The caller puts argument variables that do not fit in registers into the outbound argument overflow area. If
all arguments fit in registers, this area is not required. A caller may allocate argument overflow space
sufficient for the worst-case call, use portions of it as necessary, and not change the stack pointer between
calls.
Local variables that do not fit into the local registers are allocated space in the local variables area of the
stack. If there are no such variables, this area is not required.
2-6
Table 2-3. Register Usage in the Stack-Based Calling Convention (Continued)
r7
n0–n3 m0–m3
Register
Optional frame pointer
Used As
Preliminary (April 2000)
Caller Saved
+
SC100 Application Binary Interface
Callee Saved
+

Related parts for MSC100ABIRM