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

📄 az_lsp.asm

📁 基于TMS320F2812的AMR+RS编解码+OFDM调制解调源程序。是stand alone运行版本
💻 ASM
字号:
*****************************************************************************
** Description:     Az_lsp() in az_lpc.c                                   **
**                                                                         **
** Inputs                                                                  **
**                                                                         **
**   xar5---Word16 a[]                                                     **
**   xar3---Word16 lsp[]                                                   **
**   xar4---Word16 old_lsp[]                                               **
**                                                                         **
** Outputs:                                                                **
**                                                                         **
** Return value :                                                          **
**                                                                         **
** Attribute    :       Cycles:64742         Pm: 176                       **
**                      Modified Registers:  acc,p,t,ar0,ar1,xar3-7        **
**                                                                         **
** Programmer   :       YANG zhiwei                                        **
*****************************************************************************
			.global	_Az_lsp
			
			.ref	grid
			.ref	M
			.ref	NC
			.ref	grid_points
			.ref	_buffer2
			.ref	_buffer3
			.ref	_buffer1
			.ref	_Chebps
			.ref    _div_s
			
			
nf		.set	_buffer3
ip		.set	_buffer3+1			
xlow	.set	_buffer3+2			
ylow	.set	_buffer3+3
xhigh	.set	_buffer3+4
yhigh	.set	_buffer3+5
xmid	.set	_buffer3+6			
ymid	.set	_buffer3+7
xint	.set	_buffer3+8
x		.set	_buffer3+9
y		.set	_buffer3+10
sign	.set	_buffer3+11
exp 	.set	_buffer3+12
t_lsp	.set	_buffer3+14
t_old_lsp .set	_buffer3+16
;f1	 	.set	_buffer2
;f2	 	.set	_buffer2+20
							
_Az_lsp:	
		movl    @t_lsp,xar3		           ;store address of lsp
		movl	@t_old_lsp,xar4	    	   ;store address of old_lsp	

		movl	xar6,#_buffer2			   ;xar6 point to f1
		movl	xar7,#_buffer2+20		   ;xar7 point to f2

		mov		*xar6,#1024
		mov		*xar7,#1024				   ;f1[0] = f2[0] = 1024
		
		mov		ar0,#1						;ar0 = i + 1
		mov		ar2,#NC-1
_loop_148:
		mov		al,#M+1
		sub		al,ar0
		mov		ar1,al						;ar1 = M - i
		
		mpy		p,*+xar5[ar0],#8192	
		movl    acc,  p
		lsl		acc,#1						;L_mult (a[i + 1], 8192)
		push	acc							;store L_mult (a[i + 1], 8192)
	
		mpy		p,*+xar5[ar1],#8192			
		addl	acc,p<<Pm					;L_mac (t0, a[M - i], 8192)
		
		dec		ar0							;ar0 = i
		sub		ah,*+xar6[ar0]				;sub (x, f1[i])
		inc		ar0							;ar0 = i + 1
		mov		*+xar6[ar0],ah				;f1[i + 1] = sub (x, f1[i])	
		
		pop		acc							;restore L_mult (a[i + 1], 8192)
		mpy		p,*+xar5[ar1],#8192	
		subl	acc,p<<pm  					;L_msu (t0, a[M - i], 8192)											
		
		dec		ar0							;ar0 = i
		mov		@x,ah						;x
		add		ah,*+xar7[ar0]				;add (x, f2[i])
		inc		ar0							;ar0 = i + 1
		mov		*+xar7[ar0],ah				;f2[i + 1] = add (x, f2[i])	
		
		inc		ar0							;i++
		banz	_loop_148,ar2--		
		
		mov		@nf,#0
		mov		@ip,#0						;nf = ip = 0
		
		movl	xar2,#_buffer2				;coef = f1
		
		movl	xar1,#grid
		mov		al,*xar1
		mov		@xlow,al					;xlow = grid[0]
	
		mov		ar6,@xlow
		mov		ar7,#NC
		lcr		_Chebps
		mov		@ylow,ah					;ylow = Chebps (xlow, coef, NC)
		
		mov		ar1,#0						;j = 0
_loop_178:		
		mov		al,@nf
		sub		al,#M
		bf		_line_270,geq				;if ( nf >= M ) then jump to _line_270
		
		mov		al,ar1
		sub		al,#grid_points
		bf		_line_270,geq				;if ( j >= grid_points ) then jump to _line_270
		
		inc		ar1							;j++
	
		mov		al,@xlow
		mov		@xhigh,al					;xhigh = xlow
		mov		al,@ylow
		mov		@yhigh,al					;yhigh = ylow
		
		movl	xar5,#grid
		mov		al,*+xar5[ar1]
		mov		@xlow,al					;xlow = grid[j]
		
		mov		ar6,@xlow
		mov		ar7,#NC
		push	ar1							;store j
		lcr		_Chebps
		pop		ar1
		mov		@ylow,ah					;ylow = Chebps (xlow, coef, NC)
		
		mov		t,@ylow
		mpy		acc,t,@yhigh
	    sbf		_end,eq						;if (acc = 0),jump to _end
	    bf		_orig_pos,gt				;if (acc > 0),jump to _orig_pos
	   	lsl		acc,#1						;else,acc < 0,negative
		bf	    _end,lt						;if the result < 0,jump to _end
        movb	al,#0
		mov		ah,#0x8000
		bf		_end,unc
