Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A program is stored from address 60. Address 70 holds 25 and address 71 holds 16. The PC holds 60 at the start.
The CPU runs the program until the STOP instruction has been fetched and decoded. Find the value at address 70 at the end, the value in the PC at the end, and how many times an address is put into the MAR.
Fetch: the PC is copied to the MAR and the address goes along the address bus. The instruction comes back along the data bus to the MDR. It is copied to the CIR and the PC is incremented. Decode: the CU decodes the instruction in the CIR. Execute: the instruction is carried out. The MAR and MDR are used for any data, the ALU for any calculation and the ACC for the result.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Step 1. The values. LOAD 70 puts in the ACC. ADD 71 makes it . STORE 70 writes over the old value at address 70.
Step 2. The PC. Four instructions are fetched, at addresses 60, 61, 62 and 63. Each fetch adds 1 to the PC, so it ends at .
Step 3. The MAR in the fetch stages. Each of the four fetches puts the instruction's address into the MAR: 60, 61, 62, 63. That is 4 times.
Step 4. The MAR in the execute stages. LOAD 70 puts 70 into the MAR, ADD 71 puts 71, and STORE 70 puts 70 again. STOP needs no memory. That is 3 more times.
Answer: address 70 holds 41, the PC holds 64, and the MAR is loaded times.
Check. The program adds the two numbers and saves the sum where the first number was. The first number is lost, which is what STORE 70 means.
Log in to join the discussion.
Loading…