Instruction Set Architecture

Dilum Bandara
Dilum BandaraResearch Scientist at Data61, CSIRO
Instruction Set
Architecture
CS2052 Computer Architecture
Computer Science & Engineering
University of Moratuwa
Dilum Bandara
Dilum.Bandara@uom.lk
Blocks of a Microprocessor
2
Literal
Address
Operation
Program
Memory
Instruction
Register
STACK Program Counter
Instruction
Decoder
Timing, Control and Register selection
Accumulator
RAM &
Data
Registers
ALU
IO
IO
FLAG &
Special
Function
Registers
Clock
Reset
Interrupts
Program Execution Section Register Processing Section
Set up
Set up
Modify
Address
Internal data bus
Source: Makis Malliris & Sabir Ghauri, UWE
Instruction Set Architecture (ISA)
3
Instruction Set
Software
Hardware
Source: Computer Architecture: A Quantitative Approach, J. L. Hennessy & D. A. Patterson, 3rd Edition.
ISA (Cont.)
 Part of computer architecture related to
programming
 Include native data types, instructions, registers,
addressing modes, memory architecture,
interrupt & exception handling, & external I/O
 e.g., R1, R2, …, PC
 e.g., MOV, ADD, INC, AND
 ISA specifies the set of opcodes (machine
language), & native commands implemented by
a particular processor
4
Well Known ISAs
 x86
 Based on Intel 8086 CPU in 1978
 Intel family, also followed by AMD
 X86-64
 64-bit extensions
 Proposed by AMD, also followed by Intel
 ARM
 32-bit & 64-bit
 Initially by Acorn RISC Machine
 ARM Holding
 MIPS
 32-bit & 64-bit
 By Microprocessor without Interlocked Pipeline Stages (MIPS)
Technologies 5
Well Known ISAs (Cont.)
 SPARC
 32-bit & 64-bit
 By Sun Microsystems
 PIC
 8-bit to 32-bit
 By Microchip
 Z80
 8-bit
 By Zilog in 1976
 Many extensions
 Intel – MMX, SSE, SSE2, AVX
 AMD – 3D Now!
6
A Good ISA
 Lasts through many implementations
 Portability, compatibility
 Used in many different ways
 Servers, desktop, laptop, mobile, tablet
 Provides convenient functions to higher layer
 Permit efficient implementation at lower layer
7
Example – Instructions
 Microprocessor that we are going to build will
support following 2 instructions
 ADD
 LOAD
8
Activating Necessary Blocks
9
Source: www.transtutors.com/homework-help/computer-
science/computer-architecture/cpu/general-register-organization/
Micro-operations
 Digital modules are best described by
 Registers they contain
 Micro-operations performed on data stored on those
registers
 Elementary operations done on data in registers
 Register Transfer Language
 Concise symbolic expressions
 ADD
 ADD RC, RA, RB RC  RA + RB
PC  PC + 1
 LOAD
 LOAD RA, d RA  d
PC  PC + 1 10
How to Describe a Computer
 Set of registers & their functions
 Sequence of micro-operations
 Controls that initiates & maintains sequence of
micro-operations
 Today, from a programming point of view,
Assembly is the lowest level we use to define
these registers, instructions, & their order of
execution
11
Programming in Assembly
 To program in Assembly we need
1. Knowledge about hardware design
 Registers
 Memory addressing
 I/O
2. Knowledge about instruction set
12
Registers (Review)
 Type of memory located inside CPU
 Can hold a single piece of data
 Useful in both data processing & control
functionalities
 Types
 Special purpose registers
 Program counter (PC)
 Instruction register (IR)
 Accumulator or working register (A or W)
 Flag register (FLAG or STATUS)
 General purpose registers
 No special name, typically A, B, C, ... Or R1, R2, R3, ... 13
Format of an Assembly Statement
14
[Identifier /
Label]
Operation/
Command/
Op code
[Operand(s)] [;Comment]
Labeling code or
to indicate a
program
destination
address for
jumps
What instruction to
be carried out by
CPU
Only valid
instructions are
allowed
Data or register
contents to be used
in instruction
Some instructions
don’t need operands
Explanatory text.
Optional but very
useful, as
Assembly
programs are
hard to
understand
L20: ADD RC, RA, RB ;RC  RA + RB
Example – Instruction Set
 We’ll use instruction set from PIC 16F87x for our
discussion
 Textbook doesn’t use a specific set
 Most other textbooks may use MIPS or x86
 They are still too complex to start with
 When you are more familiar, you can learn/use any
new instruction set
15
16
F file register
W working register
B bit
L literal (number)
Z conditional
execution
d destination bit
d=0 store in W
d=1 store in f
use , w or ,f instead
Source: Makis Malliris &
Sabir Ghauri, UWE
Opcode
 Determines the
instruction
 Registers, bits,
