Advertisement
kolyaventuri

pyramid.asm

Nov 25th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 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, 5 # Ending variable j = 5
  14.  
  15. loop:
  16. addi $s0, $s0, 1 # i += 1
  17.  
  18. li $v0, 1 # Print integer instruction
  19. li $s3, 0 # Inner loop helper k = 0
  20. move $a0, $s0 # Move the current integer into the target register
  21.  
  22. innerloop:
  23. syscall
  24. addi $s3, $s3, 1 # k + =1
  25. bne $s3, $s0 innerloop # If j < i, repeat
  26.  
  27. addi $a0, $0, 0xA # New line character
  28. addi $v0, $0, 0xB # Print command for lower 8 bits of $a0
  29. syscall # Print the new line
  30.  
  31. bne $s0, $s1, loop # If we aren't at the end yet, loop again
  32.  
  33. # Kill the program
  34. li $v0, 10
  35. syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement