Development Environment:
Vdsp 5.0, bf561There is a built-in function in GCC
_ Builtin_return_address (level)To obtain the return address of the function. This function is not available in vdsp, but FP pointers can be used for the same purpose. In the C function of vdsp, the first assembly command is usually link 0x0; // here the variable number command does the following: [-- Sp] = rets; [-- Sp] = FP; FP = sp; SP + =-N; that is, the return address of this function is saved at the beginning of each function, the FP pointer of the previous function is also saved. In fact, it is equivalent to linking the return address of the function with a single-chain table. As long as you follow the chain table up, you can naturally find the return address for calling the function. Example: # define Level 3 void S3 (void) {unsigned int FP, RTS; int I; ASM ("% 0 = FP;": "= D" (FP )); for (I = 0; I <level; I ++) {RTS = * (unsigned int *) (FP + 4); FP = * (unsigned int *) FP ;} printf ("RTS: 0x % x", RTS);} void S2 (void) {S3 ();} void S1 (void) {S2 ();} int main (INT argc, char * argv []) {S1 (); Return 0;} the output result is: RTS: 0xffa014ba, that is, pointing to S1 () in the main function () the next statement called.