literals depend on
the opcode field
17
Source: PIC16F87X Data Sheet by
Microchip Technology Inc.
Assembler
 Assembler translates human readable code into
binary
 Binary code specifies opcode & operands
 ADDLW 135 means “add literal 135 to W register”
 Assembler converts this to 11 1110 1000 0111
 This is what the machine understands
18
Program Operations
 Load a register with a given number
 Copy data from register to another
 Carry out arithmetic & logical operations on a
data word or a pair of data words
 Test a bit or word & jump, or not, depending on
result of the test
 Jump to a point in the program
 Jump to a subroutine
 Carry out a special control operation
19
Instruction Classification
Instruction Types
 Data transfers
 Arithmetic, logic
 Rotates, shifts
 Bit set, bit reset, & bit test
 General-purpose, CPU
control
 Jumps
 Calls, returns
Instruction Function
 Move
 Register
 Arithmetic
 Logic
 Test & Skip
 Jump
20
Data Transfer Instructions
 Used to transfer data from one location to
another
 Register to Register, Register to Memory, Memory to
Register
 MOV
 MOVLW 3 ; W  03h
 MOVWF R1 ; R1  03h
 MOV is same as LDA (Load) in textbook
21
Arithmetic Instructions
 Used in arithmetic operations
 ADD – ADDWF R1 ; W  W + R1
 ADD – ADDLW 3 ; W  W + 3
 SUB – SUBLW 5 ; W  W - 5
 INC – INCF R1 ; R1  R1 + 1
22
ALU (Review)
 Data processing
unit
 Arithmetic unit
 Performs
arithmetic
operations
 Logic unit
 Performs logical
operations
23
Accumulator
Source: Introduction to PIC Microcontroller – Part 1 by Khan Wahid
Example – Arithmetic Instructions
 Write an assembly program to add 5 & 10
 Steps
 How many registers?
 What registers to use?
 What instructions are required?
 MOV – MOVLW 5 ; W  05h
 ADD – ADDLW 0xA ; W  05h + Ah
24
Logic Operations
 Used in bitwise logic operations
 AND – ANDLW 3 ; W  W & 0011
 OR – IORLW 3 ; W  W | 0011
 XOR – XORLW 3 ; W  W  1001
 NOT – COMF 0x20,1 ;(0x20)  (0x20)/
25
Example – Logic Operations
 Example
 Write an assembly program to convert a given
character from uppercase to lowercase & vice versa
 If we consider ASCII, this can be achieved by
changing the 5th bit
 A = 65 =0x41 = 0 1 0 0 0 0 0 1
 a = 97 =0x61 = 0 1 1 0 0 0 0 1
 Get XOR with 00100000 = 32 = 0x20
26
Transfer Instructions (Jump
Instructions)
 Can be used to jump here & there within program
 Can be used to control loops
 GOTO – GOTO loop ;go to loop label
 CALL – CALL delay ;call delay subroutine
27
Example – Transfer Instructions
 Example
 Write a program to calculate the total of all integers
from 1 to 10
 High-level program
28
int total = 0;
for (int i=1 ; i<=10; i++)
{
total += i;
}
Example – Transfer Instructions
(Cont.)
 Steps
 Are there any conditions/loops?
 How many registers?
 What registers to use?
 What instructions to use?
 ADDLW
 Increment/decrement instruction – INCF, DECF
 Let’s use memory address 0020h
29
Transfer Instructions (Cont.)
30
start movlw 0xa ; w  10
movwf 0x20 ; (0x20)  w
movlw 0 ; total
loop addwf 0x0020,0 ; Add
decf 0x0020,1 ; Dec counter
btfss STATUS,Z ; is counter 0?
goto loop ; repeat
nop
end
int total = 0;
for (int i=10 ; i!=0; i--)
{
total += i;
}
31
Homework
 Example
 Write an assembly program to multiply 3 & 4
 Steps:
 How many registers?
 What registers to use?
 What instructions to use?
 MOV – MOVLW 3 ; W  03h
 MUL – ???
Shift Operators >> <<
 Move all bits in a value by given no of positions to left or
right
10011011 01110110 10010011
>> 1 >> 3 >> 3
01001101 00001110 00010010
10011011 01110110
<<1 <<3
00110110 10110000
 Multiply by powers of 2 – value << n (value * 2n)
 e.g., 4 << 3 ; (4 * 8) =32
 Divide by powers of 2 – value >>=n (value / 2n)
 e.g., 75 >> 4; 75 / 16 =4
32
Rotate Through Carry
 RLF – Rotate Left f through Carry
 Suppose carry was 1
 RLF 9B  1 = 37
 RLF 9B  2 = 6F
 RRF – Rotate Right f through Carry
 Suppose carry was 1
 RRF 9B  1 = CD
 RRF 9B  2 = E6 33
Comparison Operations
 Comparing 2 numbers need to be treated with
