CSC 103: How Computers Work
HW 2: PIPPIN with Conditional Instructions
Due Friday October 5: 4pm to EGR 105B
Convert the following generic computer code segments into PIPPIN
(a)
W = (X * (Z - 3)) + 16)
(b)
if (Y < 0)
Z = 1
else
Z = 2
Recall that we work in assembly language, but the computer works in machine language,
which is in binary. You can look at your program in machine language by clicking the
'binary' button at the bottom of the simulator. You can also get more information on the
instruction codes for PIPPIN by looking at the PIPPIN User's Guide on the course web page.
Hints:
- It will probably be easier to write out your PIPPIN instructions on paper
before beginning to type them into the simulator.
- As you write out your instructions, it is useful to write the definition (or
expected execution) of the jump and compare instructions next to those lines.
- To test your code, determine what the answer should be ( i.e., what Z is equal
to in part (b)) with each value you enter for Y, and run the Pippin simulator
to see that your PIPPIN code gives you the result you expect.
- Test both possibilities in (b), entering a value for Y that is greater than 10 and
then a value for Y that is less than 10, making sure you know what you expect
for Z each time.
- To run the same program a second time, reset the variable values, and also
reset the PC to 0.
- Test the code for part (a) in the same manner.
What to hand in
Hand in the computer code - you can type it into a word document once you have
it working. Do not forget the line numbers for both programs
written along the left margin of each line of code.