Dale - Computer Science Illuminated 228

Dale - Computer Science Illuminated 228 - mode and the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
7.4 A Program Example 201 them. At the end of the first fetch, the PC and the IC look like this. (We continue to use color to emphasize addresses, opcode, address-mode specifier, and data.) The instruction is decoded as a ‘Write character to output’ instruction with immediate mode addressing. Because this instruction takes three bytes, the PC is incremented by three. The data is retrieved from the operand specifier in the IR, and the instruction is executed. “ 6 ” is written on the screen. The second fetch is executed and the PC and IR are as follows: The instruction is decoded as another ‘Write character to output’ instruc- tion with immediate mode addressing. The instruction takes three bytes, so the PC is again incremented by three. The data is retrieved, the instruction is executed, and “ 7 ” is written on the screen. The next three instructions are executed exactly the same way. After the “ . ” has been written, the PC and IR look as follows: The opcode is decoded as a Stop instruction. The contents of the addressing
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: mode and the operand specifier are ignored. The fetch-execute cycle stops. Pep/7 Simulator Remember that the instructions are written in the Pep/7 machine language, which doesnt correspond to any particular CPUs machine language. We have just hand-simulated the program. Can we execute it on the computer? Yes, we can. Pep/7 is a virtual (hypothetical) machine, but we have a simulator for the machine. That is, we have a program that behaves just like the Pep/7 virtual machine behaves. To run a program, we enter the hexadecimal code, byte by byte with blanks between each, and end the program with zz . The simulator Program counter (CP) Instruction register (IR) 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 Program counter (CP) Instruction register (IR) 0 0 0 0 0 0 0 0 0 0 0 3 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 1 Program counter (CP) Instruction register (IR) 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0...
View Full Document

Ask a homework question - tutors are online