Branches
4-14
ADSP-BF53x/BF56x Blackfin Processor Programming Reference
[--SP] = (R7:7, P5:5); /* multiple push instruction */
P5.H = HI(myregister); /* P5 used locally */
P5.L = LO(myregister);
R7 = [P5]; /* R7 used locally */
R0 = R0 + R7; /* R0 user for parameter passing */
(R7:7, P5:5) = [SP++]; /* multiple pop instruction */
RTS; /* return from subroutine */
myfunction.end: /* closing subroutine label */
Due to the syntax of the multiple-push, multiple-pop instructions, often
the upper R- and P-registers are used for local purposes, while lower regis-
ters pass the parameters. See the
“Address Arithmetic Unit”
chapter for
more details on stack management.
The
CALL
instruction not only redirects the program flow to the myfunc-
tion routine, it also writes the return address into the
RETS
register. The
RETS
register holds the address where program execution resumes after the
RTS
instruction executes. In the example this is the location that holds the
[P0]=R0;
instruction.
The return address is not passed to any stack in the background. Rather,
the
RETS
register functions as single-entry hardware stack. This scheme
enables “leaf functions” (subroutines that do not contain further
CALL
instructions) to execute with less possible overhead, as no bus transfers
need to be performed.
If a subroutine calls other functions, it must temporarily save the content
of the
RETS
register explicitly. Most likely this is performed by stack oper-
ations as shown below.
/* parent function */
CALL function_a;
/* continue here after the call */
JUMP somewhereelse;
function_a: /* subroutine label */
[--SP] = (R7:7, P5:5); /* optional multiple push instruction */
Содержание ADSP-BF53x Blackfin
Страница 38: ...Conventions xxxviii ADSP BF53x BF56x Blackfin Processor Programming Reference...
Страница 134: ...System Reset and Powerup 3 18 ADSP BF53x BF56x Blackfin Processor Programming Reference...
Страница 324: ...Instruction Overview 7 20 ADSP BF53x BF56x Blackfin Processor Programming Reference...
Страница 486: ...Instruction Overview 13 28 ADSP BF53x BF56x Blackfin Processor Programming Reference...
Страница 512: ...Instruction Overview 14 26 ADSP BF53x BF56x Blackfin Processor Programming Reference...
Страница 604: ...Instruction Overview 15 92 ADSP BF53x BF56x Blackfin Processor Programming Reference...
Страница 688: ...Instruction Overview 18 48 ADSP BF53x BF56x Blackfin Processor Programming Reference...
Страница 742: ...Instruction Overview 19 54 ADSP BF53x BF56x Blackfin Processor Programming Reference...
Страница 752: ...Examples 20 10 ADSP BF53x BF56x Blackfin Processor Programming Reference...
Страница 780: ...Product Identification Register 21 28 ADSP BF53x BF56x Blackfin Processor Programming Reference...
Страница 790: ...ADSP BF535 Flags A 10 ADSP BF53x BF56x Blackfin Processor Programming Reference...
Страница 800: ...Performance Monitor Registers B 10 ADSP BF53x BF56x Blackfin Processor Programming Reference...
Страница 994: ...Instructions Listed By Operation Code C 194 ADSP BF53x BF56x Blackfin Processor Programming Reference...
Страница 1042: ...Index I 40 ADSP BF53x BF56x Blackfin Processor Programming Reference...