main: .data main_regs: .word 0, 0, 0, 0, 0, 0, 0, 0 # register storage main_return_addr: .word 0 # return address .data a_1: .word 0 .data arr_1: .word 0, 0, 0, 0, 0 .data len_1: .word 0 .data temp_1: .word 0 .data remainder_1: .word 0 .data ten_power_1: .word 0 .data sum_1: .word 0 .data divisor_1: .word 0 .data i_1: .word 0 .data j_1: .word 0 .data f1_1: .word 0 .data f2_1: .word 0 .text li $t0, 21 sw $t0, a_1 #line 15 above. label0: # Label for a while/for statement. li $t0, 1 li $t1, 1 seq $t2, $t0, $t1 beqz $t2, label1 # Test to exit a while/for statement. #line 16 above. li $t0, 1 sw $t0, f1_1 #line 17 above. li $t0, 1 sw $t0, f2_1 #line 18 above. label2: # Label for a while/for statement. lw $t0, f2_1 lw $t1, a_1 slt $t2, $t0, $t1 beqz $t2, label3 # Test to exit a while/for statement. #line 20 above. lw $t0, f1_1 lw $t1, f2_1 add $t2, $t0, $t1 #line 21 above. sw $t2, f2_1 #line 21 above. lw $t0, f2_1 lw $t1, f1_1 sub $t2, $t0, $t1 #line 22 above. sw $t2, f1_1 #line 22 above. lw $t0, f2_1 lw $t1, a_1 seq $t2, $t0, $t1 beqz $t2, label4 # Condition in a if statement. #line 23 above. lw $t0, a_1 li $v0, 1 move $a0, $t0 syscall # line 24 b label3 # Quit the while/for statement. label4: # Label to a not-if statement. b label2 # Return to the while/for condition. label3: # Label to exit a while/for statement. lw $t0, a_1 li $t1, 1 add $t2, $t0, $t1 #line 28 above. sw $t2, a_1 #line 28 above. lw $t0, a_1 li $t1, 100 seq $t2, $t0, $t1 beqz $t2, label5 # Condition in a if statement. #line 29 above. b label1 # Quit the while/for statement. label5: # Label to a not-if statement. b label0 # Return to the while/for condition. label1: # Label to exit a while/for statement. li $v0, 5 syscall move $t0, $v0 sw $t0, a_1 # line 33 li $t0, 0 sw $t0, i_1 #line 36 above. li $t0, 1 sw $t0, ten_power_1 #line 37 above. lw $t0, a_1 sw $t0, temp_1 #line 38 above. li $t0, 1 sw $t0, len_1 #line 39 above. label6: # Label for a while/for statement. lw $t0, temp_1 li $t1, 10 div $t2, $t0, $t1 #line 40 above. li $t0, 0 sgt $t1, $t2, $t0 beqz $t1, label7 # Test to exit a while/for statement. #line 40 above. lw $t0, len_1 li $t1, 1 add $t2, $t0, $t1 #line 41 above. sw $t2, len_1 #line 41 above. lw $t0, temp_1 li $t1, 10 div $t2, $t0, $t1 #line 42 above. sw $t2, temp_1 #line 42 above. b label6 # Return to the while/for condition. label7: # Label to exit a while/for statement. li $t0, 2 sw $t0, i_1 #line 45 above. lw $t0, a_1 li $t1, 1 sle $t2, $t0, $t1 beqz $t2, label8 # Condition in a if statement. #line 46 above. li $t0, 0 li $v0, 1 move $a0, $t0 syscall # line 47 li $t0, 0 li $v0, 1 move $a0, $t0 syscall # line 47 li $t0, 0 li $v0, 1 move $a0, $t0 syscall # line 47 li $t0, 0 li $v0, 1 move $a0, $t0 syscall # line 47 label8: # Label to a not-if statement. lw $t0, a_1 li $t1, 1 sgt $t2, $t0, $t1 beqz $t2, label9 # Condition in a if statement. #line 49 above. label10: # Label for a while/for statement. lw $t0, i_1 lw $t1, a_1 slt $t2, $t0, $t1 beqz $t2, label11 # Test to exit a while/for statement. #line 50 above. lw $t0, a_1 lw $t1, a_1 lw $t2, i_1 div $t3, $t1, $t2 #line 51 above. lw $t1, i_1 mul $t2, $t3, $t1 #line 51 above. sub $t1, $t0, $t2 #line 51 above. li $t0, 0 sne $t2, $t1, $t0 beqz $t2, label12 # Condition in a if statement. #line 51 above. lw $t0, i_1 li $t1, 1 add $t2, $t0, $t1 #line 52 above. sw $t2, i_1 #line 52 above. b label10 # Return to the while/for statement. label12: # Label to a not-if statement. b label11 # Quit the while/for statement. b label10 # Return to the while/for condition. label11: # Label to exit a while/for statement. lw $t0, i_1 lw $t1, a_1 sne $t2, $t0, $t1 beqz $t2, label13 # Condition in a if statement. #line 57 above. li $t0, 0 li $v0, 1 move $a0, $t0 syscall # line 58 li $t0, 0 li $v0, 1 move $a0, $t0 syscall # line 58 li $t0, 0 li $v0, 1 move $a0, $t0 syscall # line 58 li $t0, 0 li $v0, 1 move $a0, $t0 syscall # line 58 label13: # Label to a not-if statement. lw $t0, i_1 lw $t1, a_1 seq $t2, $t0, $t1 beqz $t2, label14 # Condition in a if statement. #line 60 above. lw $t0, a_1 sw $t0, temp_1 #line 61 above. li $t0, 0 sw $t0, i_1 #line 62 above. label15: # Label for a while/for statement. lw $t0, i_1 lw $t1, len_1 slt $t2, $t0, $t1 beqz $t2, label16 # Test to exit a while/for statement. #line 63 above. lw $t0, temp_1 lw $t1, temp_1 li $t2, 10 div $t3, $t1, $t2 #line 64 above. li $t1, 10 mul $t2, $t3, $t1 #line 64 above. sub $t1, $t0, $t2 #line 64 above. sw $t1, remainder_1 #line 64 above. li $t0, 0 sw $t0, j_1 #line 65 above. li $t0, 1 sw $t0, ten_power_1 #line 66 above. label17: # Label for a while/for statement. lw $t0, j_1 lw $t1, len_1 li $t2, 1 sub $t3, $t1, $t2 #line 67 above. slt $t1, $t0, $t3 beqz $t1, label18 # Test to exit a while/for statement. #line 67 above. lw $t0, ten_power_1 li $t1, 10 mul $t2, $t0, $t1 #line 69 above. sw $t2, ten_power_1 #line 69 above. lw $t0, j_1 li $t1, 1 add $t2, $t0, $t1 #line 70 above. sw $t2, j_1 #line 70 above. b label17 # Return to the while/for condition. label18: # Label to exit a while/for statement. lw $t0, remainder_1 lw $t1, ten_power_1 mul $t2, $t0, $t1 #line 72 above. lw $t0, temp_1 li $t1, 10 div $t3, $t0, $t1 #line 72 above. add $t0, $t2, $t3 #line 72 above. sw $t0, temp_1 #line 72 above. lw $t0, i_1 li $t1, 1 add $t2, $t0, $t1 #line 73 above. sw $t2, i_1 #line 73 above. li $t0, 2 sw $t0, j_1 #line 75 above. label19: # Label for a while/for statement. lw $t0, j_1 lw $t1, temp_1 slt $t2, $t0, $t1 beqz $t2, label20 # Test to exit a while/for statement. #line 76 above. lw $t0, temp_1 lw $t1, temp_1 lw $t2, j_1 div $t3, $t1, $t2 #line 77 above. lw $t1, j_1 mul $t2, $t3, $t1 #line 77 above. sub $t1, $t0, $t2 #line 77 above. li $t0, 0 sne $t2, $t1, $t0 beqz $t2, label21 # Condition in a if statement. #line 77 above. lw $t0, j_1 li $t1, 1 add $t2, $t0, $t1 #line 78 above. sw $t2, j_1 #line 78 above. b label19 # Return to the while/for statement. label21: # Label to a not-if statement. b label20 # Quit the while/for statement. b label19 # Return to the while/for condition. label20: # Label to exit a while/for statement. lw $t0, j_1 lw $t1, temp_1 sne $t2, $t0, $t1 beqz $t2, label22 # Condition in a if statement. #line 83 above. li $t0, 0 li $v0, 1 move $a0, $t0 syscall # line 84 li $t0, 0 li $v0, 1 move $a0, $t0 syscall # line 84 li $t0, 0 li $v0, 1 move $a0, $t0 syscall # line 84 li $t0, 0 li $v0, 1 move $a0, $t0 syscall # line 84 b label16 # Quit the while/for statement. label22: # Label to a not-if statement. b label15 # Return to the while/for condition. label16: # Label to exit a while/for statement. lw $t0, j_1 lw $t1, temp_1 seq $t2, $t0, $t1 beqz $t2, label23 # Condition in a if statement. #line 88 above. li $t0, 1111 li $v0, 1 move $a0, $t0 syscall # line 89 label23: # Label to a not-if statement. label14: # Label to a not-if statement. label9: # Label to a not-if statement. li $t0, 0 sw $t0, i_1 #line 93 above. label24: # Label for a while/for statement. lw $t0, i_1 li $t1, 5 slt $t2, $t0, $t1 beqz $t2, label25 # Test to exit a while/for statement. #line 94 above. li $v0, 5 syscall move $t0, $v0 sw $t0, a_1 # line 96 lw $t0, i_1 lw $t1, a_1 li $t2, 4 mul $t0, $t0, $t2 #Compute offset la $t2, arr_1 #Get base addr add $t0, $t0, $t2 #address!!! sw $t1, ($t0) #line 97 above. lw $t0, i_1 li $t1, 1 add $t2, $t0, $t1 #line 98 above. sw $t2, i_1 #line 98 above. b label24 # Return to the while/for condition. label25: # Label to exit a while/for statement. li $t0, 1 sw $t0, sum_1 #line 102 above. li $t0, 2 sw $t0, divisor_1 #line 103 above. label26: # Label for a while/for statement. lw $t0, divisor_1 li $t1, 0 la $t2, arr_1 mul $t1, $t1, 4 #multiply by word size add $t2, $t2, $t1 #tx holds address of array[value] lw $t1, ($t2) #ty holds array[value] #line 104 above. li $t2, 2 div $t3, $t1, $t2 #line 104 above. li $t1, 1 add $t2, $t3, $t1 #line 104 above. slt $t1, $t0, $t2 beqz $t1, label27 # Test to exit a while/for statement. #line 104 above. li $t0, 0 la $t1, arr_1 mul $t0, $t0, 4 #multiply by word size add $t1, $t1, $t0 #tx holds address of array[value] lw $t0, ($t1) #ty holds array[value] #line 105 above. li $t1, 0 la $t2, arr_1 mul $t1, $t1, 4 #multiply by word size add $t2, $t2, $t1 #tx holds address of array[value] lw $t1, ($t2) #ty holds array[value] #line 105 above. lw $t2, divisor_1 div $t3, $t1, $t2 #line 105 above. lw $t1, divisor_1 mul $t2, $t3, $t1 #line 105 above. sub $t1, $t0, $t2 #line 105 above. li $t0, 0 seq $t2, $t1, $t0 beqz $t2, label28 # Condition in a if statement. #line 105 above. lw $t0, sum_1 lw $t1, divisor_1 add $t2, $t0, $t1 #line 106 above. sw $t2, sum_1 #line 106 above. label28: # Label to a not-if statement. lw $t0, divisor_1 li $t1, 1 add $t2, $t0, $t1 #line 108 above. sw $t2, divisor_1 #line 108 above. b label26 # Return to the while/for condition. label27: # Label to exit a while/for statement. lw $t0, sum_1 li $t1, 1 la $t2, arr_1 mul $t1, $t1, 4 #multiply by word size add $t2, $t2, $t1 #tx holds address of array[value] lw $t1, ($t2) #ty holds array[value] #line 110 above. sne $t2, $t0, $t1 beqz $t2, label29 # Condition in a if statement. #line 110 above. li $t0, 0 li $v0, 1 move $a0, $t0 syscall # line 111 label29: # Label to a not-if statement. lw $t0, sum_1 li $t1, 1 la $t2, arr_1 mul $t1, $t1, 4 #multiply by word size add $t2, $t2, $t1 #tx holds address of array[value] lw $t1, ($t2) #ty holds array[value] #line 113 above. seq $t2, $t0, $t1 beqz $t2, label30 # Condition in a if statement. #line 113 above. li $t0, 1 sw $t0, sum_1 #line 114 above. li $t0, 2 sw $t0, divisor_1 #line 115 above. label31: # Label for a while/for statement. lw $t0, divisor_1 li $t1, 1 la $t2, arr_1 mul $t1, $t1, 4 #multiply by word size add $t2, $t2, $t1 #tx holds address of array[value] lw $t1, ($t2) #ty holds array[value] #line 116 above. li $t2, 2 div $t3, $t1, $t2 #line 116 above. li $t1, 1 add $t2, $t3, $t1 #line 116 above. slt $t1, $t0, $t2 beqz $t1, label32 # Test to exit a while/for statement. #line 116 above. li $t0, 1 la $t1, arr_1 mul $t0, $t0, 4 #multiply by word size add $t1, $t1, $t0 #tx holds address of array[value] lw $t0, ($t1) #ty holds array[value] #line 117 above. lw $t1, divisor_1 div $t2, $t0, $t1 #line 117 above. lw $t0, divisor_1 mul $t1, $t2, $t0 #line 117 above. li $t0, 1 la $t2, arr_1 mul $t0, $t0, 4 #multiply by word size add $t2, $t2, $t0 #tx holds address of array[value] lw $t0, ($t2) #ty holds array[value] #line 117 above. seq $t2, $t1, $t0 beqz $t2, label33 # Condition in a if statement. #line 117 above. lw $t0, sum_1 lw $t1, divisor_1 add $t2, $t0, $t1 #line 118 above. sw $t2, sum_1 #line 118 above. label33: # Label to a not-if statement. lw $t0, divisor_1 li $t1, 1 add $t2, $t0, $t1 #line 120 above. sw $t2, divisor_1 #line 120 above. b label31 # Return to the while/for condition. label32: # Label to exit a while/for statement. lw $t0, sum_1 li $t1, 0 la $t2, arr_1 mul $t1, $t1, 4 #multiply by word size add $t2, $t2, $t1 #tx holds address of array[value] lw $t1, ($t2) #ty holds array[value] #line 123 above. sne $t2, $t0, $t1 beqz $t2, label34 # Condition in a if statement. #line 123 above. li $t0, 0 li $v0, 1 move $a0, $t0 syscall # line 124 label34: # Label to a not-if statement. lw $t0, sum_1 li $t1, 0 la $t2, arr_1 mul $t1, $t1, 4 #multiply by word size add $t2, $t2, $t1 #tx holds address of array[value] lw $t1, ($t2) #ty holds array[value] #line 125 above. seq $t2, $t0, $t1 beqz $t2, label35 # Condition in a if statement. #line 125 above. li $t0, 1 li $v0, 1 move $a0, $t0 syscall # line 126 label35: # Label to a not-if statement. label30: # Label to a not-if statement. li $t0, 2 sw $t0, i_1 #line 129 above. label36: # Label for a while/for statement. lw $t0, i_1 li $t1, 5 slt $t2, $t0, $t1 beqz $t2, label37 # Test to exit a while/for statement. #line 130 above. li $t0, 1 sw $t0, sum_1 #line 132 above. li $t0, 2 sw $t0, divisor_1 #line 133 above. label38: # Label for a while/for statement. lw $t0, divisor_1 lw $t1, i_1 la $t2, arr_1 mul $t1, $t1, 4 #multiply by word size add $t2, $t2, $t1 #tx holds address of array[value] lw $t1, ($t2) #ty holds array[value] #line 134 above. li $t2, 2 div $t3, $t1, $t2 #line 134 above. li $t1, 1 add $t2, $t3, $t1 #line 134 above. slt $t1, $t0, $t2 beqz $t1, label39 # Test to exit a while/for statement. #line 134 above. lw $t0, i_1 la $t1, arr_1 mul $t0, $t0, 4 #multiply by word size add $t1, $t1, $t0 #tx holds address of array[value] lw $t0, ($t1) #ty holds array[value] #line 135 above. lw $t1, divisor_1 div $t2, $t0, $t1 #line 135 above. lw $t0, divisor_1 mul $t1, $t2, $t0 #line 135 above. lw $t0, i_1 la $t2, arr_1 mul $t0, $t0, 4 #multiply by word size add $t2, $t2, $t0 #tx holds address of array[value] lw $t0, ($t2) #ty holds array[value] #line 135 above. seq $t2, $t1, $t0 beqz $t2, label40 # Condition in a if statement. #line 135 above. lw $t0, sum_1 lw $t1, divisor_1 add $t2, $t0, $t1 #line 136 above. sw $t2, sum_1 #line 136 above. label40: # Label to a not-if statement. lw $t0, divisor_1 li $t1, 1 add $t2, $t0, $t1 #line 138 above. sw $t2, divisor_1 #line 138 above. b label38 # Return to the while/for condition. label39: # Label to exit a while/for statement. lw $t0, sum_1 lw $t1, i_1 la $t2, arr_1 mul $t1, $t1, 4 #multiply by word size add $t2, $t2, $t1 #tx holds address of array[value] lw $t1, ($t2) #ty holds array[value] #line 140 above. seq $t2, $t0, $t1 beqz $t2, label41 # Condition in a if statement. #line 140 above. li $t0, 1 li $v0, 1 move $a0, $t0 syscall # line 141 lw $t0, i_1 li $t1, 1 add $t2, $t0, $t1 #line 142 above. sw $t2, i_1 #line 142 above. b label36 # Return to the while/for statement. label41: # Label to a not-if statement. lw $t0, sum_1 lw $t1, i_1 la $t2, arr_1 mul $t1, $t1, 4 #multiply by word size add $t2, $t2, $t1 #tx holds address of array[value] lw $t1, ($t2) #ty holds array[value] #line 145 above. sne $t2, $t0, $t1 beqz $t2, label42 # Condition in a if statement. #line 145 above. li $t0, 0 li $v0, 1 move $a0, $t0 syscall # line 147 lw $t0, i_1 li $t1, 1 add $t2, $t0, $t1 #line 148 above. sw $t2, i_1 #line 148 above. label42: # Label to a not-if statement. b label36 # Return to the while/for condition. label37: # Label to exit a while/for statement. # Code to exit. li $v0, 10 syscall #exit