Chapter3_2016SemIIEEngStd (1)
Chapter3_2016SemIIEEngStd (1)
3.1 Introduction
What is an Instruction Set ?
3.2 Machine Instruction Characteristics
Elements of Machine Instruction
Operand Locations
Instruction Representation
CHAPTER 3 Instruction Types
THE CENTRAL PROCESSING UNIT 3.3 Instruction Set Design
Types of Operands
(CPU)
Types of Operations
Addressing Mode
Instruction Format
3.4 Instruction Cycle Revisited
3.5 Instruction Cycle Data Flow
1
3.6 Processor Structure and Function
Processor Organization
Register Organization
2
3.7 Reading Assignment
When you have done that, do this... Implicitly referenced, if only one register exist
In most cases not explicitly stated in the instruction Explicitly using its unique number, if more than one
Implicitly the next instruction, the one that logically register exists
follows the current one in the program Immediate
I/O device
15 16
Note: The “type” of a unit of data is determined by the operation
being performed on it
DATA TRANSFER ARITHMETIC
Most fundamental type of instructions Performed by ALU
Must specify the following things Basic arithmetic operations provided by most
Location of source and destination operands machines are:
memory, register … Add, Subtract, Multiply, Divide
Length of data to be transferred Signed Integer
Full word, half word … Floating point
Addressing mode of each operand May include
E.g. Increment
Move, Store, Load, Push, Pop Decrement
In terms of CPU action Negate
data transfer operations are the simplest type Absolute
17 18
logical
Operations that manipulate individual bits of a word shift
Bitwise operations
AND, OR, exclusive-OR (XOR)
shift in 0
NOT (one’s complement)
In addition a variety of shifting and rotating functions
Logical shift arithmetic
Shifts bits of word either to the left or right
On one end the bit shifted out is lost
shift
Arithmetic shift keep sign !
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 rotate
19 20
CONVERSION INPUT/OUTPUT
Change the format of data or operate on the Transfer data
format of data from the computer to peripheral devices
Binary to Decimal From peripheral devices to the computer system
ASCII to EBCDIC
To be seen in detail in another chapter
E.g. Binary to BCD
binary 00001111 (1510)
packed BCD 0001 0101
1 5
21 22
23 24
TRANSFER OF CONTROL… TRANSFER OF CONTROL…
Branch Branch Instructions
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. 25 26
BR X
Branch to instruction at location X
29 30
Notations:
A = Contents of an address field in the instruction
R = Contents of an address field in the instruction that refers to a register
(X) = Contents of memory location X or register X
EA =Effective address of the location containing the referenced operand
Note:
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
31 One or more bits in the instruction format can be used as a mode field 32
Determines which addressing mode is to be used
ADDRESSING MODES… IMMEDIATE ADDRESSING
Types of addressing modes The instruction itself contains the operands value
Immediate Operand is part of instruction
Direct Operand = A
Indirect E.g. ADD 5
Register Add 5 to contents of accumulator
Register Indirect 5 is operand
Displacement No additional memory reference required after
Stack the fetch of the instruction itself
The value that can be specified is limited
Size/value of the operand is limited/limited range
33
Fast 34
Operand =((R ))
+ Operand
45 46
47 48
INDEXED ADDRESSING… STACK ADDRESSING
Combinations A stack
Indirect addressing with indexing The stack mode of addressing is a form of implied
addressing
The machine instructions need not include a memory
Post indexing reference but implicitly operate on the top of the
The indexing performed after the indirection stack
EA = (A) + (R)
Good to access a block of data of a fixed format
Pre indexing
The indexing performed before the indirection
EA = (A+(R))
Used to construct a multiway branch table 49 50
51 52
3.4 INSTRUCTION CYCLE REVISITED INSTRUCTION CYCLE ,REVISED …
Instruction cycle so far consists of the following Indirect addressing
sub cycles: May require memory access to fetch operands
Fetch Indirect addressing requires more memory accesses
Execute Can be thought of as additional instruction subcycle
Interrupt
53 54
57 58
May include
Memory read/write
Input/Output
Register transfers
ALU operations
59 60
DATA FLOW (INTERRUPT) DATA FLOW (INTERRUPT DIAGRAM)
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
61 62
Process data
Write data
needed 63 64
PROCESSOR ORGANIZATION… REGISTER ORGANIZATION
Detailed view of a CPU Registers
Indicates CPU must have some working space
Data transfer and logic control paths Temporary storage
Internal processor bus Top level of memory hierarchy
Used to transfer data b/n the ALU and various registers
Number and function vary between processor designs
One of the major design decisions
65 66
67 68
USER VISIBLE REGISTERS… USER VISIBLE REGISTERS…
General Purpose Registers Address registers
Can be assigned variety of function by the Hold addresses
programmer Can be
May be true general purpose General purpose or
May be restricted Devoted to particular addressing mode
Index registers, stack pointer, segment register
May be used for data or addressing
Data Registers
Used only to hold data
Accumulator
69 70
71 72
CONTROL & STATUS REGISTERS…
Program Status Word (PSW)
A register that contain status information
Usually contains
Condition codes
Status information
END of Chapter 3
Common fields or flags include
Sign, zero, carry, equal, overflow, supervisor, interrupt
enable/disable