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

📄 sin.asm

📁 包含几个高效的矢量运算的数学函数
💻 ASM
字号:
M .set 9 ; Sine table size log2

	.include "ccall.asm"                  
	.ref _SineTable                  
	.def	_ti_sin
_ti_sin:
	pre_ccall 3,AR_X,AR_Y,AR_N

;STACK CONTENTS:
; 1 = sin_Index / sin_Ynext / sin_Ydiff
; 2 = sin_Frac
; 3 = 
	; Modify any registers needed
	spm	1		; MUST Set Product shift to +1
	clrc	SXM		; MUST Set Sign Extension Mode Off
	; Note: Overflow mode is off in C.
; End C Preprocessing

; Subtract one from N and check for N=0
	mar *,AR_N
	banz LOOP,AR_X
	b DONE

;	ldp	#sin_X		
;	lacc	sin_X,8		; Index = integer(X + Phase)
LOOP:
	lacc *+,M-1,AR_STACK
	        
;;;	add	sin_Phase,8	;;; UNUSED

;	sach sin_Index	
;   sacl sin_Frac
	sach *+,1
	and #07fffh ; Zero sign bit
	sacl *-

;	lacc	sin_Index	; Y = SinTable[Index], 
	lacc *,AR_Y
	add #_SineTable	
;	tblr sin_Y
	tblr *,AR_STACK
	add	#1
;	tblr sin_Ynext	; Ynext = SinTable[Index+1],
	tblr *

;	lacc sin_Ynext	; Ydiff = Ynext - Y
	lacc *,AR_Y
;	sub	sin_Y
	sub *,AR_STACK
;	sacl sin_Ydiff
	sacl *

;	lt sin_Ydiff	; Y = round(Y + Ydiff*Frac)
	lt *+
;	mpy	sin_Frac
	mpy *-,AR_Y
;	zalr sin_Y
	zalr *
	apac
;	sach sin_Y	
	sach *+,AR_N
	banz LOOP,AR_X

; Begin C Post Processing
DONE:
	; Restore any other registers modified
	; Note: Overflow mode is off in C.
	spm	0
	post_ccall 3

⌨️ 快捷键说明

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