I've just started learning MIPS assembly and I can't figure out, how to conditionally return to the caller
procedure. An example will make my question clearer. I have a procedure caller
, which does something before calling multiply
, I want this procedure to execute other things
after multiply
is finished. I know how to use conditions to jump to the labels, but instead of beq $t3, 80, caller
I want to return to the caller
, just after jal multiply
. I know that, to return you have to use jr $ra
, but can I call it using a condition?
caller:
doing_somehing
jal multiply
other_things
multiply:
beq $t3, 80, caller
lw $t4, array($t3)
mul $t4, $t4, $t1
sw $t4, array($t3)
addi $t3, $t3, 4
j multiply
Assembly should behave like this C code:
void caller()
{
doing_something();
multily();
other_things();
}
void multiply()
{
int i = 0;
while (i < 80)
{
someUnrelated();
i += 4;
}
return;
}