so I'm currently trying to go through a for loop in MIPS and trying to multiply with it. I did the same thing with addition and it worked. Below, $t0 is the lower integer the user has entered, $t6 is the upper integer + 1, and $t4 is the register that stores the result. Here it is:
beq $t0, $t6, resultFunction
add $t4, $t4, $t0
addi $t0, $t0, 1
j addForLoop
What this does is store the lowest integer value a user has entered and then increments it to an upper integer value they have entered + 1 so that it increments correctly. It then adds appropriately and then increments the counter by 1, repeating if they are not the same. When the values are the same, it exits out of the loop. For example, if the values are 2 and 4, the answer would be 2 + 3 = 5, then 5 + 4 = 9. The loop would output with the answer 9 as it should. I tried to do this same thing but multiplying instead, and this is where my problem is. When trying to replace add with mul (like this),:
beq $t0, $t6, resultFunction
mul $t4, $t4, $t0
addi $t0, $t0, 1
j multForLoop
it is not working correctly and I'm getting 0 as the output instead. If the two integers are 2 and 4 again, it should output 24 (2 * 3 = 6, 6 * 4 = 24). I'm not quite sure why this isn't working and any help would be appreciated.