RosettaCodeData/Task/Loops-Do-while/MIPS-Assembly/loops-do-while.mips

14 lines
516 B
Plaintext

.text
main: li $s0, 0 # start at 0.
li $s1, 6
loop: addi $s0, $s0, 1 # add 1 to $s0
div $s0, $s1 # divide $s0 by $s1. Result is in the multiplication/division registers
mfhi $s3 # copy the remainder from the higher multiplication register to $s3
move $a0, $s0 # variable must be in $a0 to print
li $v0, 1 # 1 must be in $v0 to tell the assembler to print an integer
syscall # print the integer in $a0
bnez $s3, loop # if $s3 is not 0, jump to loop
li $v0, 10
syscall # syscall to end the program