Advertisement
kolyaventuri

Untitled

Nov 24th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. # Prints the triangle
  2. #
  3. # 1
  4. # 22
  5. # 333
  6. # 4444
  7. # 55555
  8.  
  9. .text
  10.  
  11. main:
  12. li $s0, 0 # Starting variable i = 0
  13. li $s1, 6 # Ending variable j = 6
  14. j loop
  15.  
  16. loop:
  17. addi $s0, $s0, 1 # i += 1
  18. beq $s0, $s1, eof # If end of loop, exit
  19. j printint # Go print the variable
  20.  
  21. printint:
  22. li $v0, 1 # Print integer instruction
  23. li $s3, 0 # Inner loop helper k = 0
  24.  
  25. loopstart:
  26. move $a0, $s0 # Move the current integer into the target register
  27. syscall
  28. j innerloop
  29.  
  30. innerloop:
  31. addi $s3, $s3, 1 # k + =1
  32. beq $s3, $s0, endloop
  33. j loopstart
  34.  
  35. endloop:
  36. addi $a0, $0, 0xA # New line character
  37. addi $v0, $0, 0xB # Print lower 8 bits of $a0
  38. syscall
  39.  
  40. j loop # Keep going
  41.  
  42. eof:
  43. # Kill the program
  44. li $v0, 10
  45. syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement