All pastes #496856 Raw Edit

Someone

public text v1 · immutable
·published 2007-05-19 14:12 UTC
rendered paste body
.data

A: .float 1.
constPi: .float 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
const0: .double 0.
const1: .double 1.
const6: .double 6. 		#2 * 3
const20: .double 20.		#4 * 5
const42: .double 42.		#6 * 7
const72: .double 72.		#8 * 9
const110: .double 110.		#10*11
const156: .double 156.		#12*13
const210: .double 210.		#14*15
const272: .double 272.		#16*17
const342: .double 342. 		#18*19
const420: .double 420.		#20*21

.text
main:
	l.s $f12, constPi
	jal sinus
	l.s $f2, const0
	add.s $f12, $f0, $f2
	li $v0, 2
	syscall
	li $v0, 10
	syscall



#calc the sin(f12) by using the first 21 terms of the taylorseries (using horner)
sinus:
	cvt.d.s $f12, $f12		#casten auf double
	mul.d $f2, $f12, $f12		#berechne x^2
	l.d $f4, const1			#lade konstante = 1

	l.d $f6, const420
	div.d $f8, $f2, $f6		#innerste klammer(1-x^2/420)
	sub.d $f0, $f4, $f8

	l.d $f6, const342
	div.d $f8, $f2, $f6		#berechne x^2/342
	mul.d $f0, $f0, $f8		#x^2/342*(1-x^2/420)
	sub.d $f0, $f4, $f0		#1-x^2/342*(1-x^2/420)

	l.d $f6, const272
	div.d $f8, $f2, $f6		
	mul.d $f0, $f0, $f8
	sub.d $f0, $f4, $f0		#1-x^2/272*(1-x^2/342*(1-x^2/420))

	l.d $f6, const210
	div.d $f8, $f2, $f6		
	mul.d $f0, $f0, $f8
	sub.d $f0, $f4, $f0		#1-x^2/210*(1-x^2/272*(1-x^2/342*(1-x^2/420)))

	l.d $f6, const156
	div.d $f8, $f2, $f6		
	mul.d $f0, $f0, $f8
	sub.d $f0, $f4, $f0		#1-x^2/156*(1-x^2/210*(1-x^2/272*(1-x^2/342*(1-x^2/420))))

	l.d $f6, const110
	div.d $f8, $f2, $f6		
	mul.d $f0, $f0, $f8
	sub.d $f0, $f4, $f0		#1-x^2/110*(1-x^2/156*(1-x^2/210*(1-x^2/272*(1-x^2/342*(1-x^2/420)))))

	l.d $f6, const72
	div.d $f8, $f2, $f6		
	mul.d $f0, $f0, $f8
	sub.d $f0, $f4, $f0		#1-x^2/72*(1-x^2/110*(1-x^2/156*(1-x^2/210*(1-x^2/272*(1-x^2/342*(1-x^2/420))))))

	l.d $f6, const42
	div.d $f8, $f2, $f6		
	mul.d $f0, $f0, $f8
	sub.d $f0, $f4, $f0		#1-x^2/42*(1-x^2/72*(1-x^2/110*(1-x^2/156*(1-x^2/210*(1-x^2/272*(1-x^2/342*(1-x^2/420)))))))

	l.d $f6, const20
	div.d $f8, $f2, $f6		
	mul.d $f0, $f0, $f8
	sub.d $f0, $f4, $f0		#1-x^2/20*(1-x^2/42*(1-x^2/72*(1-x^2/110*(1-x^2/156*(1-x^2/210*(1-x^2/272*(1-x^2/342*(1-x^2/420))))))))

	l.d $f6, const6			
	div.d $f8, $f2, $f6		
	mul.d $f0, $f0, $f8
	sub.d $f0, $f4, $f0		#1-x^2/6*(1-x^2/20*(1-x^2/42*(1-x^2/72*(1-x^2/110*(1-x^2/156*(1-x^2/210*(1-x^2/272*(1-x^2/342*(1-x^2/420)))))))))

	mul.d $f0, $f12, $f0		#x*(1-x^2/6*(1-x^2/20*(1-x^2/42*(1-x^2/72*(1-x^2/110*(1-x^2/156*(1-x^2/210*(1-x^2/272*(1-x^2/342*(1-x^2/420))))))))))
	cvt.s.d $f0, $f0		#casten auf single
	jr $ra