CS1021 Lab 2 Fibonacci Numbers
Q1 Write an ARM Assembly Language program to compute the nth Fibonacci number. The nth Fibonacci number is defined recursively as:
Fn =Fn-1 +Fn-2 whereF0 =0andF1 =1.
Use R2 for n and compute Fn in R0. Test your program by computing F16 and F32.
Q2 Using your answer to Q1 as a starting point, write an ARM Assembly Language program to calculate the largest possible Fibonacci number using (i) 32-bit unsigned arithmetic and (ii) 32-bit signed arithmetic. Make sure you report the values of n and Fn (in hexadecimal and decimal) in your project submission.
Hint: If the maximum integer is MAX, it is possible to terminate the loop generating the Fibonacci numbers using the following condition:
if (MAX – Fn-1 < Fn-2) // Fn-1 + Fn-2 will be greater than MAX...
break; // therefore Fn-1 is the largest Fibonacci number
This lab will count towards your final CS1021 coursework mark. Submit your solution lab2.s and evidence that your program works (eg. use the Windows Snipping tool to get screen shots of the Keil IDE that show the results of running your program) via Blackboard no later than 9am on Fri 12-Oct-2018.
CS1021 Lab 2 2018 jones@scss.tcd.ie
1