Here is the code we wrote today (after I finished it):
#translation of the code below, which prints num boxes of given size #read integer num #read integer size #int i=0; #while(i < size) { # int j=0; # while(j < num) { # int k=0; # while(k < size) { # System.out.print(’.’); //period is character 46 # k++; # } # System.out.print(’ ’); //space is character 32 # j++; # } # System.out.println(); //newline is character 10 # i++; #} li $v0, 5 #read integer num syscall addi $t0, $v0, 0 #t0 is num li $v0, 5 #read integer size syscall addi $t1, $v0, 0 #t1 is size li $t3, 0 #i=0; t3 is i iloop: bge $t3, $t1, exit #while(i < size) { li $t4, 0 #j=0; t4 is j jloop: bge $t4, $t0, newln #while(j < num) { addi $t2, $zero, 0 #k=0; t2 is k kloop: bge $t2, $t1, space #while(k < size) { addi $v0, $zero, 11 #print character 46 li $a0, 46 syscall addi $t2, $t2, 1 #k++; b kloop #bottom of k loop (prints periods) space: addi $v0, $zero, 11 #print character 32 addi $a0, $zero, 32 syscall addi $t4, $t4, 1 #j++; b jloop #bottom of j loop newln: addi $v0, $zero, 11 #print newline (character 10) addi $a0, $zero, 10 syscall addi $t3, $t3, 1 #i++; b iloop #bottom of i loop exit: li $v0, 10 #make exit system call syscall