Simonson - CSC304 - Computer Architecture
Basic Assembly Language Using
I/O, Assignment, Selection, Loops, and Strings
Due (Total 25 points) Friday, February 9
0. In the book. (5 points) Chapter 1:
1.5, 1.6, 1.7, 1.9 (all parts)
1. (5 points) Write a SPIM program to take three integer
values A, B and C and compute B2 - 4AC, if the value is
greater than 0, or else output 0. You may assume that
all values fit in 32 bits. Recall that pseudo-instruction
"mul" uses three parameters while the MIPS instruction mult uses
only two and stores its answer in registers LO and HI. You could
hard code the data in memory in your program ( A: .word 12 etc.), or
better, read each of the three integers from the console (using 5
for $v0) and store them in A, B, and C, respectively.
2. (5 points) Write and run a SPIM program
that calculates the greatest common divisor of two integers.
You can use the "remu" unsigned remainder instruction, and
implement Euclid's algorithm in a loop.
3. (10 points) Write and run a
SPIM program which takes a string as input, and outputs the same
string with the first occurrence of a letter in each word in
uppercase, and all other letters in lowercase. Any non-letters
should remain as they are. The string can consist of any
characters up to a maximum of 100. You may assume that a new word
starts after one or more spaces.
For example the string "hhdThY
67trrEErr UUUdd$5W" should
Make sure to comment your programs carefully, and to make them
user friendly to run.