A MIPS assembly implementation of the Fibonacci function, demonstrating the power and intricacies of assembly programming.
The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, often starting with 0 and 1. This repository contains a recursive MIPS assembly implementation of the Fibonacci function, adhering to the modern Fibonacci convention:
fibonacci(0) = 0
fibonacci(1) = 1
To use the Fibonacci function in your MIPS assembly project:
- Clone the repository
- Include the Fibonacci function in your assembly program.
- Use the
fibonacci
label to call the function. The inputx
is passed in the$a0
register, and the result will be in the$v0
register.
To ensure the Fibonacci function works accurately, a main
function is included in the assembly file for direct testing. This testing setup allows users to directly interact and validate the correctness of the function.
-
Compile and Run the Assembly File:
Depending on the simulator or environment you're using (like SPIM or MARS), open and assemble the Fibonacci MIPS assembly file. Then, run the program.
-
Input a Number:
Once you run the program, you'll be prompted to "Enter a number:". Input any non-negative integer to compute its Fibonacci value.
-
View the Result:
After entering the number, the program will display the corresponding Fibonacci value for the given number.
Enter a number: 9
Fibonacci of 9 is: 34