
Function Structure and Calling Conventions
6-16
1 is an example of TMS320C2x code that performs the tasks listed
in section 4.3.2.
Example 6
−
1. TMS320C2x Code as a Called Function
; presume ARP = AR1 (SP)
POPD
*+
; pop return address, push on software stack
SAR
AR0,*+
; push AR0 (FP)
SAR
AR1,*
; *SP = SP
LARK
AR0,SIZE
; FP = size of frame
LAR
AR0,*0+
; FP = SP, SP += size ==> allocate frame
SAR
AR6,*+
; push AR6
SAR
AR7,*+
; push AR7
...
; code for the function
MAR
*,AR1
; set ARP = SP
MAR
*−
; point to saved AR7
LAR
AR7,*−
; pop AR7
LAR
AR6,*−
; pop AR6
SBRK
SIZE+1
; deallocate frame, point to saved FP
LAR
AR0,*−
; pop FP
PSHD
*
; push return address on hardware stack
RET
; return
6.3.3 Special Cases for a Called Function
There are four special cases for a called function:
-
Returning a structure
-
Not moving the return address to the software stack
-
Not allocating a frame
-
Using the TMS320C5x RETD instruction
These cases are explained in the following sections.
Содержание TMS320C2x
Страница 8: ...viii...
Страница 69: ...2 47 C Compiler Description...
Страница 159: ...6 36...
Страница 226: ...8 6...
Страница 250: ...Index Index 14 Z z shell option 2 2 2 4 2 14 overriding with c option 4 5 overriding with n option 2 13...