The missing MIPS instructions, in order, are
bne  $t0, $0, fooRet1
subi $a0, $s0, 3
add  $v0, $s1, $v0
The comparison slti $t0, $s0, 3 makes $t0 nonzero exactly when , so the first instruction selects the base case. The second forms from the saved argument, rather than relying on $a0 surviving the first call. After the second call, $s1 holds bar(y-2) and $v0 holds bar(y-3); the final addition puts their sum in $v0, as required by the calling convention.

Articles by others on the same topic (0)

There are currently no matching articles.