care due to non-intuitive nature of Carry flag
movlw 2 ; W = 2
subwf Q, W ; W = Q - 2
btfss STATUS, C ; check carry flag
goto Gr_eq ; Q >= 2
goto Less ; Q < 2
34
1 of 34

Recommended

Computer Organisation & Architecture (chapter 1) by
Computer Organisation & Architecture (chapter 1) Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1) Subhasis Dash
2.3K views37 slides
Instruction Set Architecture (ISA) by
Instruction Set Architecture (ISA)Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA)Gaditek
6.1K views45 slides
Computer Organization and Architecture. by
Computer Organization and Architecture.Computer Organization and Architecture.
Computer Organization and Architecture.CS_GDRCST
22.8K views48 slides
Processor Organization and Architecture by
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and ArchitectureVinit Raut
15.6K views130 slides
Instruction set (prasenjit dey) by
Instruction set (prasenjit dey)Instruction set (prasenjit dey)
Instruction set (prasenjit dey)Prasenjit Dey
199 views28 slides
Computer architecture instruction formats by
Computer architecture instruction formatsComputer architecture instruction formats
Computer architecture instruction formatsMazin Alwaaly
7.9K views31 slides

More Related Content

What's hot

CISC & RISC Architecture by
CISC & RISC Architecture CISC & RISC Architecture
CISC & RISC Architecture Suvendu Kumar Dash
27.6K views42 slides
Types of instructions by
Types of instructionsTypes of instructions
Types of instructionsihsanjamil
103.6K views49 slides
General register organization (computer organization) by
General register organization  (computer organization)General register organization  (computer organization)
General register organization (computer organization)rishi ram khanal
2.8K views9 slides
Computer organization &amp; architecture chapter-1 by
Computer organization &amp; architecture chapter-1Computer organization &amp; architecture chapter-1
Computer organization &amp; architecture chapter-1Shah Rukh Rayaz
576 views83 slides
Input & Output by
Input & OutputInput & Output
Input & OutputDilum Bandara
6.1K views20 slides
ADDRESSING MODES by
ADDRESSING MODESADDRESSING MODES
ADDRESSING MODESSadaf Rasheed
15.7K views22 slides

What's hot(20)

Types of instructions by ihsanjamil
Types of instructionsTypes of instructions
Types of instructions
ihsanjamil103.6K views
General register organization (computer organization) by rishi ram khanal
General register organization  (computer organization)General register organization  (computer organization)
General register organization (computer organization)
rishi ram khanal2.8K views
Computer organization &amp; architecture chapter-1 by Shah Rukh Rayaz
Computer organization &amp; architecture chapter-1Computer organization &amp; architecture chapter-1
Computer organization &amp; architecture chapter-1
Shah Rukh Rayaz576 views
Floating point arithmetic operations (1) by cs19club
Floating point arithmetic operations (1)Floating point arithmetic operations (1)
Floating point arithmetic operations (1)
cs19club12.5K views
Pipeline hazards in computer Architecture ppt by mali yogesh kumar
Pipeline hazards in computer Architecture pptPipeline hazards in computer Architecture ppt
Pipeline hazards in computer Architecture ppt
mali yogesh kumar20.9K views
Addressing modes/Addressing Mode with illustration/ Addressing mode in 8086 by samirbharat77
Addressing modes/Addressing Mode with illustration/ Addressing mode in 8086Addressing modes/Addressing Mode with illustration/ Addressing mode in 8086
Addressing modes/Addressing Mode with illustration/ Addressing mode in 8086
samirbharat772.1K views
Register transfer and micro-operation by Nikhil Pandit
Register transfer and micro-operationRegister transfer and micro-operation
Register transfer and micro-operation
Nikhil Pandit18.9K views
Instruction set and instruction execution cycle by Mkaur01
Instruction set and instruction execution cycleInstruction set and instruction execution cycle
Instruction set and instruction execution cycle
Mkaur012.7K views
Instruction Execution Cycle by utsav_shah
Instruction Execution CycleInstruction Execution Cycle
Instruction Execution Cycle
utsav_shah31.4K views
Computer instruction by Sanjeev Patel
Computer instructionComputer instruction
Computer instruction
Sanjeev Patel16.4K views
Introduction to computer architecture and organization by Muhammad Ishaq
Introduction to computer architecture and organizationIntroduction to computer architecture and organization
Introduction to computer architecture and organization
Muhammad Ishaq9K views
Chapter 4 The Processor by guest4f73554
Chapter 4 The ProcessorChapter 4 The Processor
Chapter 4 The Processor
guest4f7355412.8K views
Flynns classification by Yasir Khan
Flynns classificationFlynns classification
Flynns classification
Yasir Khan82.5K views

Viewers also liked

