0% found this document useful (0 votes)
19 views2 pages

Arch Assignment

Uploaded by

Lux Musica Beats
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

Arch Assignment

Uploaded by

Lux Musica Beats
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CSC2002S: Architecture Assignment

MIPS Assembly Programming


MIPS is a family of RISC architectures. The 32-bit version of MIPS has 32 general purpose
registers and 32 single precision floating point registers – 2 floating point registers may be
combined to store a double precision floating point value. In this assignment, we’ll look at MIPS
assembly programing using the QtSpim emulator.

Question 1 [30 marks]


Write a program (question1.asm) that will receive the number of lines of input, n, followed by n
lines of text and will then print them in reverse order. Each line should be stored in memory.
Sample IO:
Enter n, followed by n lines of text:
3
one
two
three
The values are:
three
two
one

Question 2 [30 marks]


Write a program (question2.asm) that will receive a series of positive integers to be added,
separated by the ‘+’ operation. Compute the sum of these values. Assume that the input sum has
no whitespace.
Sample IO:
Enter a sum:
10+4+50+6
The value is:
70

Question 3 [40 marks]


Spreadsheets, consisting of units called cells, are useful for summing numbers. Another useful
feature of spreadsheets is the ability of cells to reference other cells.
Write a program (question3.asm) that will function as a simple 1D spreadsheet. Each cell can
consist of either a positive integer or a formula (a reference to another cell). Formulae are
denotated with the character ‘=’, eg: ‘=2’ is a reference to cell 2, and that formula should be

1
replaced with the integer value in cell 2. Cells are indexed from 0. The program should also
accept n number of cells, as the first integer will indicate the number of cells, similar to Question
1. The program should then print all cells in order. Finally, the sum of all cells should be printed
at the end.
Sample IO:
Enter n and formulae:
3
1
2
3
The values are:
1
2
3
6

Sample IO (do not include the comments):


Enter n and formulae:
5 #The number of cells
1 #Cell 0: integer value
2 #Cell 1: integer value
3 #Cell 2: integer value
=1 #Cell 3: formula referencing cell 1
=3 #Cell 4: formula referencing cell 3
The values are:
1
2
3
2 #Cell 3 displays cell 1’s value
2 #Cell 4 displays cell 3’s value
10 #Sum of all cells

Submission
Create a compressed archive, zip, of all files. Name the zip file with your student number and
upload to Automarker.
NOTE:
1. We can determine the end of a string inputted from console by checking for the line feed
(LF) character, which has an ASCII code of 0x0A or 10.

You might also like