I have the following C code, that I would like to translate into MIPS assembly.
int fib_iter(int n) {
int i, f0, f1, f;
f0 = 0;
f1 = 1;
if (n == 0) return f0;
if (n == 1) return f1;
for (i = 2; i <= n; i = i + 1) {
f = f0 + f1;
f0 = f1;
f1 = 1;
}
return f;
}
I have not idea how to do it though, and I couldn't find a good tutoriol anywhere. I have read the wikipedia article about MIPS (https://en.wikipedia.org/wiki/MIPS_instruction_set) and found the table about all the assembly commands pretty helpful already, however actually translating is still unclear to me.. Could you maybe show me with the small example up there how to do it and then I can try myself? Thank you!