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

📄 mysinlongok.asm

📁 利用泰勒公式计算32位数的正余弦值
💻 ASM
字号:
	.title	"sinx.asm"
	.mmregs
	.def 	main

	.def	squr_theta,theta_temp,coeff_1,sinh,sinl
			
			.bss	theta,2,1,2
			.bss	squr_theta,2,1,2
			.bss	theta_temp,2,1,2
			.bss	sin_theta,2,1,2
			.bss	coeff_1,2,1,2
			.bss	sin_x1,2,1,2


			.data
table:		.long	38e3h
			.long	6186h
			.long	0cccch
			.long	02aaaah



coef_s		.usect	"sin_vars",8
sinh		.usect	"sin_vars",1
sinl		.usect	"sin_vars",1
	
sin_x		.usect	"sin_x",90
stack:		.usect	"stack",30

	.text
main:
	STM     #0028h ,PMST				    
	NOP								   
	NOP  
	STM     #7FFFh,SWWSR 
	NOP
	NOP					
	STM     #0000h ,BSCR 	
	NOP
	NOP						     
	STM     #0000h,ST0  
	NOP
	NOP                 	   ;对CPU工作状态寄存器初始化
	STM     #2800h,ST1 
	NOP
	NOP
	STM     #0000h,CLKMD
	NOP
	NOP 
