$30
CDA3101
Programming Assignment 2
A 24-hour grace period with 20% penalty is given. No submission is accepted after the grace period.
Instructions
Transform the following code into MIPS instructions. Your programs should run correctly on the
QtSPIM simulator. Submit your assembly solution (project2.s) containing the neatly
written/organized MIPS code in e-Learning (Canvas) website before the deadline.
Important
You should use comments (‘#’ followed by text) in order to make your programs more readable.
The name of the file submitted MUST be “project2.s”
You MUST verify that your submission in Canvas is successful by downloading your submission
from Canvas and successfully testing it again using SPIM simulator. This will ensure that you
uploaded the right file in eLearning and the upload is successful.
Basic Problem (80 pts):
Given two integers, write a program to find the Greatest Common Divisor (GCD) and Least
Common Multiple (LCM) of them.
Your assembly implementation should follow the pseudo code sequence given below. Please
do not perform any optimization at pseudo code level or at assembly level.
Input validation (20 pts):
The input numbers need be in range [0, 255]. Besides, both inputs cannot be zero at the same
time since GCD(0,0) is undefined.
So, you should verify the input numbers are valid.
Tips:
For printing to/reading from console, you should first load correct value to register $v0, and
then call “syscall” method. If there is an input, the value would be returned in $v0.