Computer Organization and Structure

 

Homework #2

Due: 2006/11/4

 

Please write the following programs in MIPS assembly language.

 

1.      Max & Min:
Write a program that reads any amount of integer inputs then output the biggest and smallest number among these integer.

 

HintYou can read the inputs one by one.

 

2.      Euclidean Algorithm:
Write a program to compute the greatest commom divisor (GCD) of tho given integers by using the Euclidean algorithm.

 

HintMake sure you really understand how Euclidean algorithm works!

NoteWe want you to use “for loops” and subtract operations instead of division operations in this problem. You can still use division operations, but will result in a little penalty.

 

BONUS

 

Factorial:

Write a program to compute n!, for any given input n. You have to implement big integer operations in order to deal with large numbers.

Ex15!=1307674368000, which is too big to be stored in an integer variable (or register). So without big integer operations, you can’t deal with this problem very well.

 

Hint: The real problem is how to deal with big integers, not how to compute factorial. Think carefully before you start!

 

Submission & Grading

 

The deadline is 11/4. Please send your source code to TAs by E-mail before 11:59PM of that day. The file name should be your student id like B91705056.rar. If you want to submit a newer edition of your code, please rename it like B91705056_1.rar.

 

Please remember that you still have to demo your code to TAs. On the demo day please

 

a.         hand-in the the documentation of your programs in HARD COPY.

b.        demo your program and explain the code to TAs.

 

The demo time will be hold on 11/6 and 11/8, at the night time. Please fill your name into the demo schedule in the class of 10/31. If you have any problem with this, please contact us before its too late.

 

Grading-- program60%, documentation40%.

 

NOTE

 

a.      You can use any resources you found on the net, or discuss with others. However, ANY KIND OF COPIED CODES WILL GET ZERO POINTS. (include the “shared” one)

 

b.        You can Email TAs for any problems you encountered. But we will not help you to

do your homework!

 

c.         We will not accept any code after the deadline. And we will not give you any points if you don’t show up on the demo day.