📄 expn.asm
字号:
;***********************************************************
; Version 2.20.01
;***********************************************************
;****************************************************************************
; Function: expn
; Description: exponent vector evaluation via polynomial approximation
;
; Copyright Texas instruments Inc, 1998
;----------------------------------------------------------------------------
; Revision History:
; 1.00, A. Aboagye, 8/31/98 - Original release. Started from sine code
; 2.00 - Li Yuan, 4/09/02. fixed overflow flag setup at the end of code.
;
;********************************************************************************
.mmregs
;*****************************************************
; Table containing the coefficients for the polynomial
.data
coef: ; hex values values in q4.12
.word 0x0039 ;0.0139 (coef for x^5 = c5)
.word 0x008f ;0.0348 (coef for x^4 = c4)
.word 0x02ba ;0.1705 (coef for x^3 = c3)
.word 0x07fc ;0.4990 (coef for x^2 = c2)
.word 0x1000 ;1.0001 (coef for x^1 = c1)
.word 0x1000 ;1.0000 (coef for x^0 = c0)
; Far-mode adjustment
.if __far_mode
offset .set 1 ; far mode uses one extra location for ret addr ll
.else
offset .set 0
.endif
.asg (2), ret_addr ; stack description
; x in A
.asg (3 + offset), arg_y
.asg (4 + offset), arg_n
; register usage
.asg ar0, ar_y ; pointer to output vector
.asg ar2, ar_x ; pointer to input vector
.asg ar3, ar_coef ; pointer to coef table
.asg ar4, ar_coefsave ; save coef table address
;****************************************************************
.global _expn
.text
_expn:
PSHM ST0 ; 1 cycle
PSHM ST1 ; 1 cycle
RSBX OVA ; 1 cycle
RSBX OVB ; 1 cycle
; Get arguments and set modes
; ---------------------------
ssbx frct ; set frct ON (1)
ssbx ovm ; why saturate? no guard bits adv? (1)
ssbx sxm ; (1)
ld *sp(arg_n),b ; b = n (1)
sub #1,b ; b = n-1 (2)
stlm b,brc ; brc = n-1 (1)
st #coef, *(ar_coefsave) ; pointer to coef table (2)
stlm a, ar_x ; pointer to array x (1)
rptbd eloop-1 ; repeat n times (2)
mvdk *sp(arg_y),*(ar_y) ; pointer to array y (2)
ld *ar_x+,a ; al = x (sign-extended) (1)
mvmm ar_coefsave,ar_coef ; initialize ar_coef to beg of table (1)
; Start polynomial evaluation
; ---------------------------
stlm a,t ; t = al = x (1)
ld *ar_coef+,16,a ; ah = c5; point to c4 (1)
ld *ar_coef+,16,b ; bh = c4; point to c3 (1)
poly *ar_coef+ ; a = ah*t + b (1)
; = c5*x + c4
; bh = c3 point to c2
poly *ar_coef+ ; a = ah*t + b (1)
; = (c5*x + c4)*x + c3
; = c5*x^2 + c4*x + c3
; bh = c2 point to c1
poly *ar_coef+ ; a = ah*t + b (1)
; = (c5*x^2+c4*x+c3)*x + c2
; = c5*x^3+c4*x^2+c3*x + c2
; bh = c1 point to c0
poly *ar_coef+ ; a = ah*t + b (1)
; = (c5*x^3+c4*x^2+c3*x + c2)*x + c1
; = c5*x^4+c4*x^3+c3*x^2+c2*x +c1
; bh = c0 point to c(-1)
maca t,b,a ; a = ah*t + b (1)
; = (c5*x^4+c4*x^3+c3*x^2 + c2*x+c1)*x + c0
; = c5*x^5+c4*x^4+c3*x^3+c2*x^2 +c1*x + c0
sth a,*ar_y+ ; store q4.12 output
eloop
; Return overflow flag
; --------------------
ld #0,a ; (1)
xc 1,AOV ; BOV (1)
ld #1,a ; (1)
POPM ST1 ; 1 cycle
POPM ST0 ; 1 cycle
.if __far_mode
fretd ; (6)
.else
retd ; (6)
.endif
nop
nop
;end of file. please do not remove. it is left here to ensure that no lines of code are removed by any editor
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -