I have written a Java based machine level simulator of the Pep/7 machine to help you understand the fetch-decode-execute cycle.  The program runs as an

applet within a web page that requires the Java virtual machine plug-in.  The version which comes from Sun has more features than the one from Microsoft.  Try loading the page and if it runs you okay.  Otherwise you can get the Sun version at http://java.com/en/download/windows_automatic.jsp

  Note: it is not required that you use this program for any part of this course. It is simply an aide to understanding how the Pep/7 behaves.

After the Pep/7 java simulator loads, the screen always resembles this

The upper portion of the screen holds the registers, the middle contains the control buttons, while the lower portion shows the current contents of memory. All the initial registers are set to zero with the exception of the Stack Pointer (SP) which holds the value 0111111111111000. By default all register values are shown in binary, but by pressing the button labeled "View Decimal" we can switch to base 10:

Or by pressing "View Hex" we can switch to base 16:

You can switch bases at any time by pushing the appropriate button. Now the first task is to store our program in memory. For this tutorial we will use the machine code program given in problem 4.7:

0000

E1000A

0003

E1000B

0006

E1000C

0009

00

000A

4A6F

000C

79

The left column indicates the starting memory cell in hexadecimal while the right column gives the values stored there. But information is stored on a byte basis so each memory location holds exactly one byte (8 bits or 2 hex digits). So memory location 0 holds "E1", location 1 holds "00", and location 2 holds "0A". To enter the program we push the "Edit Memory" button and a new window should now be displayed:
To simply the task, the simulator always uses hex when entering values into memory. First enter 0 in the field the memory location and E1 in the field labeled "value". The program is case insensitive and assumes a leading zero so you could also have entered "e1". The editing window should resemble

Now push the "Set Memory" button on the editing window. A message appears in the editing widow telling you that mem[0] has been set to 255(decimal).

Now look back at the main simulator window. The memory location 0 circled in red has changed. The memory has 4 Megabytes of storage but all can be viewed by scrolling the arrows on the memory box. The memory is read by row + column. So Memory location 4F would occur on the row labeled 0040 under the column labeled "F".

Now the next value to be entered is 0 at memory address 1, but by looking at the current contents of memory we can see it is already at 0 so we can skip it and enter the next value which is 0A at memory address 2:

The program assumes if you enter a single number there is a leading 0 in front so you could have entered "0A", "0a", "A" or "a" and the result would be the same. We continue entering the values until the entire program is loaded. You can close the editing window now. You can reopen it at any time by just selecting the "Edit Memory" button. Now we are ready to run the program by pushing the button labeled "Fetch"

The machine has loaded into the instruction register (IR) the next three bytes stored in memory location Program Counter (PC)=0. Push the button labeled "Decode".

Now the machine has decoded the value into the operation, the register, its addressing mode, and the operand. Press the "Increment" step to move the program counter forward.

Notice the only change occurred in the PC register. It will advance three locations except if it is a single byte instruction. The PC holds the address of the NEXT instruction to be executed. Okay now we are ready to actually perform the operation so press "Execute"

The instruction was to display the character held in memory address "A" which is the character 'J' - it shown on the output box. The Fetch-Execute cycle now continues to "Fetch" the next instruction held in memory location 3.

By repeatedly pushing the far right button here is the final results:

You can run the program again by just hitting the reset button. The PC goes back to 0 and the fetch-execute cycle begins again. However any changes you made to memory are permanent.