Assignment 03

Contents:

  • Overview
  • Internet Requirements
  • Practice Problems
  • Problems to be Submitted
  • Extra Credit

  • Overview

    Topic: Circuit review, and Machine Architecture
    Related Reading: pp. 20-23, Ch. 2.1-2.3 [Br]; pp. 207-214; Mod. 7.3-7.4 [DH]
    Due: 8pm Monday, 1 October 2001

    This assignment will use the PIN machine simulator and the PIPPIN assembly language based on the Decker/Hirshfield text. The practice problems will include an introduction to this information (see Lab 6.1 or 7.5). An important reference page is the User's Guide on page 260 which gives a list of all available operations.


    Internet Requirements

    You will only need an internet connection at time of submission, and either the text's CD-ROM or an internet connection while working on the assignment.

    Practice Problems

  • Lab 6.1 (p. 215-216)
  • Lab 7.5 (p. 264-265)
  • Exercises 10-11, on pp. 231-232 [DH]

    Problems to be Submitted (20 points)

    1. (2 points)
      Figure 7.7 on page 244 of [DH] shows a circuit for a one-bit adder. This circuit can be made significantly simpler, however, by using an XOR gate, as the resulting sum bit is precisely (a XOR b). Build this simpler version using Logg-O. Test it using all possible combinations of inputs.

      When you are satisfied, save your circuit in a file named "HalfAdd" for submission.

    2. (3 points)
      Figure 7.8 on page 244 of [DH] shows how two half-adders can be used to build a full-adder. Use the principals of the previous problem to build a full-adder circuit.

      When you are satisfied, save your circuit in a file named "FullAdd" for submission.

    3. (2 points)
      Consider the following mystery program in PIPPIN:
      0  LOD X
      2  SUB Y
      4  STO T4
      6  CPL T4
      8  JMZ 14
      10 LOD Y
      12 JMP 16
      14 LOD X
      16 STO W
      18 HLT
      
      Please try to save the above program, Mystery to your computer, and then load the file from disk when running PIP. For instance, to save the program if you are using Internet Explorer as your browser, click the right mouse button on the Mystery link, and select "Save Target As...". If you have trouble saving this file, you can instead start PIP form scratch and type the assembly instructions into PIP yourself.

      This program considers locations X and Y as input, and W as the result. Our goal is to examine the behavior of the program. To do so, we will ask you to execute the program, step-by-step, recording many key values after each individual step. To begin, initialize the memory locations so that X=5 and Y=8. Execute the program one step at a time. After each step, record each of the following values in a table: {PC, ACC, W, X, Y, T4}. Continue until the program halts.

      Reset the values so that {PC=0, W=0, X=12, Y=3, T4=0}. Now begin executing the program again, step-by-step, creating a second table which contains the values of these five locations after each step.

    4. (3 points)
      Describe, in English, the apparent purpose of the mystery program. That is, how does the resulting value of W depend on inputs X and Y, in general?

      Hint: You can draw your conclusions based on examining the instructions, considering the executions above, or considering additional executions.

    5. (5 points)
      Create a program in PIP which sets the value of W to be equal to the average of the three values initially in {X, Y, Z}, rounded down to an integer. That is, it should set W = (X+Y+Z)/3, where the division instruction in PIP automatically throws away any remainder.

      When complete, save your PIP configuration to a file named "Average" for submission.

    6. (5 points)
      Create a program in PIP which takes the initial value of X and does the following. If X is a positive number, the value should remain unchanged. If X is a negative number however, the program should replace the value in X with the corresponding positive number. For example, if X= 5 it should remain unchanged, but if X=-4 then your program should halt with the value 4 stored in X.

      Save your PIP program to a file named "Absolute" for submission.

    Overall, you should submit five files. Please place the answers for questions #3 and #4 in a single document named "Answers" to be submitted. Each of the other four questions involves submission of a particular file, as discussed in the problems.

    Extra Credit (4 points)

    Given three numbers, write a program which reports the second largest of the three. Specifically, location W should be given the second largest of the values initially in {X, Y, Z}

    Save your solution in a file named "Median".

    Warning: When creating this problem, it seemed a reasonable challenge. Conceptually, it is straightforward. I will admit that by the time I sat and wrote such a program, it involved over 30 instructions.


    comp150 Class Page
    mhg@cs.luc.edu
    Last modified: 21 September 2001