Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Prints the triangle
- #
- # 1
- # 22
- # 333
- # 4444
- # 55555
- .text
- main:
- li $s0, 0 # Starting variable i = 0
- li $s1, 5 # Ending variable j = 5
- loop:
- addi $s0, $s0, 1 # i += 1
- li $v0, 1 # Print integer instruction
- li $s3, 0 # Inner loop helper k = 0
- move $a0, $s0 # Move the current integer into the target register
- innerloop:
- syscall
- addi $s3, $s3, 1 # k + =1
- bne $s3, $s0 innerloop # If j < i, repeat
- addi $a0, $0, 0xA # New line character
- addi $v0, $0, 0xB # Print command for lower 8 bits of $a0
- syscall # Print the new line
- bne $s0, $s1, loop # If we aren't at the end yet, loop again
- # Kill the program
- li $v0, 10
- syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement