<< Chapter < Page Chapter >> Page >

The assembly file c_fft_given.asm contains two main parts, the data section starting with .sect ".data" and the program section starting with .sect ".text" . Every function and variable accessed in C must be preceded by a single underscore _ in assembly and a .global _name must be placed in the assembly file for linking. In this example, bit_rev_fft is an assembly function called from the C program with a label _bit_rev_fft in the text portion of the assembly file and a .global _bit_rev_fft declaration. In each assembly function, the macro ENTER_ASM is called upon entering and LEAVE_ASM is called upon exiting. These macros are defined in v:\ece420\54x\dspclib\core.inc . The ENTER_ASM macro saves the status registers and AR1 , AR6 , and AR7 when entering a function as required by the register use conventions. The ENTER_ASM macro also sets the status registers to the assembly conventions we have been using (i.e, FRCT =1 for fractional arithmetic and CPL =0 for DP referenced addressing). The LEAVE_ASM macro just restores the saved registers.

Parameter passing

The parameter passing convention between assembly and C is simple for single input, single output assembly functions. Froma C program, the input to an assembly program is in the low part of accumulator A with the output returned in the same place. When morethan one parameter is passed to an assembly function, the parameters are passed on the stack (see the core filedescription for more information). We suggest that you avoid passing or returning more than one parameter. Instead, use globalmemory addresses to pass in or return more than one parameter. Another alternative is to pass a pointer to the start of a bufferintended for passing and returning parameters.

Registers modified

When entering and leaving an assembly function, the ENTER_ASM and LEAVE_ASM macros ensure that certain registers are saved and restored. Since the C program may use any and all registers, the state ofa register cannot be expected to remain the same between calls to assembly function(s). Therefore, any information that needs to be preserved across calls to an assembly function must besaved to memory!

Now, we explain how to use the FFT routine provided by TI for the C54x. The FFT routine fft.asm located in v:\ece420\54x\dsplib\ computes an in-place, complex FFT. The length of the FFT is defined as a label K_FFT_SIZE and the algorithm assumes that the input starts at data memory location _fft_data . To have your code assemble for an N -point FFT, you will have to include the following label definitions in your assembly code.

N .set 1024 K_FFT_SIZE .set N ; size of FFT K_LOGN .set 10 ; number of stages (log_2(N))

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Ece 320 spring 2004. OpenStax CNX. Aug 24, 2004 Download for free at http://cnx.org/content/col10225/1.12
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Ece 320 spring 2004' conversation and receive update notifications?

Ask