The blanks are Although the immediate call increases the argument, substitution into
x < 2 and return x - foo(x + 1). The compiled slti and bne select the first branch exactly for . Otherwise addi forms , jal foo returns its value in $v0, and sub $v0, $s0, $v0 subtracts that value from the preserved . Thus the complete high-level implementation isproc bar(val x : int) : int
begin if x < 2 then
return 1
else
return x - foo(x + 1)
end
endfoo's two recursive calls decreases the corresponding bar arguments to and whenever the recursive branch is entered. The mutual recursion therefore terminates on ordinary integer inputs, assuming sufficient stack space and no machine arithmetic overflow. Articles by others on the same topic
There are currently no matching articles.