Systems Architecture
121 Assignment 1
DUE 6pm Friday XXX, end of week 4

Rules

  1. The course rules on own work and plagiarism apply to this assignment. See the subject outline page for details. Your submission will be cross-compared to other student submissions to ensure that answers have not been shared.
  2. The due date for the assignment is a hard date. You will need to supply a good reason if an extension is required. Unless you have given me your written request for extension, and I have approved an extension (along with my signature), late submissions will not be accepted. This assignment is worth 15% of your final mark in this course.

Submission

Your answer to the assignment must be submitted electronically through the iLearn portal as a Zip or tar file containing all of the source code files: no other submission will be accepted. Instructions on how to create a Zip or tar file are given somewhere.
Please submit your Zip or tar file for the assignment through the iLearn submission area.

Task 1 - 7 marks

Write a MIPS assembly program that does the following:
  1. Continually prompts the user to enter a whole number, and reads the number entered.
  2. Stops reading numbers from the user when they enter the value 0.
  3. Prints out the value of the smallest number entered, the biggest number entered and the (integer) average of all the numbers entered. The zero value is not included in the calculations.

Hints, Tips and Constraints

You will need to use syscalls 4 (print string), 1 (print int), 5 (read int) and 10 (exit) in your program, so make sure that you know how to use them.
The user can enter any valid whole number in their input, so your program needs to be able to deal with positive and negative numbers.
If the user enters no numbers, i.e. 0 only, then your program can do anything as long as it doesn't crash.
Your program must not crash, regardless of what whole numbers the user enters in the program.
You are free to store all your data in registers, or you can use main memory to store data.
You will need to learn how to loop and how to make decisions. This is covered in the Week 4 lab, so you may want to read up on this before we get to the Week 4 lab.
I expect to see the same layout and the same amount of commenting as I provide in my example assembly programs in the lab and elsewhere.

Example Runs

Here are some example runs, all in a single text file.

Task 2 - 8 marks

Here is a list of 50 whole numbers:
63, 42, 11, 277, 15, 59, -1143, 75, 37, 49, 29, 373, 87, 6, 68, 58, 7,
95, 0, 43, 69, 42953, 56, 96, -10, 76645, 873, 27, 90, 84, 90, 79, 47, -18,
-152, 77, 8, -5, -5, -4506, 35, -9, 89, 52, -9, 94, -12, 5, 26, 48
Write a MIPS assembly program to do the following:
  1. Store the list of 50 numbers as an array of words in the MIPS main memory.
  2. Print out the list of 50 numbers, each one on a separate line.
  3. Write code that sorts the array into ascending order, i.e. from the lowest value to the highest value.
  4. Re-prints out the list of 50 numbers, each one on a separate line.

Hints, Tips and Constraints

I would recommend that you use Bubble Sort to sort the array, as it is one of the simplest algorithms to implement.
Store the size of the array, i.e. 50, in a memory location before you store the array. This way, if you need to sort an array of a different size, you can change the size of the array as well as storing a different set of values in main memory.
Don't worry about writing out the array printing code twice. I know this counts as DRY code, but we haven't learned how to do functions yet, so you can't write a function to do this yet.

Example Run

Here is my example run. The two array prints are separated by a blank line.

Bonus Marks - 3 marks

Write a function to print the list, and also a function to sort the list. For both functions, pass a pointer to the array size stored in memory, and a pointer to the first element of the array.


File translated from TEX by TTH, version 3.85.
On 23 Jan 2012, 16:15.