Guest User

Untitled

a guest
Jul 17th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. .data
  2. fn_2: .word 0
  3. fn_1: .word 1
  4. fn: .word 0
  5. n: .word 0
  6. spaceInsert: .asciiz " "
  7. prompt: .asciiz "Please enter a positive integer: "
  8. test: .asciiz "testing..."
  9.  
  10.  
  11. .text
  12. .globl main
  13. main:
  14. li $v0, 4 # load instructions to output a string
  15. la $a0, prompt # prompt for n
  16. syscall
  17.  
  18. li $v0, 5 # load instructions to read an int
  19. la $a0, n # read in n
  20. syscall
  21.  
  22. lw $t0, n # st0re n into $t0
  23. lw $s0, fn_2 # store fn_2 into register $s0
  24. lw $s1, fn_1 # store fn_1 into register $s1
  25. lw $s2, fn # store fn into $s0
  26. add $t1, $zero, 1 # this is the counter, i
  27.  
  28. LOOP: add $s2, $s1, $s0
  29.  
  30. li $v0, 4 # load instructions to output a string
  31. la $a0, spaceInsert # output space
  32. syscall
  33.  
  34. li $v0, 1 # load instructions to output an int
  35. move $a0, $s2 # output fn
  36. syscall
  37.  
  38. move $s0, $s1 # fn_2 = fn_1
  39. move $s1, $s2 # fn_1 = fn
  40.  
  41. add $t1, $t1, 1 # i++
  42. bne $t1, $t0, LOOP
  43.  
  44. Exit:
  45. li $v0, 10
  46. syscall
Add Comment
Please, Sign In to add comment