lec 2.0 - the instruction execution process

Download Report

Transcript lec 2.0 - the instruction execution process

INSTRUCTION EXECUTION PROCESS
A
digital computer is a sequential machine.
 The CPU (microprocessor) executes
instructions in a sequence as specified by
the program.
 In general terms the instructions are
executed in the sequence they are written.
 However a certain class of instruction (jump,
interrupt) can vary the instruction execution
sequence.
 Upon
completing this topic, you should
be able to:
• Explain the instruction format
• State the instruction cycles stages
• Describe the instruction fetching process
• Illustrate the instruction execution process
 Instructions
are stored in program memory in
binary coded form.
 Since
an instruction must represent a complete
and unambiguous statement of the operation
required by the processor, therefore 8-bits (the
number of bits of a single memory location) is
often insufficient to specify the complete
instruction.
 Depending on the particular
instruction, 8085A instructions
occupy one, two or three
successive memory locations (or
bytes).
 The
first byte of an instruction is called the
Opcode (Operation Code)
 The other bytes of an instruction is called
the data to be operated on (operand)
 The Opcode describes :
• The operation to be carried out
e.g: move data, arithmetic operation, logical
operation, etc
• Where the source data is located in the computer
• The destination for the result of the operation
• How many bytes constitute the complete instruction
Consider the instruction:
STA addr
 Opcode in assembly language form
STA
 Opcode in machine language form (i.e. the bits that
are actually stored in memory) 00110010 (32H)


The opcode specifies :
•
•
•
•

Data is to be moved
The source of the data is the CPU register A
The destination for the data is external memory
The complete instruction is three bytes long
Bytes 2 & 3 of the instruction specify the address of
the memory location where the data is to be written
 There
are two stages to the complete
execution of an instruction :
Stage 1 : CPU fetches the instruction from memory
Stage 2 : CPU executes the instruction
 Processor
put the address
of where the instruction is
stored onto address bus
 Processor asserts the read
control line
 The memory device places
the data at the addressed
location onto the data bus
 The processor reads the
instruction byte.

Once read from memory, the opcode of the instruction is
stored in the instruction register (an 8-bit register) of the
CPU.

The contents of the instruction register is read by the
instruction decoder.

The instruction decoder configures the control logic so
that the particular sequence of CPU operations are
carried out to complete execution of the instruction.
 This
will include fetching the remaining bytes
of an instruction, if the instruction is a multibyte
instruction.
 The
second ( and third ) bytes of a multibyte
instruction are accessed by the CPU in exactly
the same way as the opcode is fetched from
memory.
 The second ( and third ) bytes of an instruction
are stored in temporary registers in the CPU.

•
•
•
•
•
•
•
•
•
•
The following are the sequence of operations the processor is
required to perform to execute the instruction
STA addr
Place program counter onto address bus
Assert RD control signal
Read opcode and load into instruction register
Decode the opcode
Place program counter onto address bus
Assert RD control signal
Read byte 2 and save in temp register W
Place program counter onto address bus
Assert RD control signal
Read byte 3 and save in temp register X
; opcode address
; PC incremented
; address of byte 2
; PC incremented
; address of byte 3
; PC incremented


•
•
•
The whole of the instruction has been fetched at this stage. The
8-bit temporary registers W & X contain the 16-bit address of
the memory location at which the contents of CPU register A is to
be stored.
The execution phase of the instruction can now take place.
Place the contents of W & X onto the
address bus
Place the contents of register A onto
data bus
Assert WR control signal
; specify memory address
; data to be written
; write data to memory