Mips implementation by
Mips implementationMips implementation
Mips implementationhoang974
2.6K views101 slides
06 mips-isa by
06 mips-isa06 mips-isa
06 mips-isaWaqar Jamil
1.7K views22 slides
Case study of digital camera by
Case study of digital cameraCase study of digital camera
Case study of digital cameraRadhakrishna Singh
11.2K views28 slides
05 instruction set design and architecture by
05 instruction set design and architecture05 instruction set design and architecture
05 instruction set design and architectureWaqar Jamil
5.1K views37 slides
8 bit alu design by
8 bit alu design8 bit alu design
8 bit alu designShobhan Pujari
16.8K views20 slides
8 bit single cycle processor by
8 bit single cycle processor8 bit single cycle processor
8 bit single cycle processorDhaval Kaneria
24.9K views12 slides

Viewers also liked(17)

Mips implementation by hoang974
Mips implementationMips implementation
Mips implementation
hoang9742.6K views
05 instruction set design and architecture by Waqar Jamil
05 instruction set design and architecture05 instruction set design and architecture
05 instruction set design and architecture
Waqar Jamil5.1K views
8 bit single cycle processor by Dhaval Kaneria
8 bit single cycle processor8 bit single cycle processor
8 bit single cycle processor
Dhaval Kaneria24.9K views
Micro Programmed Control Unit by Kamal Acharya
Micro Programmed Control UnitMicro Programmed Control Unit
Micro Programmed Control Unit
Kamal Acharya34.7K views
MicroProgrammed Explained . by Muhammad Umar
MicroProgrammed Explained .MicroProgrammed Explained .
MicroProgrammed Explained .
Muhammad Umar5K views
15 control-computer organization and archietecture-CO-COA by Jay Patel
15 control-computer organization and archietecture-CO-COA15 control-computer organization and archietecture-CO-COA
15 control-computer organization and archietecture-CO-COA
Jay Patel1.9K views
Computer architecture by neclinux
Computer architectureComputer architecture
Computer architecture
neclinux23.9K views
basic computer programming and micro programmed control by Rai University
basic computer programming and micro programmed controlbasic computer programming and micro programmed control
basic computer programming and micro programmed control
Rai University6.5K views
Lec 12-15 mips instruction set processor by Mayank Roy
Lec 12-15 mips instruction set processorLec 12-15 mips instruction set processor
Lec 12-15 mips instruction set processor
Mayank Roy8.7K views
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver... by Rahul Borthakur
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...
Rahul Borthakur75.3K views
Origin of Microprocessor and Classification of Microprocessor by Vijay Kumar
Origin of Microprocessor and  Classification of Microprocessor Origin of Microprocessor and  Classification of Microprocessor
Origin of Microprocessor and Classification of Microprocessor
Vijay Kumar13.3K views
Computer Architecture – An Introduction by Dilum Bandara
Computer Architecture – An IntroductionComputer Architecture – An Introduction
Computer Architecture – An Introduction
Dilum Bandara20.3K views
Microprogram Control by Anuj Modi
Microprogram Control Microprogram Control
Microprogram Control
Anuj Modi54.2K views

Similar to Instruction Set Architecture

Lecture1 - Computer Architecture by
Lecture1 - Computer ArchitectureLecture1 - Computer Architecture
Lecture1 - Computer ArchitectureVolodymyr Ushenko
1.1K views15 slides
viva q&a for mp lab by
viva q&a for mp labviva q&a for mp lab
viva q&a for mp labg yugandhar srinivas
4.5K views10 slides
instruction by
instruction instruction
instruction Asif Iqbal
562 views16 slides
EMBEDDED SYSTEMS 4&5 by
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5PRADEEP
766 views36 slides
Assembler by
AssemblerAssembler
AssemblerManish Pandey
905 views66 slides
Control unit-implementation by
Control unit-implementationControl unit-implementation
Control unit-implementationWBUTTUTORIALS
2.9K views62 slides

Similar to Instruction Set Architecture(20)