_orig_pos:
        lsl		acc,#1								
        bf		_end,gt					    ;if the result > 0,sign not changed
        mov		al,#0xffff
        mov		ah,#0x7fff
_end:
		bf		_loop_178,gt				;if ( L_mult (ylow, yhigh) > (Word32) 0L ) then jump to _loop_178
		
		mov		ar0,#4-1					;4 loops
_loop_193:	
		mov		al,@xlow					
		asr		al,#1						;al = shr(xlow,1)
		mov		ah,@xhigh	
		asr		ah,#1						;ah = shr(xhigh,1)
		add		ah,al
		mov		@xmid,ah					;xmid = add (shr (xlow, 1), shr (xhigh, 1))
		
		mov		ar6,@xmid
		mov		ar7,#NC	
		push	ar0							;store i
		push	ar1							;store j
		lcr		_Chebps
		pop		ar1
		pop		ar0							;restore i
		mov     @ymid,ah					;ymid = Chebps (xmid, coef, NC)
		
		mov		t,@ylow
		mpy		acc,t,@ymid
		lsl		acc,1
		bf		_line_206,gt				;if ( L_mult (ylow, ymid) > (Word32) 0L ) then jump to _line_206
		mov		al,@ymid
		mov		@yhigh,al					;yhigh = ymid
		mov		al,@xmid
		mov		@xhigh,al					;xhigh = xmid
		bf		_line_211,unc				;jump to _line_211	
_line_206:
		mov		al,@ymid					
		mov		@ylow,al					;ylow = ymid
		mov		al,@xmid
		mov		@xlow,al					;xlow = xmid
_line_211:
		banz    _loop_193,ar0--				;if(i > 0)then jump to _loop_193
		
		mov		al,@xlow
		mov		ah,@xhigh
		sub		ah,al
		mov		@x,ah						;x = sub (xhigh, xlow)
		mov		al,@ylow
		mov		ah,@yhigh
		sub		ah,al
		mov		@y,ah						;;y = sub (yhigh, ylow)
		
		cmp		ah,#0						;set flags by  ( y - 0 )
		bf		_line_226,neq				;if ( y <> 0 ) then jump to _line_226]
		mov		al,@xlow
		mov		@xint,al					;xint = xlow
		bf		_line_246,unc				;jump to _line_246
_line_226:
		mov		acc,@y
		mov		@sign,al					;sign = y
		abs		acc							;acc = abs_s(y)
		csb		acc							;t = norm(acc)
		sub		t,#16
		mov		@exp,t
		lsl		al,t						;al = shl (y, exp)
		push	ar1							;store j
		push	ar2							;store xar2
		mov		ar1,#16383
		mov		ar2,al
		lcr		_div_s						;al = div_s ((Word16) 16383, y)
		pop		ar2
		pop		ar1							;restore j
		
		mov		t,al
		mpy		acc,t,@x
		lsl		acc,#1                      ;L_mult (x, y)
		mov		ar7,al
		mov		al,#20
		sub		al,@exp						;t = sub (exp , 20)
		mov		t,al
		mov		al,ar7
	
		asrl	acc,t						;L_shr (t0, sub (20, exp))
		mov		@y,al
		
		mov		ah,@sign
		cmp		ah,#0
		bf		_line_241,geq				;if (sign > 0) then jump to _line_241
		mov		al,@y
		neg		al
		mov		@y,al						;y = negate( y )
_line_241:
		mov		t,@y						;t = y
		mpy		acc,t,@ylow
		lsl		acc,#1						;L_mult (ylow, y)
		
		mov		t,#11
		;mov		t,#10
		asrl	acc,t						;t0 = L_shr (t0, 11)
		
		mov		ah,@xlow
		sub		ah,al
		mov		@xint,ah					;xint = sub (xlow, extract_l (t0))
_line_246:
		movl 	xar3,@t_lsp				    ;restore address of lsp
		mov		ah,@nf
		mov		ar0,ah
		mov		al,@xint
		mov		*+xar3[ar0],al				;lsp[nf] = xint
		mov		@xlow,al					;xlow = xint
		add		@nf,#1						;nf++
		
		mov		al,@ip
		cmp		al,#0
		bf		_line_256,neq				;if ( ip <> 0 ) then jump to _line_256
		mov		@ip,#1						;else ,ip = 1
		movl	xar2,#_buffer2+20					;coef = f2
		bf		_line_261,unc				;jump to _line_261
_line_256:
		mov		@ip,#0
		movl	xar2,#_buffer2				;ip = 0,coef = f1
_line_261:
		mov		ar6,@xlow
		mov		ar7,#NC
		push	ar1							;store j
		lcr		_Chebps
		pop		ar1							;restore j
		mov		@ylow,ah
		bf		_loop_178,unc				;jump to _loop_178
_line_270:		 
		mov		al,@nf
		sub		al,#M
		bf		_line_278,geq				;if ( nf >= M ) then jump to _line_278
		movl	xar3,@t_lsp		 			;xar3 point to lsp
		movl	xar4,@t_old_lsp 			;xar4 point to old_lsp]
		mov		ar1,#M-1
_loop_272:
		mov		al,*xar4++					
		mov		*xar3++,al					;lsp[i] = old_lsp[i]
		banz	_loop_272,ar1--	
_line_278:
		lretr                         

⌨️ 快捷键说明

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