#DoWhileExample.asm #An example of a do-while loop using slt and bne # # This example represents the following Java code: # int i = 0, n = 10; # do # { # i++; # System.out.println(i); # } while (i < n); # # where i is $t1 and n is $t2 .data newLine: .asciiz "\n" .text main: li $t1, 0 #initialize i to zero li $t2, 10 #initialize n to ten do: #do loop operations addi $t1, $t1, 1 #increment i li $v0, 1 #print i or $t1 move $a0, $t1 #copy contents of $t1 into $a0 syscall li $v0, 4 #print a newline character la $a0, newLine syscall slt $t3, $t1, $t2 #compare i to n bne $t3, $zero, do #keep going if i < n li $v0, 10 #end the program syscall