instruction by Asif Iqbal
instruction instruction
instruction
Asif Iqbal562 views
EMBEDDED SYSTEMS 4&5 by PRADEEP
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
PRADEEP766 views
Control unit-implementation by WBUTTUTORIALS
Control unit-implementationControl unit-implementation
Control unit-implementation
WBUTTUTORIALS2.9K views
Ec 252 ec-252-l10-instruction sets and addressing modes by bhshmuec
Ec 252 ec-252-l10-instruction sets and addressing modesEc 252 ec-252-l10-instruction sets and addressing modes
Ec 252 ec-252-l10-instruction sets and addressing modes
bhshmuec1.7K views
5th unit Microprocessor 8085 by Mani Afranzio
5th unit Microprocessor 80855th unit Microprocessor 8085
5th unit Microprocessor 8085
Mani Afranzio143 views
Systemsoftwarenotes 100929171256-phpapp02 2 by Khaja Dileef
Systemsoftwarenotes 100929171256-phpapp02 2Systemsoftwarenotes 100929171256-phpapp02 2
Systemsoftwarenotes 100929171256-phpapp02 2
Khaja Dileef6K views
Alu design-project by alphankg1
Alu design-projectAlu design-project
Alu design-project
alphankg16.4K views
Examinable Question and answer system programming by Makerere university
Examinable Question and answer system programmingExaminable Question and answer system programming
Examinable Question and answer system programming
Basic processing unit by aniket bhute by Aniket Bhute
Basic processing unit by aniket bhuteBasic processing unit by aniket bhute
Basic processing unit by aniket bhute
Aniket Bhute1.4K views
Presentation computer architechure (1) by Amr Ahmed
Presentation computer architechure (1)Presentation computer architechure (1)
Presentation computer architechure (1)
Amr Ahmed274 views
Embedded system (Chapter 2) part 2 by Ikhwan_Fakrudin
Embedded system (Chapter 2) part 2Embedded system (Chapter 2) part 2
Embedded system (Chapter 2) part 2
Ikhwan_Fakrudin5.6K views
Single Cycle Processing by inmogr
Single Cycle ProcessingSingle Cycle Processing
Single Cycle Processing
inmogr6K views

More from Dilum Bandara

Modeling Multi-Layer Access Control Policies of a Hyperledger-Fabric-Based Ag... by
Modeling Multi-Layer Access Control Policies of a Hyperledger-Fabric-Based Ag...Modeling Multi-Layer Access Control Policies of a Hyperledger-Fabric-Based Ag...
Modeling Multi-Layer Access Control Policies of a Hyperledger-Fabric-Based Ag...Dilum Bandara
230 views19 slides
A Decision Model for Choosing Patterns in Blockchain-based Applications by
A Decision Model for Choosing Patterns in Blockchain-based ApplicationsA Decision Model for Choosing Patterns in Blockchain-based Applications
A Decision Model for Choosing Patterns in Blockchain-based ApplicationsDilum Bandara
210 views16 slides
Smart Contract Testing by
Smart Contract TestingSmart Contract Testing
Smart Contract TestingDilum Bandara
363 views19 slides
Smart Contract Security Testing by
Smart Contract Security TestingSmart Contract Security Testing
Smart Contract Security TestingDilum Bandara
672 views21 slides
What's not a cloud by
What's not a cloudWhat's not a cloud
What's not a cloudDilum Bandara
516 views7 slides
Blockchain - A Catalyst for Solving Age-old Distributed Systems Problems by
Blockchain - A Catalyst for Solving Age-old Distributed Systems ProblemsBlockchain - A Catalyst for Solving Age-old Distributed Systems Problems
Blockchain - A Catalyst for Solving Age-old Distributed Systems ProblemsDilum Bandara
224 views18 slides

More from Dilum Bandara(20)

Modeling Multi-Layer Access Control Policies of a Hyperledger-Fabric-Based Ag... by Dilum Bandara
Modeling Multi-Layer Access Control Policies of a Hyperledger-Fabric-Based Ag...Modeling Multi-Layer Access Control Policies of a Hyperledger-Fabric-Based Ag...
Modeling Multi-Layer Access Control Policies of a Hyperledger-Fabric-Based Ag...
Dilum Bandara230 views
A Decision Model for Choosing Patterns in Blockchain-based Applications by Dilum Bandara
A Decision Model for Choosing Patterns in Blockchain-based ApplicationsA Decision Model for Choosing Patterns in Blockchain-based Applications
A Decision Model for Choosing Patterns in Blockchain-based Applications
Dilum Bandara210 views
Smart Contract Security Testing by Dilum Bandara
Smart Contract Security TestingSmart Contract Security Testing
Smart Contract Security Testing
Dilum Bandara672 views
Blockchain - A Catalyst for Solving Age-old Distributed Systems Problems by Dilum Bandara
Blockchain - A Catalyst for Solving Age-old Distributed Systems ProblemsBlockchain - A Catalyst for Solving Age-old Distributed Systems Problems
Blockchain - A Catalyst for Solving Age-old Distributed Systems Problems
Dilum Bandara224 views
Protocols for Fast Delivery of Large Data Volumes by Dilum Bandara
Protocols for Fast Delivery of Large Data VolumesProtocols for Fast Delivery of Large Data Volumes
Protocols for Fast Delivery of Large Data Volumes
Dilum Bandara208 views
Content-Centric Networking (CCN) by Dilum Bandara
Content-Centric Networking (CCN)Content-Centric Networking (CCN)
Content-Centric Networking (CCN)
Dilum Bandara973 views
Internet Architecture and Design Philosophy by Dilum Bandara
Internet Architecture and Design PhilosophyInternet Architecture and Design Philosophy
Internet Architecture and Design Philosophy
Dilum Bandara903 views
Transactions and Concurrency Control by Dilum Bandara
Transactions and Concurrency ControlTransactions and Concurrency Control
Transactions and Concurrency Control
Dilum Bandara4.2K views
Physical and Logical Clocks by Dilum Bandara
Physical and Logical ClocksPhysical and Logical Clocks
Physical and Logical Clocks
Dilum Bandara9.6K views
Content Delivery Networks (CDN) by Dilum Bandara
Content Delivery Networks (CDN)Content Delivery Networks (CDN)
Content Delivery Networks (CDN)
Dilum Bandara3K views
Message and Stream Oriented Communication by Dilum Bandara
Message and Stream Oriented CommunicationMessage and Stream Oriented Communication
Message and Stream Oriented Communication
Dilum Bandara17.9K views
CAP Theorem and Split Brain Syndrome by Dilum Bandara
CAP Theorem and Split Brain SyndromeCAP Theorem and Split Brain Syndrome
CAP Theorem and Split Brain Syndrome
Dilum Bandara1.1K views
Communication in Distributed Systems by Dilum Bandara
Communication in Distributed SystemsCommunication in Distributed Systems
Communication in Distributed Systems
Dilum Bandara919 views
02 - Topologies of Distributed Systems by Dilum Bandara
02 - Topologies of Distributed Systems02 - Topologies of Distributed Systems
02 - Topologies of Distributed Systems
Dilum Bandara3.1K views
01 - Introduction to Distributed Systems by Dilum Bandara
01 - Introduction to Distributed Systems01 - Introduction to Distributed Systems
01 - Introduction to Distributed Systems
Dilum Bandara1.2K views
Use of Technology in Toll Collection & Management by Dilum Bandara
Use of Technology in Toll Collection & ManagementUse of Technology in Toll Collection & Management
Use of Technology in Toll Collection & Management
Dilum Bandara578 views

