COMPILER DESIGN

ADVANCED TOPICS IN COMPILER DESIGN

CODE GENERATION FOR OBJECT ORIENTED LANGUAGES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
A program has been stored in memory and is ready to be executed. The three steps in the fetch-decode-execute cycle are shown below. The program counter is a counter that stores the memory location of the next instruction to be executed.Executing the instruction Fetching and decoding the instruction Incrementing the program counter. Assume the three-step cycle for the previous instruction has just completed. In which of the following orders must these three steps be performed to complete the next instruction?
A
Fetch and decode the instruction; execute the instruction; increment the program counter
B
Fetch and decode the instruction; increment the program counter; execute the instruction
C
Increment the program counter; execute the instruction; fetch and decode the instruction
D
Execute the instruction; increment the program counter; fetch and decode the instruction
Explanation: 

Detailed explanation-1: -It is composed of three main stages: the fetch stage, the decode stage, and the execute stage.

Detailed explanation-2: -The CPU works by following a process known as ‘fetch, decode and execute’. The CPU fetches an instruction from memory, decodes this instruction and then executes it. The CPU carries out this cycle continuously, millions of times per second.

Detailed explanation-3: -A program counter is a register in a computer processor that contains the address (location) of the instruction being executed at the current time. As each instruction gets fetched, the program counter increases its stored value by 1.

Detailed explanation-4: -The correct answer is Fetch instruction, Decode instruction, Read operands, Execute instruction and Store data.

There is 1 question to complete.