Here is the code we wrote today:

  #this code reads an integer and then prints from 0 to this value
  #using a translation of the following code:
  #   $t1 = 0;
  #   while($t1 < $t0) {
  #      print $t1;
  #      $t1++;
  #   }
		  
	#reads an integer into t0
	addi	$v0, $zero, 5
	syscall
	add	$t0, $zero, $v0
	
	#set $t1 to 0
	addi	$t1, $zero, 0 
	
loop:	bge	$t1, $t0, exit		#top of loop
	
	#print contents of $t1
	add	$a0, $zero, $t1
	addi	$v0, $zero, 1
	syscall
	
	addi	$t1, $t1, 1		#increment $t1
	
	b	loop			#end of loop
	
exit:	#exit the program
	addi	$v0, $zero, 10
	syscall	

Here is the different version of the loop we were looking at as class ended:

	#reads an integer into t0
	addi	$v0, $zero, 5
	syscall
	add	$t0, $zero, $v0
	
	#set $t1 to 0
	addi	$t1, $zero, 0 
	
loop:	blt	$t1, $t0, body		#top of loop
	b	exit
	
body:	#print contents of $t1
	add	$a0, $zero, $t1
	addi	$v0, $zero, 1
	syscall
	
	addi	$t1, $t1, 1		#increment $t1
	
	b	loop			#end of loop
	
exit:	#exit the program
	addi	$v0, $zero, 10
	syscall