📄 amf_sqrt_render.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_Sqrt_Render.asm#3 $
// Part of : VisualAudio V2.5.0
// Updated : $Date: 2006/10/12 $ by $Author: Fernando $
// Module Name : AMF_Sqrt.asm
// DSP Processor : ADSP21161
// Original Author : Tim Stilson, based on code example in Sharc Instruction Set Reference
// Date : 1/15/04
//====================================================================================
// Processor resources used:
// 28 words pmem INTERNAL
// 659 cycles, tickSize=128, (19 + 10*(tickSize/2))
//====================================================================================
//====================================================================================
// 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_Sqrt.h"
#include "asm_sprt.h"
.global _AMF_Sqrt_Render; ;
.segment /pm SEG_MOD_FAST_CODE;
_AMF_Sqrt_Render:
//====================================================================================
entry;
//module entry arguments passed in registers:
// r4 = instance (AMF_Sqrt * restrict)
// r8 = * buffers (float * restrict)
// r12 = int tickSize
puts=mode1;
r0=i1; puts=r0;
r2 = lshift r12 by -1; // ticksize/2 (SIMD in time dimension)
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_Sqrt_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; // f4=X2=.5*X1(3-C*X1^2), this is 1/sqrt(in)
f4=f0*f4, f0=dm(i1,m4); // f4=in*f4=sqrt(in), get next input
AMF_Sqrt_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_Sqrt_Render.END:
leaf_exit; // C-rth requires this instead of rts
//------------------------------------------------------------------------------------
.endseg;
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -