2.32 [5] <§2.8> Functions can often be implemented by compilers “in-line.”
An in-line function is when the body of the function is copied into the program space,
allowing the overhead of the function call to be eliminated.
Implement an “in-line” version of the the C code in the table in MIPS assembly.
What is the reduction in the total number of MIPS assembly instructions needed to complete the function?
Assume that the C variable n is initialized to 5.
function :
int fib(int n) {
if (n==0)
return 0;
else if (n==1)
return 1;
else
return fib(n-1) + fib(n-2);
}
大多回答是說
遞迴不適合用inline
原因在於程式碼可能過大
但這題n只等於5
假如真的要放inline沒辦法得到答案嗎
謝謝