Assignment 04

Contents:

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

  • Overview

    Topic: Machine Architecture
    Related Reading: Ch. 2.1-2.3 of [Br]; pp. 207-214, Mod. 7.4 of [DH]
    Due: 8pm Thursday, 14 February 2002

    This assignment will use the PIPPIN software from the Decker/Hirshfield text. The practice problems will include an introduction to using the software. Also, please see the following information regarding using the Decker/Hirschfield software.


    Internet Requirements

    While doing this assignment, you will either need to use an Internet connection or else the CD-ROM that comes with the DH text.

    Practice Problems

  • Lab 6.1 (p. 215-216)

  • Lab 7.5 (p. 264-265)

  • Exercises 10b and 11 on pp. 231-232 [DH]

  • Questions 1-4 of Ch. 2.1 of [Br] (p. 84).
    answers appear in Appendix F

  • Problems to be Submitted (20 points)

    Problems 1, 2 and 3 involve 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. ;Instructions for doing this are here. 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.

    1. (3 points)
      We want you to create a table which records many key values before each instruction to be executed. The first row shows how the initial values should be set before beginning the program. The next two rows are to get you going. Continue until the program halts.

          | PC|ACC| W | X | Y | T4|
          +---+---+---+---+---+---+
          | 0 | 0 | 0 | 5 | 8 | 0 |
          | 2 | 5 | 0 | 5 | 8 | 0 |
          | 4 |-3 | 0 | 5 | 8 | 0 |
          |   |   |   |   |   |   |
          |   |   |   |   |   |   |
      

      Hint: If you understand the instructions, you should be able to fill in the table by hand-simulating the program. Of course, after trying this on your own, you can check your answers by watching the PIPPIN program as it runs.

    2. (3 points)
      As with the previous problem, complete the following table.
          | PC|ACC| W | X | Y | T4|
          +---+---+---+---+---+---+
          | 0 | 0 | 0 |12 | 3 | 0 |
          | 2 |12 | 0 |12 | 3 | 0 |
          | 4 | 9 | 0 |12 | 3 | 0 |
          |   |   |   |   |   |   |
          |   |   |   |   |   |   |
      

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

      Hint: Though you may want to consider additional examples, your write-up for this problem should be stated without mention of specific examples.

    4. (5 points)
      We want you to create a PIPPIN program with the following behavior. Let's denote the initial values stored in {W, X, Y, Z} as {W0, X0, Y0, Z0}. Let's denote the final values stored in {W, X, Y, Z} as {W1, X1, Y1, Z1}.

      Your program should cause the following (please note the use of subscripts carefully):

      W1 = 2 * X0
      X1 = X0 - Y0
      Y1 = W1 + Z0
      Z1 = Y1 / 4

      For example, if the initial values were {W=1, X=2, Y=3, Z=4} then the final values should equal {W=4, X=-1, Y=8, Z=2}

      Save your PIPPIN program to a file named "Mixup" for submission.

    5. (5 points)
      Create a PIPPIN program which has behavior described as follows:
      If (X<5) Then
        Copy the value from Cell Y into cell W
      Else
        Copy the value from Cell Z into Cell W
      

      For example, if the initial memory contents appear as {W=6, X=7, Y=8, Z=9} then after running such a program, the contents should appear as {W=9, X=7, Y=8, Z=9}.

      Alternatively, if the initial memory contents appear as {W=1, X=2, Y=3, Z=4} then after running such a program, the contents should appear as {W=3, X=2, Y=3, Z=4}.

      Save your PIPPIN program to a file named "IfElse" for submission.

    Overall, you should submit three files. Please place the answers for questions #1, #2 and #3 in a single document to be submitted. The final two questions each involves submission of a PIPPIN file.

    Extra Credit (3 points)

    Write a PIPPIN program with the following behavior. Given a positive integer X, it should set W to be the largest possible integer such that W2 is less than or equal to X.

    For example, if X=27, then W should be set to 5. If X=53, W should be set to 7.

    Save your solution in a file named "SquareRoot".


    comp150 Class Page
    mhg@cs.luc.edu
    Last modified: 6 February 2002