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

📄 example 2-19.asm

📁 《基于TI DSP的通用算法实现》程序代码
💻 ASM
字号:

;Example 2 - 19. Fixed-Point Exponential Operation ASM Listing for C54x

;================================================================
; This routine is used to calculate the exponential of an input
; which is given by log in Q11 format. The integer part should be
; less than 10 according to MP3 algorithm. Programmer should be
; responsible for make sure DP is pointed to the data page of N and 
;       X.
; Input: AL = fraction part in Q11 and MSB 5bits are integer part, 
;       AH = 0
; Output: AL = integer, AH = 0
; Register used: B, T, AR0, AR3
; Memory: 30 words
;================================================================

	.mmregs
	.def exp

	.data
exptbl	.int 1, 3, 7, 20, 55, 148, 403, 1097, 2981, 8103, 22026, 0
					; exptbl is generated by equation en. 
					; n starts from 0 to 10.

a9	.int 1, 7, 46, 273, 1365, 5461, 16384, 32767, 0, 0
					; a9 is in Q15 format. It is generated by
					; equation 32768/n!. 
					; n starts from 8 down to 1 in order to take
					; advantage of instruction POLY.

	.bss N, 1			; N stores scaling number
	.bss X, 1			; X is temporary storage. Must
					; be at the same data page of N.

	.text

exp:
	ADD	#0, A, B		; B=A=Y
	AND	#400h, B		; Check if it is larger than 0.5
	BCD	adj, BNEQ		; Yes, then need adjustment
	ADD	#400h, A, B
	STL	B, –11, N		; store scaling index
	AND	#3FFh, B		; truncate fractional part
	STL	B, 4, X			; store fractional part in Q15 format
	B	taylor

adj:
	STL	B, –11, N		; store scaling index
	AND	#7FFh, B		; truncate fractional part
	SUB	#400h, B
	STL	B, 4, X			; store negative fraction in Q15 format

taylor:
	STM	a9, AR3			 AR3 points to coefficient in Taylor’s equ.
	LD	X, T 			; set up running environment using
	LD	*AR3+, 16, A		; powerful poly instruction on c54x DSP
	LD	*AR3+, 16, B		;

	RPT	#7			; loop 8 times enough for audio app.
	POLY	*AR3+ 			; AH=fractional part in Q15 format

	ADD	#7FFFh, 16, A		; taylor equ. has 1 constant
	MVDM	N, AR0 			; index into exptbl
	STM	exptbl, AR3
	MAR	*AR3+0
	MPYA	*AR3			; multiply the scaling part
	SFTA	B, –16, A		; AL=BH
	
	RET

	.end

⌨️ 快捷键说明

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