You are on page 1of 42

Instruction Set Architecture

Lecture 4
Outline

• Components of Instruction
• Types of Instruction
• Characteristics and Functions
• Addressing Mode and Formats
• Instruction Formats and Power PC Addressing

BTECH 2306 Computer Architecture 2


What is Instruction Set?

User Lever: Application Program


High-Level Language
Assembly Language/Machine Code
Microprogrammed/Hardwired Control
Functional Units (Memory, ALU, etc)
Logic Gates
Transistors and Wires

BTECH 2306 Computer Architecture 3


Instruction Representation

• In machine code each instruction has a unique bit pattern.


• Symbolic representation is used.
– e.g. ADD, SUB, LOAD, STOR

• Operands can also be represented in this way


– ADD A,B

BTECH 2306 Computer Architecture 4


Simple Instruction Format

BTECH 2306 Computer Architecture 5


Instruction Type

• Data processing
• Data storage
• Data movement
• Program flow control

BTECH 2306 Computer Architecture 6


Number of Addresses

• Three (3) addresses


• Two (2) Addresses
• One (1) Address
• Zero (0) Address

BTECH 2306 Computer Architecture 7


Three (3) Addresses

• Operand 1, Operand 2, Result


• a = b + c;
• May be a forth - next instruction (usually implicit)
• Not common
• Needs very long words to hold everything

BTECH 2306 Computer Architecture 8


Three (3) Addresses

• Instruction Comment
SUB Y, A, B Y A– B
MPY T, D, E T DxE
ADD T, T, C T T+C
DIV Y, Y, T Y YT

BTECH 2306 Computer Architecture 9


Two (2) Addresses

• One address doubles as operand and result


• a=a+b
• Reduces length of instruction
• Requires some extra work
• Temporary storage to hold some results

BTECH 2306 Computer Architecture 10


Two (2) Addresses

• Instruction Comment
MOVE Y, A Y A
SUB Y, B Y Y–B
MOVE T, D T D
MPY T, E T TxE
ADD T, C T T+C
DIV Y, T Y YT
BTECH 2306 Computer Architecture 11
One (1) Address

• Implicit second address


• Usually a register (accumulator)
• Common on early machines

BTECH 2306 Computer Architecture 12


One Address
Instruction Comment
LOAD D AC D
MPY E AC AC x E
ADD C AC AC + C
STOR Y Y AC
LOAD A AC A
SUB B AC AC - B
DIV Y AC AC  Y

BTECH 2306 Computer Architecture 13


Zero (0) Address

• All addresses implicit


• Uses a stack
• e.g. push a
• push b
• Add

BTECH 2306 Computer Architecture 14


How Many Addresses?
• More addresses
– More complex instructions
– More registers
– Fewer instructions per program

• Fewer addresses
– Less complex instructions
– More instructions per program
– Faster fetch/execution of instructions

BTECH 2306 Computer Architecture 15


Addressing Modes

• Immediate
• Direct
• Indirect
• Register
• Register Indirect
• Displacement (Indexed)
• Stack

BTECH 2306 Computer Architecture 16


Immediate Addressing
• Operand is part of instruction
• Operand = address field
• e.g. ADD 5
– Add 5 to contents of accumulator
– 5 is operand

• No memory reference to fetch data


• Fast
• Limited range

BTECH 2306 Computer Architecture 17


Immediate Addressing Diagram

BTECH 2306 Computer Architecture 18


Direct Addressing

• Address field contains address of operand


• Effective address (EA) = address field (A)
• Single memory reference to access data
• No additional calculations to work out
effective address
• Limited address space
BTECH 2306 Computer Architecture 19
Direct Addressing Diagram

BTECH 2306 Computer Architecture 20


In-direct Addressing

• Memory cell pointed to by address field


contains the address of (pointer to) the operand
• EA = (A)
– Look in A, find address (A) and look there for
operand

BTECH 2306 Computer Architecture 21


In-direct Addressing

• Large address space


• 2n where n = word length
• May be nested, multilevel, cascaded
• Multiple memory accesses to find operand
• Hence slower

BTECH 2306 Computer Architecture 22


In-direct Addressing Diagram

BTECH 2306 Computer Architecture 23


Register Addressing
• Operand is held in register named in address filed
• EA = R
• Limited number of registers
• Very small address field needed
– Shorter instructions
– Faster instruction fetch

BTECH 2306 Computer Architecture 24


Register Addressing

• No memory access
• Very fast execution
• Very limited address space
• Multiple registers helps performance
• c.f. Direct addressing

BTECH 2306 Computer Architecture 25


Register Addressing Diagram

BTECH 2306 Computer Architecture 26


Register Indirect Addressing
• C.f. indirect addressing
• EA = (R)
• Operand is in memory cell pointed to by contents of
register R
• Large address space (2n)
• One fewer memory access than indirect addressing

BTECH 2306 Computer Architecture 27


Register Indirect Addressing
Diagram

BTECH 2306 Computer Architecture 28


Important in Instruction set Design

• Operation repertoire
– How many operation to provide and how
complex operation should be.

BTECH 2306 Computer Architecture 29


Important in Instruction set Design
• Data types
– Various types of data upon which operations are
performed.
• Instruction format
– Instruction length, number of addresses, size of various
fields, and so on.

BTECH 2306 Computer Architecture 30


Important in Instruction set Design
• Registers
– Number of processor registers that can be referenced by
instructions.
• Addressing
– Mode or modes by which the address of an operand is
specified.

BTECH 2306 Computer Architecture 31


Types of Operand

• General Categories of Data


– Addresses
– Numbers
– Characters
– Logical Data

BTECH 2306 Computer Architecture 32


Numbers

• Three types of numerical data in


computers:
– Integer or Fixed point
– Floating point
– Decimal

BTECH 2306 Computer Architecture 33


Characters

• Code devised by which characters are represented by


a sequence of bits:
– Morse code
– International Reference Alphabet
– American Standard Code for International Interchange
– Extended Binary Coded Decimal Interchange Code

BTECH 2306 Computer Architecture 34


Logical Data

• Two advantages of logical data:


– Storing the value of Boolean.
– Convert from IRA to packed decimal, need to
extract the rightmost 4 bits of bytes.

BTECH 2306 Computer Architecture 35


Types of Operation

• Data Transfer
• Arithmetic
• Logical
• Conversion
• I/O
• System Control
• Transfer of Control

BTECH 2306 Computer Architecture 36


Data Transfer

• Specify
– Source
– Destination
– Amount of data

• May be different instructions for different movements


• Or one instruction and different addresses

BTECH 2306 Computer Architecture 37


Arithmetic

• Add, Subtract, Multiply, Divide


• Signed Integer
• Floating point
• Logical
• Conversion

BTECH 2306 Computer Architecture 38


Input/Output

• May be specific instructions


• May be done using data movement instructions
(memory mapped)
• May be done by a separate controller (DMA)

BTECH 2306 Computer Architecture 39


System Control

• Privileged instructions
• CPU needs to be in specific state
• For operating systems use

BTECH 2306 Computer Architecture 40


Transfer of Control

• Branch
• Skip
• Subroutine call

BTECH 2306 Computer Architecture 41


End of Lecture

You might also like