Professor Shai Simonson - CS304 - Computer Architecture



Assignment 1

Basic Assembly Language Using MIPS
I/O, Assignment, Selection, Loops, and Strings

 

Due Friday, September 21.  (30 points)

0.  In the book.  Chapter 4:  1, 8, 10, 11, 14.

1.  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.  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.

2.  Write and run a SPIM program that calculates the greatest common divisor of two integers.  You can use the "remu" unsigned remainder instruction.

3.  Write and run a SPIM program which takes a string as input, and outputs the same string with the first letter of each word in upper-case, and all other letters in lower-case. 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.

(Hint:  To distinguish between the first letter of a word and non-first letter just check whether the previous letter is a blank.)
 
4.  In the hardwired control unit discussed in class, assuming implementation is done with the minimum number of states, there are 8 (1 bit) inputs for the instructions: LOAD, STORE, etc. (only one is ever asserted at a time), 6 (1 bit) inputs for the states: I_0, I_1 ... I_5 (only one is ever asserted at one time), 1 (1 bit) input for AC=0, 13 (1 bit) outputs for the control lines: c_0 ... c_12,  and 2 (1 bit) outputs for the state: Increment and Reset.
Write out the logic for all output signals in terms of input signals.

back

 


shai@stonehill.edu

http://www.stonehill.edu/compsci/shai.htm