CSCI 101: Intro to Computer Science

Lab 6.4:   Symbols and Bits

PIPPIN

We asked you in the previous lab to confirm to your own satisfaction that the PIPPIN code produced by the Rosetta program did in fact correspond to - or simulated the effects of - the original equation. This is tough to do by hand, but there's a better way. We can use our CPU simulator, PIPPIN, to actually run the program, and then observe the effects of the program on the simulator's memory.

Clearly, we anticipated that these two programs, our translator and our machine simulator, would be related. It is no accident that Rosetta produces as its output PIPPIN instruction codes, which can then serve as input to the simulator. Neither is it an accident that the Rosetta program has a button in its control panel that saves the resultant PIPPIN code for loading into the CPU Simulator (the button is named SAVE FOR CP SIMULATION - NOTE This will only work if your browser allows saving from applets).

  1. Enter and set our standard equation, W = X * (2 + Y), into the Rosetta program, set it to perform "Code Generation", and click the "Play" button.
  2. Now, click "SAVE FOR CP SIMULATION," and switch to this lab, so you can use the PIPPIN simulator. Open the file you just created in PIPPIN, or type in the values from Rosetta if your browser can't save and load from Java files.
  3. Make sure that the simulator is operating in Symbolic mode.
  4. Notice, too, how the memory locations associated with variable W, X, and Y are uninitialized. For our statement to accomplish anything that we would notice (beside, say, setting W to zero, which it already is!), we should set the locations corresponding to X and Y to reasonable values, so that we can see if the code works. Click the memory cell for variable X, and set it (by typing into it) to 4. Similarly, set Y's memory cell to contain 5.
  5. If all goes well, when you click the "Play" button on the simulator, it should (after some pretty serious work) leave the value 28 (the result of evaluating 4 * (5 + 2)) in the location W. Click "Play" now to watch this occur.
  6. Click "Reset" to clear the simulator, and reset the value of memory location W to zero (resetting the simulator does not clear the memory cells for our variables).
  7. Repeat steps 1-6 for our more advanced equation:

    X = (3 * Y) + (2/W)

    In this case, when you set the values of variables (as in step 4, above), set Y to 14, and W to 1. This should produce a value of 44 for variable X when the code is "played" by the simulator. If you are in a hurry you can use the "Run" button to execute your program without all of PIPPIN's animated effects.

  8. Finally, write and test a PIPPIN program that calculates the average of the values in memory locations X, Y, and Z, and stores the result in W.