world leader in high performance signal processing
Trace: » benchmarks

Benchmarks

Examination of the assembly code generated when calling the swap function shows that R1 stores the second parameter and R0 stores the first parameter; however, in this case the parameters are addresses of variables instead of values of variables. The assembler code may look something like the following:

.global _swap;
 _swap:
 /***store addresses***/
 P2 =R0 ;
 P1 =R1 ;
 /***store values from given addresses***/
 R0 =[P2 ];
 R1 =[P1 ];
 /***write values to given addresses, swapping locations***/
 [P2 ] =R1 ;
 [P1 ] =R0 ;
 RTS;

First, this code stores the address saved in R0 to pointer register P2 and the address saved in R1 to pointer register P1. The value at the address pointed to by P2 is then stored in R0 and the value at the address pointed to by P1 is stored in R1. Finally, the address pointed to by P2 is written with the value in R1 and the address pointed to by P1 is written with the value in R0. When this done the original values from the two memory locations have swapped positions.

There are of course many other assembler directives, assembly instructions, and methods of parameter passing that cannot be covered here. For more information on the GNU assembler click here. For information on Blackfin assembly instructions see the Blackfin Processor Instruction Set Reference, available online from Analog Devices' website.

Complete Table of Contents/Topics