Sie sind auf Seite 1von 11

IntructionIntruction CycleCycle (F(Fetcetchh--EExecutexecute CCycycllee))

The sequence of actions that a CPU

performs to execute each machine code instruction in a program.

• The Instruction Fetch Execute Cycle can be broken down into the following steps:

1. Fetch Cycle

2. Decode Cycle

3. Execute Cycle

4. Interrupt Cycle

IntructionIntruction CycleCycle (F(Fetcetchh--EExecutexecute CCycycllee))

START Fetch next instruction
START
Fetch next
instruction
Decode instruction Execute instruction Interrupt ? END
Decode
instruction
Execute
instruction
Interrupt ?
END

FetchFetch CycleCycle

• The fetch cycle begins with retrieving the address stored in the Program Counter (PC). This is the memory address of the instruction to be executed.

The CPU fetches the instruction stored at this address from the memory and transferring this instruction to Instruction Register (IR).

• The program counter is incremented to point to the next address from which the new instruction is to be fetched.

DecodeDecode CycleCycle

From the instruction register, the data forming the instruction is decoded by the instruction decoder.

• The Opcode of the instruction are being determined.

• The operands are retrieved from the addresses as needed by the Opcode.

ExecuteExecute CycleCycle

The decoded information is used by Control Unit to perform the operation required by the instruction. • Ex: reading values from registers, passing values to the ALU, adding valus etc.

• The result generated by the operation is stored in the main memory, registers, or sent to an output device.

InterruptInterrupt CycleCycle

• An interrupt can occur any time during the program execution.

Whenever it is caused, a series of events take place so that the instruction fetch execute cycle can again resume after the interrupt.

• Therefore, when an interrupt occurs, the following steps are performed:

1. Suspend the execution of current instruction.

2. Push the address of current instruction on the Stack Pointer (SP).

3. Loading the PC with the address of the interrupt handler.

4. Perform the interrupt routine.

5. Once the execution of the interrupt handler complete, the address of the next instruction to be executed is obtained from popping the value of the address in the Stack Pointer.

6. Resume the suspended instruction execution.

• This cycle of fetching a new instruction, decoding it and finally executing it continues until the computer is turned off.

Instruction Cycle / Machine Cycle

Instruction Cycle: The time required to execute an instruction.

When the 8085 processor executes an instruction, it will execute some of the machine cycles in a specific order.

Machine Cycle: The time required to access the memory or input/output devices.

• The 8085 microprocessor has 5 basic machine cycles:

1.Opcode fetch cycle (4T) 2.Memory read cycle (3T) 3.Memory write cycle (3T) 4.I/O read cycle (3T) 5.I/O write cycle (3T)

T-State: The time taken by the processor to execute a machine cycle is expressed in T-states.

• 1 T-state = 1/ operating frequency of 8085 Microprocessor

– For example operating frequency = 2MHz, then time required to execute 1 T-state = 0.5 uSec

Example: Calculate time required to execute instruction MOV C, A

sol: This instruction has one machine cycle i.e. opcode fetch (In any instruction 1st cycle is always opcode fetch and opcode fetch consists 4 to 6 T state depend on the operation of particular instruction) So to execute MOV C, A required 4T states so time required to execute this instruction is 4*0.5usec = 2usec

• Example:Calculate the time required to execute LXI H,2000H

sol: Here we have to draw opcode fetch and two memory reads as two bytes 00H and 20H have to be read from memory. i.e, opcode fetch+Memory reads *2(bytes address) =4+3+3

So to execute LXI H,2000H,the required T-states is 10T and time is

10*0.5usec=5usec

Timing Diagram

• Timing Diagram is a graphical representation which represents the execution time taken by each instruction in a graphical format.

The timing diagram of an instruction are obtained by drawing the timing diagrams of the machine cycles of that instruction, one by one in the order of execution.

• The execution time is represented in T-states.

• The T-state starts at the falling edge of a clock.

• Th e execu ti o n tim e i s r ep r ese nt

Timing diagram for MVI B, 43H.

Timing diagram for MVI B, 43H. Opcode fetch cycle (4T) M emory rea d cycle Status
Timing diagram for MVI B, 43H. Opcode fetch cycle (4T) M emory rea d cycle Status

Opcode

fetch

cycle

(4T)

Opcode fetch cycle (4T)

Memory read cycle

Status signals:

(3T)

IO/M(bar) :

Memory write

cycle

1(I/O) 0 (Memory)

S1 | S0 |

0

| 0 | Halt

(3T)

I/O read cycle

(3T)

0

| 1 | Write

I/O write

1

| 0 | Read

cycle

1

(3T)

| 1 | Opcode fetch

• Fetching the Opcode 06H from the memory 2000H. (OF machine cycle)

• Read (move) the data 43H from memory 2001H. (memory read)

• ALE - Address Latch Enable. This signal helps to capture the lower order address presented on the multiplexed address / data bus.

Timing diagram for STA 526AH

Timing diagram for STA 526AH Opcode fetch cycle (4T) Memory read cycle Status signals: (3T) IO/M(bar)
Timing diagram for STA 526AH Opcode fetch cycle (4T) Memory read cycle Status signals: (3T) IO/M(bar)
Timing diagram for STA 526AH Opcode fetch cycle (4T) Memory read cycle Status signals: (3T) IO/M(bar)

Opcode

fetch

cycle

(4T)

Memory read cycle

Status signals:

(3T)

IO/M(bar) :

Memory write cycle

I/O read cycle

(3T)

1(I/O) 0 (Memory)

S1 | S0 |

0

| 0 | Halt

(3T)

W i

0

|

1

|

r te

I/O write

1

| 0 | Read

cycle

1

(3T)

| 1 | Opcode fetch

• STA means Store Accumulator -The contents of the accumulator is stored in the specified address (526A).

• The opcode of the STA instruction is said to be 32H. It is fetched from the memory 41FFH

• Then the lower order memory address is read(6A). - Memory Read Machine Cycle

• Read the higher order memory address (52).- Memory Read Machine Cycle

• The combination of both the addresses are considered and the content from accumulator is written in 526A. - Memory Write Machine Cycle

• Assume the memory address for the instruction and let the content of accumulator is C7H. So, C7H from accumulator is now stored in 526A.

• ALE - Address Latch Enable. This signal helps to capture the lower order address presented on the multiplexed address / data bus.