Recently uploaded

Design of machine elements-UNIT 3.pptx by
Design of machine elements-UNIT 3.pptxDesign of machine elements-UNIT 3.pptx
Design of machine elements-UNIT 3.pptxgopinathcreddy
29 views31 slides
What is Unit Testing by
What is Unit TestingWhat is Unit Testing
What is Unit TestingSadaaki Emura
23 views25 slides
SUMIT SQL PROJECT SUPERSTORE 1.pptx by
SUMIT SQL PROJECT SUPERSTORE 1.pptxSUMIT SQL PROJECT SUPERSTORE 1.pptx
SUMIT SQL PROJECT SUPERSTORE 1.pptxSumit Jadhav
11 views26 slides
Solar PV by
Solar PVSolar PV
Solar PVIwiss Tools Co.,Ltd
14 views4 slides
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,... by
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...AakashShakya12
63 views115 slides
Codes and Conventions.pptx by
Codes and Conventions.pptxCodes and Conventions.pptx
Codes and Conventions.pptxIsabellaGraceAnkers
7 views5 slides

Recently uploaded(20)

Design of machine elements-UNIT 3.pptx by gopinathcreddy
Design of machine elements-UNIT 3.pptxDesign of machine elements-UNIT 3.pptx
Design of machine elements-UNIT 3.pptx
gopinathcreddy29 views
SUMIT SQL PROJECT SUPERSTORE 1.pptx by Sumit Jadhav
SUMIT SQL PROJECT SUPERSTORE 1.pptxSUMIT SQL PROJECT SUPERSTORE 1.pptx
SUMIT SQL PROJECT SUPERSTORE 1.pptx
Sumit Jadhav 11 views
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,... by AakashShakya12
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...
AakashShakya1263 views
Multi-objective distributed generation integration in radial distribution sy... by IJECEIAES
Multi-objective distributed generation integration in radial  distribution sy...Multi-objective distributed generation integration in radial  distribution sy...
Multi-objective distributed generation integration in radial distribution sy...
IJECEIAES15 views
How I learned to stop worrying and love the dark silicon apocalypse.pdf by Tomasz Kowalczewski
How I learned to stop worrying and love the dark silicon apocalypse.pdfHow I learned to stop worrying and love the dark silicon apocalypse.pdf
How I learned to stop worrying and love the dark silicon apocalypse.pdf
Informed search algorithms.pptx by Dr.Shweta
Informed search algorithms.pptxInformed search algorithms.pptx
Informed search algorithms.pptx
Dr.Shweta16 views
Machine Element II Course outline.pdf by odatadese1
Machine Element II Course outline.pdfMachine Element II Course outline.pdf
Machine Element II Course outline.pdf
odatadese18 views
What is Whirling Hygrometer.pdf by IIT KHARAGPUR
What is Whirling Hygrometer.pdfWhat is Whirling Hygrometer.pdf
What is Whirling Hygrometer.pdf
IIT KHARAGPUR 11 views
Performance of Back-to-Back Mechanically Stabilized Earth Walls Supporting th... by ahmedmesaiaoun
Performance of Back-to-Back Mechanically Stabilized Earth Walls Supporting th...Performance of Back-to-Back Mechanically Stabilized Earth Walls Supporting th...
Performance of Back-to-Back Mechanically Stabilized Earth Walls Supporting th...
ahmedmesaiaoun12 views

