Function Structure and Calling Conventions
6-18
6.3.3.4 Using the TMS320C5x
RETD
instruction
The debugger expects the compiler to generate the frame as described above.
When generating code for the ’C5x that will not be run under the debugger, the
compiler switches steps 2 and 3 of section 6.3.2,
How a Called Function
Responds
, on page 6-15, as well as steps 11 and 12. This occurs because a
PUSHD instruction cannot go in the delay slots (the two words following a
delayed instruction) of a RETD, but a LAR AR0,* can. For the case above, the
last three instructions would be changed as follows:
PSHD
*−
; push return address on hardware stack
RETD
; return delayed
LAR
AR0,* ; restore FP
NOP
; fill delay slots of RETD
If the return address is not saved on the stack, which means a PSHD will not
be generated, the RETD will be moved two words from the end of the function.
6.3.4 Accessing Arguments and Local Variables
In general terms, the compiler performs the first local access, initializing LVP
(AR2) by loading it with the offset of the variable relative to the FP, then a MAR
*0+ instruction adds in the FP. Subsequent accesses are performed by adding
or subtracting the difference between the address of the current local variable
LVP is pointing to and the next one. Because the LVP is not preserved across
calls, it must be reinitialized after a call.
Arguments are always at negative offsets from the FP, and locals are always
at positive offsets from the FP.
Summary of Contents for TMS320C2x
Page 8: ...viii...
Page 69: ...2 47 C Compiler Description...
Page 159: ...6 36...
Page 226: ...8 6...