Delayed Branch, Call, And Return Instructions - Texas Instruments TMS320C2x User Manual

Optimizing c compiler digital signal processor
Hide thumbs Also See for TMS320C2x:
Table of Contents

Advertisement

Example 3−2. Delayed Branch, Call, and Return Instructions
main()
{
int i0, i1;
while (input(&i0) && input(&i1))
process(i0, i1);
}
TMS320C2x/C2xx/C5x C Compiler Output:
_main:
SAR
POPD
SAR
BD
LARK
LAR
***
B
L1:
LARK
MAR
LAC
SACL
CALLD
LAC
SACL
***
CALL
SBRK
L2:
MAR
LARK
CALLD
MAR
SAR
***
CALL
MAR
BZ
MAR
LARK
CALLD
MAR
SAR
***
CALL
MAR
BNZ
EPI0_1:
MAR
SBRK
PSHD
RETD
LAR
NOP
***
RET OCCURS
. . .
AR0,*+
; function prolog
*+
; save AR0 and return address
AR1,*
; begin to set up local frame
L2
; begin branch to loop control
AR0,3
; finish setting up local frame
AR0,*0+
L2 OCCURS
; branch to loop control
; loop body
AR2,2
; AR2 = &i1
*0+
*−,AR1
; ACC = *AR2, AR2 = &i0
*+,AR2
; stack ACC
_process
; begin call
* ,AR1
; ACC = *AR2
*+
; stack ACC
_process OCCURS
; call occurs
2
; pop stack
; loop control
* ,AR5
; AR5 = &i0
AR5,1
_input
; begin call
*0+,AR1
AR5,*+
; stack AR5
_input OCCURS
; call occurs
*−
; clear stack
EPI0_1
; quit if _input returns 0
* ,AR4
; AR4 = &i1
AR4,2
_input
; begin call
*0+,AR1
AR4,*+
; stack AR4
_input OCCURS
; call occurs
*−,AR2
; clear stack
L1
; continue if _input returns !0
* ,AR1
; function epilog
4
; clear local frame
*−
; push return address on hardware stack
; begin return
AR0,*
; restore AR0
; necessary, no PSHD in delay slot
; return occurs
What Kind of Optimization Is Being Performed?
Optimizing Your Code
3-17

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the TMS320C2x and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Tms320c2xxTms320c5x

Table of Contents