www.pudn.com > DaVinci_Qam.zip > qam_gen_unpack_lookup.asm


/******************************************************************************* 
Copyright(c) 2000 - 2002 Analog Devices. All Rights Reserved. 
Developed by Joint Development Software Application Team, IPDC, Bangalore, India 
for Blackfin DSPs  ( Micro Signal Architecture 1.0 specification). 
 
By using this module you agree to the terms of the Analog Devices License 
Agreement for DSP Software.  
******************************************************************************** 
Module name     : qam_gen_unpack_lookup.asm 
Label name      : _qam_gen_unpack_lookup 
Version         : 2.0 
 
                Change History  : 
                Version   Date            Author        Comments 
                2.0       01/09/2007                    Tested with VDSP++4.5 
							compiler 7.2.3.2 
		1.4       11/18/2002      Swarnalatha   Tested with VDSP++ 3.0 
                                                        compiler 6.2.2 on  
                                                        ADSP-21535 Rev.0.2 
                1.3       11/13/2002      Swarnalatha   Tested with VDSP++ 3.0 
                                                        on ADSP-21535 Rev. 0.2 
                1.2       01/20/2002      Nishanth      Modified to match  
                                                        silicon cycle count and  
                                                        to avoid accessing of  
                                                        protected area in memory 
                1.1       03/28/2001      Nishanth      Changing of P reg to I 
                                                        reg inside loop 
                1.0       03/04/2001      Nishanth      Original  
 
Description     : This program receives symbols from memory pointed to by  
                  input pointer and map the symbol to corresponding state by  
                  fetching the co-ordinates from lookup table passed as a  
                  parameter. 
                    It outputs one x coordinate and a  y co-ordinate  for each  
                  symbol. 
 
Prototype       : void qam_gen_unpack_lookup( 
                        short *iptr,       // (i) : Input pointer  
                        short *optr,       // (o) : Output pointer  
                        short *lookuptable,// (i) : Base address of lookup table 
                        int   n)           // (i) : Number of symbols  
 
Assumptions     : 1. There should be atleast 3 symbols. 
                  2. iptr[] should be aligned to a 2 byte boundary. 
                  3. optr[] and lookuptable[] should be aligned to a 4 byte  
                     boundary. 
                  4. optr[] and lookuptable[] should be in different  
                     minibanks. 
                  5. iptr[] and stack should be in different minibanks. 
 
Registers used  : R0-R3, I0-I2, M1,M2, L0-L2, P1, LC0, CC. 
 
Performance     : 
                    Code Size   : 116 Bytes. 
                    Cycle Count : 20   +   3 * n      for even number of symbols 
                                  27   +   3 * n      for odd number of symbols 
                                792 cycles for 255 symbols 
                                788 cycles for 256 symbols 
 
*******************************************************************************/ 
.section  L1_code; 
.global _qam_gen_unpack_lookup; 
.align 8; 
     
_qam_gen_unpack_lookup:      
     
    I2 = R0;                // Input SYMBOL pointer 
    I0 = R1;                // Output Pointer 
    I1 = R2;                // Base address of lookup table 
    L2 = 0;                 // Disabling circular buffering 
    L0 = 0;                 // Disabling circular buffering 
    R1.H = R2.L - R2.L(S) || R1.L = W[I2++]    || P1 = [SP + 12];  
                            // R1.H = 0, READ FIRST SYMBOL, P1 = number of  
                            //symbols 
    R2 = R1 << 2;           // Symbol multiplied by four since there are 4  
                            //bytes in the lookup 
                            // table corresponding to each symbol 
    R1.L = W[I2++];         // Read second symbol 
    M2 = R2;                // Offset = 4 * first symbol 
    L1 = 0;                 // Disabling circular buffering     
    R0 = -4;                            
    P1 += -1; 
    R2 = R0.L * R1.L(IS) || R1.L = W[I2++] || I1 += M2; 
                            // Offset = 4 * second symbol, Fetch third symbol,  
                            //Offset is added to base address 
    M1 = R2 ;                    
    R2 = R0.L * R1.L(IS) || I1 -= M2   || R3 = [I1];  
                            // Offset = -4 * third symbol, Co-ordinates of  
                            //first symbol is fetched 
                            // Base address is restored 
     
 
    LSETUP(LOOP1_ST,LOOP1_END) LC0 = P1 >> 1;  
                            // Loop for number of symbols/2 
LOOP1_ST: 
        M2 = R2;            // Offset of odd symbols 
        I1 -= M1    || R1.L = W[I2++]; 
                            // Add offset of even symbols to base address,  
                            //fetch even symbols 
        R2 = R0.L * R1.L(IS) || R3 = [I1++M1]    || [I0++] = R3; 
                            // Find offset of even symbols, fetch coordinates  
                            //of even symbols 
                            // Store result of odd symbols(first) 
        M1 = R2;            // Offset of even symbols 
        I1 -= M2    || R1.L = W[I2++]; 
                            // Add offset of odd symbols to base address, fetch  
                            //odd symbols 
LOOP1_END: 
        R2 = R0.L * R1.L(IS)   || R3 = [I1++M2]   || [I0++] = R3; 
                            // Find offset of odd symbols, fetch coordinates of  
                            //odd symbols 
                            // Store result of even symbols(second) 
    R0 = P1;                // R2 = symbol count 
    I1 -= M1 || [I0++] = R3;// Add offset of even symbols to base address,  
                            //Store result of odd symbols(first) 
    CC = BITTST(R0,0); 
    IF !CC JUMP L_END;      // no. of symbols = even? 
    R3 = [I1++M1]; 
    [I0++] = R3;            // Store result of even symbols(second) 
L_END: 
    RTS;     
                            // Program ends here 
    NOP;                    // If link or unlink happens to be the next  
                            //instruction after RTS in memory, RTS takes one  
                            //extra cycle than expected. NOP is put to 
                            // avoid this. 
_qam_gen_unpack_lookup.end: