cos_sin.asm

来自「Practical DSP Applications in Communicat」· 汇编 代码 · 共 32 行

ASM
32
字号
;
;   cos_sin.asm - table lookup cosine-sine generator
;                 use 1024 points cosine table range(0-PI)
;	                                        
;   Prototype: void cos_sin(int, int *, int *)
;	
;   Entry: arg0: T0 - alpha
;          arg1: AR0 - pinter to cosine
;          arg2: AR1 - pointer to sine

	.def  _cos_sin 
	
	.ref  tab_0_PI

	.sect "cos_sin"		
_cos_sin     
    mov   T0,AC0            ; T0=a
    sfts  AC0,#11           ; Size index for table lookup
    mov   #tab_0_PI,T0      ; Table based address
||  mov   hi(AC0),AR2
    mov   AR2,AR3
    abs   AR2               ; cos(-a) = cos(a)   
    add   #0x200,AR3        ; 90 degree offset for sine
    and   #0x7ff,AR3        ; Modulo 0x800 for 11-bit
    sub   #0x400,AR3        ; Offset 180 degree for sine
    abs   AR3               ; sin(-a) = sin(a)
||  mov   *AR2(T0),*AR0     ; *AR0=cos(a) 
    mov   *AR3(T0),*AR1     ; *AR1=sin(a)
    ret

    .end

⌨️ 快捷键说明

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