⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 amf_rsqrt_s_render.asm

📁 ADI SHARC DSP 音频算法标准模块库
💻 ASM
字号:
// Copyright(c) 2005 Analog Devices, Inc. All Rights Reserved.
// This software is proprietary and confidential to Analog Devices, Inc. and its licensors.

// File    : $Id: //depot/development/visualaudio/modules/2.5.0/SHARC/Source/AMF_RSqrt_S_Render.asm#3 $ 
// Part of : VisualAudio V2.5.0 
// Updated : $Date: 2006/10/12 $ by $Author: Fernando $



//    Module Name     : AMF_RSqrt_S.asm 
//    DSP Processor   : ADSP21161
//    Original Author : Tim Stilson, based on code example in Sharc Instruction Set Reference
//    Date               : 1/15/04
//====================================================================================
// Processor resources used:
// 27 words pmem INTERNAL
// 1171 cycles, tickSize=128, (19 + 9*tickSize)
//====================================================================================

//====================================================================================
// Discussion
//
// The math in this module is based on the code snippet in the RSQRT section of the
// 21160 Instruction Set Reference Manual (p 7-45).  The text there notes that if one only
// needs accuracy to +/- 1 LSB at 32-bit accuracy, that one of the successive-approximation
// iterations can be removed.  This module does have the iteration removed, so would
// not directly be a sufficient basis for a 40-bit module, in which case the removed
// iteration would need to be restored.
//
//====================================================================================
 
#if 1
 
#include <processor.h>
#include "AMF_RSqrt_S.h"
#include "asm_sprt.h"

.global    _AMF_RSqrt_S_Render;            ;

.segment /pm SEG_MOD_FAST_CODE;
_AMF_RSqrt_S_Render:

//====================================================================================
    entry;   
    
//module entry arguments passed in registers: 
//  r4  = instance    (AMF_RSqrt_S * restrict)
//  r8  = * buffers (float * restrict)
//  r12 = int tickSize

    puts=mode1;
    r0=i1; puts=r0;

    r2 = r12;                    // ticksize

    m4=2;                        // SIMD loop increment
    
    i4=r8;                        //i4->*buffers
    bit set mode1 PEYEN;        // Enable PEy:SIMD

    i1=dm(0,i4);                // i1=float *in
    i4=dm(1,i4);                // i4=float *out

        f8=3.0;
        f1=0.5;
        f0=dm(i1,m4);                                // get first input
        f4=RSQRTS f0;                                 // fetch 4-bit seed
    LCNTR=r2, DO AMF_RSqrt_S_Render_loop_end UNTIL LCE;
        f12=f4*f4;                                     // f12=X0^2
        f12=f12*f0;                                     // f12=C*X0^2
        f4=f1*f4, f12=f8-f12;                         // f4=.5*X0, f12=3-C*X0^2 } repeat this block
        f4=f4*f12;                                     // f4=X1=.5*X0(3-C*X0^2)  } of instructions to get
        f12=f4*f4;                                     // f12=X1^2               } the full 40-bit accuracy
        f12=f12*f0;                                 // f12=C*X1^2             } as mentioned in the docs
        f4=f1*f4, f12=f8-f12;                         // f4=.5*X1, f12=3-C*X1^2
        f4=f4*f12,              f0=dm(i1,m4);        // f4=X2=.5*X1(3-C*X1^2), get next input
AMF_RSqrt_S_Render_loop_end: 
        f4=RSQRTS f0,           dm(i4,m4)=f4;        // get seed for next iter, write output
        
    bit clr mode1 PEYEN;    // Disable PEy:SIMD
        
//====================================================================================

    i1=gets(1);
    mode1=gets(2);
    alter(2);

    
//------------------------------------------------------------------------------------
_AMF_RSqrt_S_Render.END:
    leaf_exit; // C-rth requires this instead of rts
//------------------------------------------------------------------------------------
.endseg;
#endif    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -