Advertisement
ChrisH41

Untitled

Mar 10th, 2023
1,034
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. arcSin:
  2.    
  3.     # **We will expand a power series to n = 10 given X** #
  4.    
  5.     # Initialize vars.
  6.     la $t0, ($a0) # Sum = X
  7.     mtc1 $t0, $f0 # Actual SUm
  8.     mtc1 $t0, $f1 # Temp sum
  9.     mtc1 $t0, $f11 # constant X
  10.    
  11.     li $t1, 3 # power
  12.     li $t2, 1 # counter
  13.     li $t3, 6
  14.     mtc1 $t3, $f2 # divisor
  15.     cvt.s.w $f2, $f2 # NEEDED to divide correctly
  16.    
  17.     loop: beq $t1, $t2, p3
  18.         addi $t2, $t2, 1 # Increment counter
  19.         mul.s $f1, $f1, $f11 # sux * x
  20.         j loop
  21.        
  22.     loop2: beq $t1, $t2, endLoops
  23.         addi $t2, $t2, 1 # Increment counter
  24.         mul.s $f1, $f1, $f11 # sux * x
  25.         j loop2
  26.    
  27.     p3:
  28.         div.s $f1, $f1, $f2 # tempSum / 6
  29.         add.s $f0, $f0, $f1 # sum += tempSum
  30.         mov.s $f1, $f11 # reset tempSu
  31.         li $t1, 5 # change the power to 5
  32.         li $t2, 1 # resset counter
  33.         j loop2
  34.     endLoops:
  35.         li $t3, 40
  36.         mtc1 $t3, $f2 # divisor
  37.         cvt.s.w $f2, $f2 # NEEDED to divide correctly
  38.         div.s $f1, $f1, $f2 # tempSum / 4
  39.         add.s $f0, $f0, $f1 # sum += tempSum
  40.         mfc1 $a0, $f0 # radian version
  41.         lwc1 $f1, pi
  42.         li $t3, 180   # 180 degrees
  43.         mtc1 $t3, $f2
  44.         cvt.s.w $f2, $f2
  45.         mul.s $f0, $f0, $f2
  46.         div.s $f0, $f0, $f1
  47.        
  48.    
  49.    
  50.    
  51.    
  52.     la $a0 , angleTraj
  53.     li $v0 , 4
  54.     syscall
  55.    
  56.     mov.s $f12, $f0 # return summation 
  57.    
  58.     li $v0, 2
  59.     syscall
  60.    
  61.     mfc1 $s1, $f12
  62.    
  63.     la $a0 , newLine
  64.     li $v0 , 4
  65.     syscall
  66.    
  67.     jr $ra
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement