Question
Observing fetch, decode, and execute Recall from Chapter 5 that stepping through each machine language instruction involves three phases: fetch, decode, and execute. The first
Observing fetch, decode, and execute
Recall from Chapter 5 that stepping through each machine language instruction involves three phases: fetch, decode, and execute. The first two phases, fetch and decode, are the same for every instruction. Briefly, fetch copies the address from the program counter (PC) to the memory address register (MAR). This address is then used to fetch the contents of the instruction, which is placed in the memory data register (MDR). The instruction is copied from the MDR to the instruction register (IR). Finally, the address in the PC is incremented by 1. The decode phase extracts the four-bit opcode from the instruction in the IR, and sends it to the instruction decoder. The third phase, execute, is different for each instruction. For example, executing the instruction load x consists of three steps: (1) extract the address of x from the IR and copy it to the MAR, (2) fetch the contents at this address and copy it into the MDR, and (3) copy the contents of the MDR into the data register (R).
To observe the fetch/decode/execute cycle, load the file example1.mac into memory and select On from the Step Into menu (see Figure 9.4).
Figure 9.4 Turning on Step Into
As long as this item is checked, you will be able to step through a program but not run it. As you step into each instruction in memory, a description of the fetch cycle pops up in the pane at the lower-right of the window. Each click of the Step button now moves the black bar down through the instructions in the fetch cycle. Note the changes in the MAR and MDR as you go. When you get to the execute phase, you may see changes to the ALU registers as well. If you wish to turn off this feature so that you can step through a program more quickly or run it, just select On from Step Into again. Briefly describe your observations.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started