Register Conventions
6-12
Register AR1 is dedicated as the stack pointer. The compiler uses the SP in
the conventional way: the stack grows towards higher addresses, and the SP
points to the next available word on the stack.
Register AR0 is dedicated as the frame pointer. The FP points to the beginning
of the local frame for the current function. The first word of the local frame,
which is directly pointed to by the FP, is used as a temporary memory location
to allow register-to-register transfers and is essential to creating reentrant C
functions.
Register AR2 is dedicated as the local variable pointer. All objects stored on
the local frame, including arguments, are referenced indirectly through the
LVP. See section 6.3.4,
Accessing Arguments and Local Variables
, on page
6-18, for information on how the LVP is used to access objects on the frame.
6.2.3 The TMS320C5x INDX Register
On the TMS320C5x, the *0+ addressing mode adds the INDX register, not
AR0, into the AR register indicated by the ARP (auxiliary-register pointer-field
of status register ST0). The compiler presumes the NDX bit of the status
register PMST is 0, which means that changes to the register AR0 are shad-
owed in INDX. This also means that the INDX register must be preserved
across calls just as AR0 is. For code executing with NDX = 0, preserving AR0
preserves INDX as well. If, however, you write an assembly routine that
changes the NDX bit to 1, both AR0 and INDX must be preserved explicitly.
6.2.4 Register Variables
Register variables are local variables or compiler temporaries defined to
reside in a register rather than in memory. The way the compiler uses registers
for register variables differs depending on whether you use the optimizer.
6.2.4.1 Register Variables When the Optimizer is Not Used
When the optimizer is not used, the compiler allocates registers for up to two
variables declared with the register keyword. You must declare the variables
in the argument list or in the first block of the function. Register declarations
in nested blocks are treated as normal variables.
The compiler uses AR6 and AR7 for these register variables. AR6 is allocated
to the first variable, and AR7 is allocated to the second register variable.
The
address
of the variable is placed into the allocated register to simplify
access. Only 16-bit types (char, short, int, and pointers) can be used as
register variables.
Summary of Contents for TMS320C2x
Page 8: ...viii...
Page 69: ...2 47 C Compiler Description...
Page 159: ...6 36...
Page 226: ...8 6...