ECE2071 Computer Organisation and Programming
MIPS LABORATORY TEST
Write a MIPS assembly language program that calculates the nth term (tn) in the Fibonacci series and stores the result in register $v1. You may assume that the value of n will always be greater than 1. When your program starts it should the load the value of n into register $a0. Finish your program with an ‘infinite loop’ (a jump instruction that jumps to itself).
You are to use the following equations to calculate the numbers in the Fibonacci series:
t0 = 0
t1 = 1
tr = tr-1 + tr-2
Numbers in the Fibonacci series are calculated in the following manner:
t0 = 0
t1 = 1
t2 = t0 + t1 = 0 + 1 = 1 t3 = t1 + t2 = 1 + 1 = 2 etc.
Hint: use a loop, not a recursive function!
Here is a skeleton program:
# Laboratory Test
# Written by Kermit the Frog
(given) (given)
.set noreorder
.text
.globl start
.ent start
start:
.end start
# Avoid reordering instructions
# Start generating instructions
# The label should be globally known
# The label marks an entry point
# Your assembler code goes here!
# Marks the end of the program