CSCI 210: Lab 2
MIPS
Fibs
Due:
11:59
PM
on
Sunday,
March 7th
Write a program which computes a sequence of fibonacci numbers and displays it. You will write this program using the MARS MIPS simulator, which you can download here. Check out the lab template from github here.
Partners
You can work on this lab with a partner if you choose. If you decide to work with a partner, you and your partner should check out a single lab2 repository. The first partner will create a team name, and the second partner should choose that team name. Please be careful choosing a team, as this cannot be undone. Please name your team something that makes it clear who you are.
If you choose to work with a partner, you and your partner must complete the entire lab together. Dividing the lab up into pieces and having each partner complete a part of it on their own will be considered a violation of the honor code. Both you and your partner are expected to fully understand all of the code you submit.
Input
Read three input values from the keyboard:
- the first number in the sequence,
- the second number in the sequence, and
- the number of elements of the sequence.
Each element of the sequence (beyond the first two) is equal to the sum of the previous two. For example, if the user inputs 3, 1, and 10, then your program should generate the sequence 3, 1, 4, 5, 9, 14, 23, 37, 60, 97.
Output:
For each element of the sequence that you generate, display the following:
- the number in decimal notation (using syscall 1).
- the number in hexadecimal.
- the number of 1-bits in the binary representation of the number.
For the example above, you would display
3 0x00000003 2
1 0x00000001 1
4 0x00000004 1
5 0x00000005 2
9 0x00000009 2
14 0x0000000E 3
23 0x00000017 4
37 0x00000025 3
60 0x0000003C 4
97 0x00000061 3
The hex version can be displayed using system call 34.
You will not need to use either arrays or recursion for this problem. You will probably want to write a function which counts the number of ones in a number.
Make sure to document your programs thoroughly. (This is especially important in assembly language programs, since the code itself is less easily read than high-level language code.) This should include:
- A block of comment lines at the beginning of the source file, giving the name and author of the program and a black-box description of what it does.
- A few comment lines between major sections of the program, describing the contents of each section.
- A comment at the end of most source lines, describing what the instruction on that line does.
Helpful Resources
Submit the lab by committing to your lab2 github repository.
C. Taylor