$29
CIS 314 Assignment 5 – 100/100 points
Please submit individual source files for coding exercises (see naming conventions below) and a
single solution document for non-coding exercises (.txt or .pdf only), when appropriate. Your
code and answers need to be documented to the point that the graders can understand your
thought process. Full credit will not be awarded if sufficient work is not shown.
1. [50] Write a Y86 program to implement the following C procedure (sigh - yes, this again):
void swap(int *xp, int *yp) {
int t0 = *xp;
int t1 = *yp;
*xp = t1;
*yp = t0;
}
Also implement a main procedure to call your swap procedure. Follow the register usage
conventions outlined in B&O’H section 3.7.3. Use the Y86 examples from class and the
textbook as a guide.
I recommend using the “Y86 online simulator” (linked on the course Links page) as a
programming environment.
Name your source file 5-1.ys.
2. [25] Draw a circuit (using AND, OR, and/or NOT gates) with inputs A, B, C, and D and one
output such that the output is on only if A is on and B is off or C is off and D is on (e.g., (A && !B)
|| (!C && D)). Include your answer in your solutions document (picture of a drawing is fine).
3. [25] In our example Y86 programs, such as the Sum function shown in Figure 4.6, we
encounter many cases (e.g., lines 12 and 13 and lines 14 and 15) in which we want to add a
constant value to a register. This requires first using an irmovl instruction to set a register to the
constant, and then an addl instruction to add this value to the destination register. Suppose we
want to add a new instruction iaddl with the following format:
This instruction adds the constant value V to register rB. Describe the computations performed
to implement this instruction. Use the computations for irmovl and OPl (Figure 4.18) as a guide.
Write your answer in your solutions document.
Zip the source files and solution document (if applicable), name the .zip file <Your Full
NameAssignment5.zip (e.g., EricWillsAssignment5.zip), and upload the .zip file to Canvas (see
Assignments section for submission link).