Im doing a recursive fibonacci assignment in MIPS and simulated with qtSpim on my mac and have it working. However, my teacher wants a way to check if the integer n is too large in the fib function and if so, “output the number is too large”. Any hints on how i could go about doing this?
Im doing a recursive fibonacci assignment in MIPS and simulated with qtSpim on my
Share
I don’t know much about the MIPS instruction set, but the general assembler approach is to check the carry flag after an operation. If it’s set, then the result was too big for (unsigned) arithmetic.
AFAIK, MIPS doesn’t have a carry flag. But you can approximate one as follows: