Chapter4_2017SemIIEEngstd (1)
Chapter4_2017SemIIEEngstd (1)
1
Outline
3.1 Introduction
What is an Instruction Set ?
3.2 Machine Instruction Characteristics
Elements of Machine Instruction
Operand Locations
Instruction Representation
Instruction Types
3.3 Instruction Set Design
Types of Operands
Types of Operations
Addressing Mode
Instruction Format
3.4 Instruction Cycle Revisited
3.5 Instruction Cycle Data Flow
3.6 Processor Structure and Function
Processor Organization
Register Organization
3.7 Reading Assignment
2
1. INTRODUCTION
Much of the computer architecture/organization is hidden
from a high level language programmer
Shouldn’t care what the underlying architecture really is
Each instruction must contain all the information required by the CPU for execution
These elements are :
Operation code (Op code)
Specifies the operation to be performed
Do this operation
Source Operand(s) reference(s)
Specifies a register or memory location of operand data
With this/these operands
An operation may involve one or more source operands
Inputs for the operation specified
ELEMENTS OF A MACHINE INSTRUCTION…
ADD R, Y
It is possible to write a machine language program in symbolic form
A simple program accepts this symbolic input ,convert opcode and operand
references to binary form and construct binary machine instruction
INSTRUCTION TYPES
An instruction set must be functionally complete
Sufficient enough to express any of the instructions from a high
level language
Categories of instruction types
Data processing
Arithmetic and logic instructions
Data storage
Memory instructions
Data movement
I/O instructions
Control
Logical
Conversion
I/O
System Control
Transfer of Control
DATA TRANSFER
o May include
o Increment
o Decrement
o Negate
o Absolute
LOGICAL
Operations that manipulate individual bits of a word
Bitwise operations
AND, OR, exclusive-OR (XOR)
NOT (one’s complement)
In addition a variety of shifting and rotating functions
Logical shift
Shifts bits of word either to the left or right
On one end the bit shifted out is lost
Arithmetic shift
Treats the data as a signed integer and does not shift the sign bit
Rotate/Cyclic shift
Preserves all of the bits being operated on
SHIFT AND ROTATE OPERATIONS
.
logical shift shift in 0
Rotate
CONVERSION
TRANSFER OF CONTROL
Alter the flow of program
i.e. change the sequence of instruction execution
Update the PC to a specific address
Most common such type of operations are:
Branch, Skip, Procedure call
TRANSFER OF CONTROL…
Branch
• Also called jump instruction
• Its operand is the address of the next instruction to be fetched
and executed
Two types of branches
Conditional and Unconditional
Conditional Branch
A branch is made if certain condition is met
E.g.
BRP X
Branch to instruction at location X if result is positive
BRZ X
Branch to instruction at location X if result is zero
BRE R1,R2,X
Branch to X if contents of R1 is equal to contents of R2
Unconditional branch
E.g.
BR X
Branch to instruction at location X
TRANSFER OF CONTROL…
Branch Instructions
TRANSFER OF CONTROL …
Skip
.
TRANSFER OF CONTROL …
.
TRANSFER OF CONTROL …
.
ADDRESSING MODES
The manner in which each address field specify operand location
Notations:
Virtually all computer architectures provide more than one type addressing
modes
The processor can used different approaches to determine which addressing mode
is being used in a particular instruction
Different opcodes will use different addressing modes
One or more bits in the instruction format can be used as a mode field
Determines which addressing mode is to be used
ADDRESSING MODES…
Direct e.g.?
Indirect e.g.?
Register e.g.?
Stack e.g.?
IMMEDIATE ADDRESSING
The instruction itself contains the operands value
Operand is part of instruction
Operand =A
E.g. ADD 5
Add 5 to contents of accumulator
5 is operand
No additional memory reference required after the fetch of the
instruction itself
The value that can be specified is limited
Size/value of the operand is limited/limited range
Fast
IMMEDIATE ADDRESSING DIAGRAM
. Opcode Operand
DIRECT ADDRESSING
Address field contains address of operand
Effective address EA = A
Operand = (A)
E.g. ADD A
Add contents of memory location A to accumulator
One more memory access needed to fetch the operand
No additional calculations required to work out effective address
Number of memory locations that can be referenced, limited, due to
limited width of the field
Limited address space
Common on earlier generation of computers
DIRECT ADDRESSING DIAGRAM
.
INDIRECT ADDRESSING
A (the address field) refers to a memory location which contains the
address of operand
Multiple (two) memory accesses to find operand
Fetch EA
Fetch operand
Access the memory twice, hence slower
EA = (A)
Operand = ((A))
E.g. ADD (A)
Look in A, find address (A) and look there for operand
Range of EA increased
Large address space
2n ,where n = word length
INDIRECT ADDRESSING DIAGRAM
.
REGISTER ADDRESSING
Similar to direct addressing
The address field refers to a register than a main memory address
EA = R
Operand = (R )
Very small address field needed
Shorter instructions
Faster instruction fetch
No memory access required
Very fast execution
Very limited address space
Small number of registers can be referenced
REGISTER ADDRESSING DIAGRAM
.
REGISTER INDIRECT ADDRESSING
Similar to indirect addressing mode
Operand is in memory pointed to by contents of register R
EA = (R)
Operand =((R ))
Large address space (2n)
Where n is the width of the register
Address space limitation overcome
Uses one less memory access than indirect addressing
REGISTER INDIRECT ADDRESSING
DIAGRAM
.
DISPLACEMENT ADDRESSING
Very powerful addressing mode
Combines
It defines the layout of the bits of an instruction, in terms of its constituent parts
More that one format used in a given instruction set
What are the factors affecting the instruction format ?
READING ASSIGNMENT!!!
3.4 INSTRUCTION CYCLE REVISITED
Instruction cycle so far consists of the following sub cycles:
Fetch
Execute
Interrupt
MBR
PC
IR
Register transfers
ALU operations
DATA FLOW (INTERRUPT)
Simple and Predictable
Current PC saved to allow resumption after interrupt
Contents of PC copied to MBR
Special memory location (e.g. stack pointer) loaded to MAR
MBR written to memory
PC loaded with address of interrupt handling routine
Next instruction (first of interrupt handler) can be fetched
DATA FLOW (INTERRUPT DIAGRAM)
.
3.6 Processor Structure and Function
Processor Organization
To understand the organization of the CPU, recall the
requirements placed on the CPU:
Fetch instruction
Interpret instruction
Fetch data
Process data
Write data
To do all these things
Processor needs to store data temporarily
Temporary data storage locations --- Registers --- are needed
PROCESSOR ORGANIZATION…
Simplified view of a CPU
Indicates its connection to the system via the system bus
PROCESSOR ORGANIZATION…
Detailed view of a CPU
Indicates
CONDITION CODES
Sets of individual bits , also called flags
Each bit set by CPU hardware as the result of operations:
E.g. Arithmetic operation results could be
Positive, negative, zero, overflow
Can be read (implicitly) by programs
e.g. Jump if zero
Can not (usually) be set by programs
CONTROL & STATUS REGISTERS
58