CLKOK:
	LDM		CLKMD,A
	AND		#01b,A
	BC		CLKOK,ANEQ
	NOP
	NOP                                   	 	        		        		        
	STM     #40C7h,CLKMD
	NOP
	NOP
	NOP

	STM		#stack+10,SP
	STM		#sin_x,AR0
	LD		#theta,DP

	LD		#0h,16,A
	ADD		#00h,A

	STM		#coeff_1,AR3
	ST		#010h,*AR3+
	ST		#000h,*AR3

	STM		#coef_s,AR5
	RPT		#7
	MVPD	#table,*AR5+

	STM		#90,BRC
	RPTB	end-1
	DST		A,theta


	STM		#theta+1,AR4
	LD		*AR2,T
	MPYU	*AR4-,A
	LD		A,-16,A
	MACSU	*AR2-,*AR4+,A
	MACSU	*AR4-,*AR2,A
	DST		A,theta_temp
	MPY		*AR2,*AR4,A
	LD		A,8,A
	LD		A,8,A
	DADD	theta_temp,A
	DST		A,squr_theta			;x^2=theta^2


	STM		#squr_theta+1,AR4		;AR4 to squr theta
	STM		#coef_s+1,AR3
	LD		*AR4,T
	MPYU	*AR3-,A
	LD		A,-16,A
	MACSU	*AR3+,*AR4-,A
	MACSU	*AR3-,*AR4,A
	DST		A,theta_temp
	MPY		*AR3,*AR4,A
	LD		A,8,A
	LD		A,8,A
	DADD	theta_temp,A
	DST		A,theta_temp	;x^2/72

	STM		#coeff_1,AR3		
	LD		*AR3+,16,B
	ADD		*AR3,B
	LD		A,-8,A
	SUB		A,B
	DST		B,theta_temp		;1-x^2/72

	STM 	#theta_temp+1,AR3
	STM		#squr_theta+1,AR4
	LD		*AR4-,T
	MPYU	*AR3-,A
	LD		A,-16,A
	DST		A,sin_x1
	MPYU	*AR3+,A
	DADD	sin_x1,A
	DST		A,sin_x1
	LD		*AR4,T
	MPYU	*AR3-,A
	DADD	sin_x1,A
	LD		A,-8,A
	DST		A,theta_temp
	MPY		*AR3,*AR4,A
	LD		A,8,A
	DADD	theta_temp,A
	DST		A,theta_temp		;x^2(1-x^2/72)	

	STM		#theta_temp+1,AR3
	STM		#coef_s+3,AR4
	LD		*AR4,T
	MPYU	*AR3-,A
	LD		A,-16,A
	MACSU	*AR3+,*AR4,A
	DST		A,theta_temp		;x^2/42 (1-x^2/72)	
	
	STM		#coeff_1,AR3				
	LD		*AR3+,16,B
	ADD		*AR3,B
	SUB		A,B					;1-x^2/42 (1-x^2/72)
	DST		B,theta_temp

	STM 	#theta_temp+1,AR3
	STM		#squr_theta+1,AR4
	LD		*AR4-,T
	MPYU	*AR3-,A
	LD		A,-16,A
	DST		A,sin_x1
	MPYU	*AR3+,A
	DADD	sin_x1,A
	DST		A,sin_x1
	LD		*AR4,T
	MPYU	*AR3-,A
	DADD	sin_x1,A
	LD		A,-8,A
	DST		A,theta_temp
	MPY		*AR2,*AR4,A
	LD		A,8,A
	DADD	theta_temp,A
	LD		A,-1,A
	DST		A,theta_temp	;x^2(1-x^2/42 (1-x^2/72))

	STM		#theta_temp+1,AR3
	STM		#coef_s+5,AR4
	LD		*AR4,T
	MPYU	*AR3-,A
	LD		A,-16,A
	DST		A,sin_x1
	MPYU	*AR3,A
	DADD	sin_x1,A
	DST		A,theta_temp	;x^2/20 (1-x^2/42 (1-x^2/72))	

	STM		#coeff_1,AR3				
	LD		*AR3+,16,B
	ADD		*AR3,B
	SUB		A,-4,B			;1-x^2/20 (1-x^2/42 (1-x^2/72))
	DST		B,theta_temp

	STM 	#theta_temp+1,AR3
	STM		#squr_theta+1,AR4
	LD		*AR4-,T
	MPYU	*AR3-,A
	LD		A,-16,A
	DST		A,sin_x1
	MPYU	*AR3+,A
	DADD	sin_x1,A
	DST		A,sin_x1
	LD		*AR4,T
	MPYU	*AR3-,A
	DADD	sin_x1,A
	LD		A,-8,A
	DST		A,sin_x1
	MPY		*AR3,*AR4,A
	LD		A,8,A
	DADD	sin_x1,A
	DST		A,theta_temp	;x^2(1-x^2/20 (1-x^2/42 (1-x^2/72)))

	STM		#theta_temp+1,AR3
	STM		#coef_s+7,AR4
	LD		*AR4-,T
	MPYU	*AR3-,A
	LD		A,-16,A
	DST		A,sin_x1
	MPYU	*AR3+,A
	DADD	sin_x1,A
	DST		A,sin_x1
	LD		*AR4,T
	MPYU	*AR3-,A
	DADD	sin_x1,A
	LD		A,-4,A
	DST		A,sin_x1
	MPY		*AR3,*AR4,A
	LD		A,12,A
	DADD	sin_x1,A
	DST		A,theta_temp	;x^2/6 (1-x^2/20 (1-x^2/42 (1-x^2/72)))	

	STM		#coeff_1,AR3				
	LD		*AR3+,16,B
	ADD		*AR3,B
	SUB		A,B				;1-x^2/6 (1-x^2/20 (1-x^2/42 (1-x^2/72))))
	DST		B,theta_temp

	STM		#theta_temp+1,AR3
	STM		#theta+1,AR4
	LD		*AR4-,T
	MPYU	*AR3-,A
	LD		A,-16,A
	DST		A,sin_x1
	MPYU	*AR3+,A
	DADD	sin_x1,A
	DST		A,sin_x1
	LD		*AR4,T
	MPYU	*AR3-,A
	DADD	sin_x1,A
	LD		A,-4,A
	DST		A,sin_x1
	MPY		*AR3,*AR4,A
	LD		A,12,A
	DADD	sin_x1,A
	LD		A,-8,A
	STL		A,*AR0+		;x(1-x^2/6 (1-x^2/20 (1-x^2/42 (1-x^2/72))))

	STM		#theta,AR2
	LD		*AR2+,16,A
	ADD		*AR2,A
	ADD		#0477Dh,A
end:		B		end
			.end

⌨️ 快捷键说明

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