Back to 课程

Computer Science AS OCR

0% Complete
0/0 Steps
  1. 1-1-structure-and-function-of-the-processor as
    5 主题
  2. 1-2-types-of-processor as
    3 主题
  3. 1-3-input-output-and-storage as
    2 主题
  4. 2-1-systems-software as
    8 主题
  5. 2-3-software-development as
    5 主题
  6. 2-4-types-of-programming-language as
    4 主题
  7. 3-1-compression-encryption-and-hashing as
    3 主题
  8. 3-2-databases as
    3 主题
  9. 3-3-networks as
    8 主题
  10. 3-4-web-technologies as
    13 主题
  11. 4-1-data-types as
    8 主题
  12. 4-2-data-structures as
    4 主题
  13. 4-3-boolean-algebra as
    1 主题
  14. 5-1-computing-related-legislation as
    4 主题
  15. 5-2-moral-and-ethical-issues as
    9 主题
  16. 6-1-thinking-abstractly as
    3 主题
  17. 6-2-thinking-ahead as
    1 主题
  18. 6-3-thinking-procedurally as
    3 主题
  19. 6-4-thinking-logically as
    2 主题
  20. 6-5-thinking-concurrently as
    2 主题
  21. 7-1-programming-techniques as
    9 主题
  22. 8-1-standard-algorithms-and-big-o-notation as
    8 主题
课 Progress
0% Complete

Exam code:H046

Fetch-Decode-Execute Cycle

What is the fetch-decode-execute cycle?

  • The fetch-decode-execute cycle (FDE cycle) is the process that the CPU goes through repeatedly to process instructions

  • There are 3 stages:

    • Fetching an instruction from memory – supplying the address and receiving the instruction from memory

    • Decoding the instruction – interpreting the instruction and then reading and retrieving the required data from their addresses

    • Executing the instruction – the CPU carries out the required action

Examiner Tips and Tricks

  • You’ll need to know how to write assembly language using the Little Man Computer instruction set but now we’re just covering how the registers are used in assembly language

Which registers are used in the CPU during the FDE cycle?

  • In the section below registers and CPU components appear in bold and assembly language is in italics

  • During the FDE cycle, the following steps happen:

  • Fetch

    • The PC is loaded with 0

    • The value from the PC (0) is copied to the MAR

    • The data from the MAR (0) is sent across the address bus with the instruction to read the data sent across the control bus

    • The data from that location in memory (0) is sent down the data bus to the MDR 

    • The PC is incremented by 1

  • Decode

    • The data is sent from the MDR to the CIR where it is split into the opcode and operand

    • This is sent to the CU to be decoded

  • Execute

    • Which registers are used here will depend on the instruction being executed

      • If a value is being inputted (INP) the ACC will store the value

      • If a value is being outputted (OUT) this will be the value currently in the ACC

      • If a value is loaded from RAM (LDA) this will be sent across the data bus from RAM (in the address location in the MAR) to the MDR

      • If a value is to be stored (STA) it will take the value from the ACC, send it to the MDR and then send it across the data bus to RAM (to the address location in the MAR)

      • If a value is being added to or subtracted from another value (ADD/SUB) the values will be passed to the ALU, the operation will be carried out, and the result will be stored in the ACC

      • If the LMC code is to branch (BRA/BRZ/BRP) the comparison will take place in the ALU

Worked Example

A program written in the Little Man Computer instruction set is given below.

 INP STA num
loop LDA total ADD num STA total LDA count ADD one STA count SUB num BRZ end BRA loop
end LDA total OUT HLT
one DAT 1
num DAT 0
count DAT 0
total DAT 0

Explain which registers are used and their values when the line STA count is executed and the accumulator is holding the value 9. The label count refers to memory location 16.

[2]

How to answer this question:

  • The instruction being executed in this example is STA count, so the registers used will be:

    • ACC – the accumulator is holding the value “9”

    • MDR – the value “9” from the ACC will be copied to the MDR

    • MAR – the value 16 will be stored here so the data is sent to memory location 16

  • The value that’s in the accumulator (ACC) is going to be stored in memory (RAM)

  • To work out where in memory it will be stored we need to know what count represents

  • In this question, we’ve been told it’s 16 – “the label count refers to memory location 16″

  • You’re not always told this in your exam, so you should also be able to count the lines of code

  • It’s best to write the line numbers on the code in the question, to see which line count is on. (Don’t forget that the first line is memory location 0!)

  • “Count DAT 0 “is on line 16, so the value “16” is what goes to the MAR register. (You already know this from the question above)

  • It is always the value from the accumulator (ACC) that is stored, so the value “9” must go to the MDR as data can only be sent to memory from the MDR

  • Then the value is sent to the memory location, in this case 16

Answer:

 Example answer that gets full marks:

The contents of the accumulator (9 in this case) will be copied to the MDR [1 mark] and then 9 is copied to location 16. [1 mark]

Acceptable answers you could have given instead:

The value 16 is copied to the MAR. [1 mark]

Examiner Tips and Tricks

  • When answering a question about registers be specific about the contents of the register based on the question to make sure you get the marks

  • If your answer to the question above didn’t include the values 16 and 9 then you wouldn’t get the marks despite knowing which registers are used. This is because the question is asking you which registers are used and their values when the line STA count is executed

Responses

您的邮箱地址不会被公开。 必填项已用 * 标注