Instruction Set Architecture

  • 1. Instruction Set Architecture CS2052 Computer Architecture Computer Science & Engineering University of Moratuwa Dilum Bandara Dilum.Bandara@uom.lk
  • 2. Blocks of a Microprocessor 2 Literal Address Operation Program Memory Instruction Register STACK Program Counter Instruction Decoder Timing, Control and Register selection Accumulator RAM & Data Registers ALU IO IO FLAG & Special Function Registers Clock Reset Interrupts Program Execution Section Register Processing Section Set up Set up Modify Address Internal data bus Source: Makis Malliris & Sabir Ghauri, UWE
  • 3. Instruction Set Architecture (ISA) 3 Instruction Set Software Hardware Source: Computer Architecture: A Quantitative Approach, J. L. Hennessy & D. A. Patterson, 3rd Edition.
  • 4. ISA (Cont.)  Part of computer architecture related to programming  Include native data types, instructions, registers, addressing modes, memory architecture, interrupt & exception handling, & external I/O  e.g., R1, R2, …, PC  e.g., MOV, ADD, INC, AND  ISA specifies the set of opcodes (machine language), & native commands implemented by a particular processor 4
  • 5. Well Known ISAs  x86  Based on Intel 8086 CPU in 1978  Intel family, also followed by AMD  X86-64  64-bit extensions  Proposed by AMD, also followed by Intel  ARM  32-bit & 64-bit  Initially by Acorn RISC Machine  ARM Holding  MIPS  32-bit & 64-bit  By Microprocessor without Interlocked Pipeline Stages (MIPS) Technologies 5
  • 6. Well Known ISAs (Cont.)  SPARC  32-bit & 64-bit  By Sun Microsystems  PIC  8-bit to 32-bit  By Microchip  Z80  8-bit  By Zilog in 1976  Many extensions  Intel – MMX, SSE, SSE2, AVX  AMD – 3D Now! 6
  • 7. A Good ISA  Lasts through many implementations  Portability, compatibility  Used in many different ways  Servers, desktop, laptop, mobile, tablet  Provides convenient functions to higher layer  Permit efficient implementation at lower layer 7
  • 8. Example – Instructions  Microprocessor that we are going to build will support following 2 instructions  ADD  LOAD 8
  • 9. Activating Necessary Blocks 9 Source: www.transtutors.com/homework-help/computer- science/computer-architecture/cpu/general-register-organization/
  • 10. Micro-operations  Digital modules are best described by  Registers they contain  Micro-operations performed on data stored on those registers  Elementary operations done on data in registers  Register Transfer Language  Concise symbolic expressions  ADD  ADD RC, RA, RB RC  RA + RB PC  PC + 1  LOAD  LOAD RA, d RA  d PC  PC + 1 10
  • 11. How to Describe a Computer  Set of registers & their functions  Sequence of micro-operations  Controls that initiates & maintains sequence of micro-operations  Today, from a programming point of view, Assembly is the lowest level we use to define these registers, instructions, & their order of execution 11
  • 12. Programming in Assembly  To program in Assembly we need 1. Knowledge about hardware design  Registers  Memory addressing  I/O 2. Knowledge about instruction set 12
  • 13. Registers (Review)  Type of memory located inside CPU  Can hold a single piece of data  Useful in both data processing & control functionalities  Types  Special purpose registers  Program counter (PC)  Instruction register (IR)  Accumulator or working register (A or W)  Flag register (FLAG or STATUS)  General purpose registers  No special name, typically A, B, C, ... Or R1, R2, R3, ... 13
  • 14. Format of an Assembly Statement 14 [Identifier / Label] Operation/ Command/ Op code [Operand(s)] [;Comment] Labeling code or to indicate a program destination address for jumps What instruction to be carried out by CPU Only valid instructions are allowed Data or register contents to be used in instruction Some instructions don’t need operands Explanatory text. Optional but very useful, as Assembly programs are hard to understand L20: ADD RC, RA, RB ;RC  RA + RB
  • 15. Example – Instruction Set  We’ll use instruction set from PIC 16F87x for our discussion  Textbook doesn’t use a specific set  Most other textbooks may use MIPS or x86  They are still too complex to start with  When you are more familiar, you can learn/use any new instruction set 15
  • 16. 16 F file register W working register B bit L literal (number) Z conditional execution d destination bit d=0 store in W d=1 store in f use , w or ,f instead Source: Makis Malliris & Sabir Ghauri, UWE
  • 17. Opcode  Determines the instruction  Registers, bits, literals depend on the opcode field 17 Source: PIC16F87X Data Sheet by Microchip Technology Inc.
  • 18. Assembler  Assembler translates human readable code into binary  Binary code specifies opcode & operands  ADDLW 135 means “add literal 135 to W register”  Assembler converts this to 11 1110 1000 0111  This is what the machine understands 18
  • 19. Program Operations  Load a register with a given number  Copy data from register to another  Carry out arithmetic & logical operations on a data word or a pair of data words  Test a bit or word & jump, or not, depending on result of the test  Jump to a point in the program  Jump to a subroutine  Carry out a special control operation 19
  • 20. Instruction Classification Instruction Types  Data transfers  Arithmetic, logic  Rotates, shifts  Bit set, bit reset, & bit test  General-purpose, CPU control  Jumps  Calls, returns Instruction Function  Move  Register  Arithmetic  Logic  Test & Skip  Jump 20
  • 21. Data Transfer Instructions  Used to transfer data from one location to another  Register to Register, Register to Memory, Memory to Register  MOV  MOVLW 3 ; W  03h  MOVWF R1 ; R1  03h  MOV is same as LDA (Load) in textbook 21
  • 22. Arithmetic Instructions  Used in arithmetic operations  ADD – ADDWF R1 ; W  W + R1  ADD – ADDLW 3 ; W  W + 3  SUB – SUBLW 5 ; W  W - 5  INC – INCF R1 ; R1  R1 + 1 22
  • 23. ALU (Review)  Data processing unit  Arithmetic unit  Performs arithmetic operations  Logic unit  Performs logical operations 23 Accumulator Source: Introduction to PIC Microcontroller – Part 1 by Khan Wahid
  • 24. Example – Arithmetic Instructions  Write an assembly program to add 5 & 10  Steps  How many registers?  What registers to use?  What instructions are required?  MOV – MOVLW 5 ; W  05h  ADD – ADDLW 0xA ; W  05h + Ah 24
  • 25. Logic Operations  Used in bitwise logic operations  AND – ANDLW 3 ; W  W & 0011  OR – IORLW 3 ; W  W | 0011  XOR – XORLW 3 ; W  W  1001  NOT – COMF 0x20,1 ;(0x20)  (0x20)/ 25
  • 26. Example – Logic Operations  Example  Write an assembly program to convert a given character from uppercase to lowercase & vice versa  If we consider ASCII, this can be achieved by changing the 5th bit  A = 65 =0x41 = 0 1 0 0 0 0 0 1  a = 97 =0x61 = 0 1 1 0 0 0 0 1  Get XOR with 00100000 = 32 = 0x20 26
  • 27. Transfer Instructions (Jump Instructions)  Can be used to jump here & there within program  Can be used to control loops  GOTO – GOTO loop ;go to loop label  CALL – CALL delay ;call delay subroutine 27
  • 28. Example – Transfer Instructions  Example  Write a program to calculate the total of all integers from 1 to 10  High-level program 28 int total = 0; for (int i=1 ; i<=10; i++) { total += i; }
  • 29. Example – Transfer Instructions (Cont.)  Steps  Are there any conditions/loops?  How many registers?  What registers to use?  What instructions to use?  ADDLW  Increment/decrement instruction – INCF, DECF  Let’s use memory address 0020h 29
  • 30. Transfer Instructions (Cont.) 30 start movlw 0xa ; w  10 movwf 0x20 ; (0x20)  w movlw 0 ; total loop addwf 0x0020,0 ; Add decf 0x0020,1 ; Dec counter btfss STATUS,Z ; is counter 0? goto loop ; repeat nop end int total = 0; for (int i=10 ; i!=0; i--) { total += i; }
  • 31. 31 Homework  Example  Write an assembly program to multiply 3 & 4  Steps:  How many registers?  What registers to use?  What instructions to use?  MOV – MOVLW 3 ; W  03h  MUL – ???
  • 32. Shift Operators >> <<  Move all bits in a value by given no of positions to left or right 10011011 01110110 10010011 >> 1 >> 3 >> 3 01001101 00001110 00010010 10011011 01110110 <<1 <<3 00110110 10110000  Multiply by powers of 2 – value << n (value * 2n)  e.g., 4 << 3 ; (4 * 8) =32  Divide by powers of 2 – value >>=n (value / 2n)  e.g., 75 >> 4; 75 / 16 =4 32
  • 33. Rotate Through Carry  RLF – Rotate Left f through Carry  Suppose carry was 1  RLF 9B  1 = 37  RLF 9B  2 = 6F  RRF – Rotate Right f through Carry  Suppose carry was 1  RRF 9B  1 = CD  RRF 9B  2 = E6 33
  • 34. Comparison Operations  Comparing 2 numbers need to be treated with care due to non-intuitive nature of Carry flag movlw 2 ; W = 2 subwf Q, W ; W = Q - 2 btfss STATUS, C ; check carry flag goto Gr_eq ; Q >= 2 goto Less ; Q < 2 34