CSCI 101: Intro to Computer Science
Lab 6.1: Representations
PIPPIN |
---|
These lab exercises rely on two complementary programs, both of which are translators in the sense that each accepts as input a program written in one language and produces as its output a version of the input program in another language. One translator demonstrates the two basic steps involved in translating a program from a high-level languages like JavaScript, into a lower-level assembly language, like PIPPIN described in our text. The other translates a program from its assembly language form into a machine-readable and machine-executable binary form. Taken together, these programs form a modern-day Rosetta stone.
We start with the PIPPIN Simulator above. This program does much more than just translate a program written in PIPPIN assembly language into its binary form. It actually shows how the resulting binary program is executed by the machine. At this point, though, we're only concerned with how information - numbers, names and operations that appear in PIPPIN - can be represented in binary. (We'll concentrate on the simulator's ability to execute programs in the next module.)
To do this we need only concern ourselves with the right and bottom portions of the program window. Along the right side are memory locations (stored in our machine's "RAM"). The top group of those locations (labeled 0-14, in increments of two) is intended to hold instructions to be executed by our virtual computer. The buttons along the bottom of the window can be used to control the machine as it does the execution. For now, the only buttons we will use are the two labeled Symbolic and Binary. These allow us to view the instructions we enter into the memory locations in either their symbolic form (that is, as we entered them, using PIPPIN codes, variable names, and numbers) or in their binary equivalents.
- Enter the following list of symbolic PIPPIN instructions into memory
locations 0, 2, 4, and 6, respectively, of our CPU simulator.
LOD #2 ADD Y MUL X STO W
- Click the Binary button to see the binary representation of memory.
- Toggle back and forth between Symbolic and Binary modes, until you can
see the correspondence between the two representations of the same
information. Then answer the following questions
- At what address is the MUL X instruction stored? How is that address represented in binary?
- What is the binary operation code that corresponds to the symbolic instruction LOD?
- How is the number 2 represented in binary?
- At what address is variable Y stored, and how is that address represented in binary?
- Answer question d, this time for variable X.
- Answer question d, this time for variable W.
- What are the binary operation codes corresponding to the symbolic PIPPIN instructions ADD? MUL? STO?
- Let's reverse the process now to test your understanding. See if you can
determine the symbolic PIPPIN program that corresponds to the following
sequence of binary codes as they would appear in the first 8 locations of
RAM. Use PIPPIN to check your answer.
00010100 00000101 00000000 10000000 00000001 10000011 00000011 10000001 00000101 10000010 00001110 00000000 00001110 00000000 00001110 00000000