Lab 2 - A simple assembly language program

Intro to Computer Architecture
Spring, 2018
20 points
Due:  February 26 (11:59 pm)

For this assignment you will write your first MIPS assembly language program.  (Use MARS to test and run your program.)

Write a program which computes a sequence of fibonacci numbers and displays it.


Read three input values from the keyboard (with appropriate prompting messages):

a.  the first number in the sequence,
b.  the second number in the sequence, and
c.  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.


For each element of the sequence that you generate, display the following:

a.  the number in decimal notation (using syscall 1).
b.  the number in hexadecimal (using syscall 34).
c.  the number of 1-bits in the binary representation of the number (in decimal, using syscall 1).

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


1.  Don't use arrays for this problem.  They are not necessary.

2.  Negative numbers are allowed as input values.  Make sure you try some as test cases.

3.  Document your program 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:

Submitting your program

1.   Use handin to submit your work.  This is lab 2.

2.   The directory you submit should contain the .asm file with your program code, along with a README.

3.   The README should contain a statement of the honor code.  Also indicate any known errors or problems with your code (if there are any).