Instruction Set Architecture

Dilum Bandara
Dilum BandaraResearch Scientist em 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 de 34

Recomendados

Instruction Set Architecture (ISA) por
Instruction Set Architecture (ISA)Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA)Gaditek
6.2K visualizações45 slides
Lecture 3 instruction set por
Lecture 3  instruction setLecture 3  instruction set
Lecture 3 instruction setPradeep Kumar TS
6.3K visualizações30 slides
Computer organization basics por
Computer organization  basicsComputer organization  basics
Computer organization basicsDeepak John
8.8K visualizações71 slides
Computer Organization and Architecture. por
Computer Organization and Architecture.Computer Organization and Architecture.
Computer Organization and Architecture.CS_GDRCST
23K visualizações48 slides
Assembly Language por
Assembly LanguageAssembly Language
Assembly LanguageIbrahimcommunication Al Ani
24.4K visualizações20 slides
Addressing modes por
Addressing modesAddressing modes
Addressing modeskarthiga selvaraju
10.9K visualizações27 slides

Mais conteúdo relacionado

Mais procurados

General register organization (computer organization) por
General register organization  (computer organization)General register organization  (computer organization)
General register organization (computer organization)rishi ram khanal
2.8K visualizações9 slides
Computer registers por
Computer registersComputer registers
Computer registersDeepikaT13
7.5K visualizações22 slides
8086-instruction-set-ppt por
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-pptjemimajerome
28K visualizações91 slides
Computer architecture por
Computer architectureComputer architecture
Computer architectureZuhaib Zaroon
10.9K visualizações101 slides
Instruction format por
Instruction formatInstruction format
Instruction formatSanjeev Patel
77.1K visualizações20 slides
Memory Addressing por
Memory AddressingMemory Addressing
Memory Addressingchauhankapil
3.3K visualizações12 slides

Mais procurados(20)

General register organization (computer organization) por rishi ram khanal
General register organization  (computer organization)General register organization  (computer organization)
General register organization (computer organization)
rishi ram khanal2.8K visualizações
Computer registers por DeepikaT13
Computer registersComputer registers
Computer registers
DeepikaT137.5K visualizações
8086-instruction-set-ppt por jemimajerome
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-ppt
jemimajerome28K visualizações
Computer architecture por Zuhaib Zaroon
Computer architectureComputer architecture
Computer architecture
Zuhaib Zaroon10.9K visualizações
Instruction format por Sanjeev Patel
Instruction formatInstruction format
Instruction format
Sanjeev Patel77.1K visualizações
Memory Addressing por chauhankapil
Memory AddressingMemory Addressing
Memory Addressing
chauhankapil3.3K visualizações
Unit 3 basic processing unit por chidabdu
Unit 3   basic processing unitUnit 3   basic processing unit
Unit 3 basic processing unit
chidabdu44.9K visualizações
Computer architecture pipelining por Mazin Alwaaly
Computer architecture pipeliningComputer architecture pipelining
Computer architecture pipelining
Mazin Alwaaly17.1K visualizações
Memory organization (Computer architecture) por Sandesh Jonchhe
Memory organization (Computer architecture)Memory organization (Computer architecture)
Memory organization (Computer architecture)
Sandesh Jonchhe13K visualizações
Arithmetic Logic Unit (ALU) por Student
Arithmetic Logic Unit (ALU)Arithmetic Logic Unit (ALU)
Arithmetic Logic Unit (ALU)
Student32.4K visualizações
Microprocessor 80386 por yash sawarkar
Microprocessor 80386Microprocessor 80386
Microprocessor 80386
yash sawarkar109K visualizações
Instruction pipeline: Computer Architecture por Md. Saidur Rahman Kohinoor
Instruction pipeline: Computer ArchitectureInstruction pipeline: Computer Architecture
Instruction pipeline: Computer Architecture
Md. Saidur Rahman Kohinoor57.1K visualizações
Computer Organization and Assembly Language por fasihuddin90
Computer Organization and Assembly LanguageComputer Organization and Assembly Language
Computer Organization and Assembly Language
fasihuddin9013.5K visualizações
Computer organisation -morris mano por vishnu murthy
Computer organisation  -morris manoComputer organisation  -morris mano
Computer organisation -morris mano
vishnu murthy20.2K visualizações
Architecture of 8085 microprocessor por AMAN SRIVASTAVA
Architecture of 8085 microprocessorArchitecture of 8085 microprocessor
Architecture of 8085 microprocessor
AMAN SRIVASTAVA14.8K visualizações
Control Unit Design por Vinit Raut
Control Unit DesignControl Unit Design
Control Unit Design
Vinit Raut14.1K visualizações
Decoders por Re Man
DecodersDecoders
Decoders
Re Man7.7K visualizações
Computer architecture register transfer languages rtl por Mazin Alwaaly
Computer architecture register transfer languages rtlComputer architecture register transfer languages rtl
Computer architecture register transfer languages rtl
Mazin Alwaaly4.3K visualizações
Unit II arm 7 Instruction Set por Dr. Pankaj Zope
Unit II arm 7 Instruction SetUnit II arm 7 Instruction Set
Unit II arm 7 Instruction Set
Dr. Pankaj Zope12.1K visualizações

Destaque

Mips implementation por
Mips implementationMips implementation
Mips implementationhoang974
2.6K visualizações101 slides
06 mips-isa por
06 mips-isa06 mips-isa
06 mips-isaWaqar Jamil
1.7K visualizações22 slides
Case study of digital camera por
Case study of digital cameraCase study of digital camera
Case study of digital cameraRadhakrishna Singh
11.3K visualizações28 slides
05 instruction set design and architecture por
05 instruction set design and architecture05 instruction set design and architecture
05 instruction set design and architectureWaqar Jamil
5.1K visualizações37 slides
8 bit alu design por
8 bit alu design8 bit alu design
8 bit alu designShobhan Pujari
16.8K visualizações20 slides
8 bit single cycle processor por
8 bit single cycle processor8 bit single cycle processor
8 bit single cycle processorDhaval Kaneria
24.9K visualizações12 slides

Destaque(18)

Mips implementation por hoang974
Mips implementationMips implementation
Mips implementation
hoang9742.6K visualizações
06 mips-isa por Waqar Jamil
06 mips-isa06 mips-isa
06 mips-isa
Waqar Jamil1.7K visualizações
Case study of digital camera por Radhakrishna Singh
Case study of digital cameraCase study of digital camera
Case study of digital camera
Radhakrishna Singh11.3K visualizações
05 instruction set design and architecture por Waqar Jamil
05 instruction set design and architecture05 instruction set design and architecture
05 instruction set design and architecture
Waqar Jamil5.1K visualizações
8 bit alu design por Shobhan Pujari
8 bit alu design8 bit alu design
8 bit alu design
Shobhan Pujari16.8K visualizações
8 bit single cycle processor por Dhaval Kaneria
8 bit single cycle processor8 bit single cycle processor
8 bit single cycle processor
Dhaval Kaneria24.9K visualizações
Micro Programmed Control Unit por Kamal Acharya
Micro Programmed Control UnitMicro Programmed Control Unit
Micro Programmed Control Unit
Kamal Acharya34.7K visualizações
MicroProgrammed Explained . por Muhammad Umar
MicroProgrammed Explained .MicroProgrammed Explained .
MicroProgrammed Explained .
Muhammad Umar5K visualizações
15 control-computer organization and archietecture-CO-COA por 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 Patel2K visualizações
Computer architecture por neclinux
Computer architectureComputer architecture
Computer architecture
neclinux23.9K visualizações
Micro programmed control por Shashank Singh
Micro programmed  controlMicro programmed  control
Micro programmed control
Shashank Singh3.4K visualizações
basic computer programming and micro programmed control por 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 visualizações
Lec 12-15 mips instruction set processor por 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 visualizações
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver... por 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 visualizações
Origin of Microprocessor and Classification of Microprocessor por 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 visualizações
Computer Architecture – An Introduction por Dilum Bandara
Computer Architecture – An IntroductionComputer Architecture – An Introduction
Computer Architecture – An Introduction
Dilum Bandara20.3K visualizações
Microprogram Control por Anuj Modi
Microprogram Control Microprogram Control
Microprogram Control
Anuj Modi54.2K visualizações
Types of instructions por ihsanjamil
Types of instructionsTypes of instructions
Types of instructions
ihsanjamil103.6K visualizações

Similar a Instruction Set Architecture

Lecture1 - Computer Architecture por
Lecture1 - Computer ArchitectureLecture1 - Computer Architecture
Lecture1 - Computer ArchitectureVolodymyr Ushenko
1.1K visualizações15 slides
viva q&a for mp lab por
viva q&a for mp labviva q&a for mp lab
viva q&a for mp labg yugandhar srinivas
4.5K visualizações10 slides
instruction por
instruction instruction
instruction Asif Iqbal
562 visualizações16 slides
EMBEDDED SYSTEMS 4&5 por
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5PRADEEP
766 visualizações36 slides
Assembler por
AssemblerAssembler
AssemblerManish Pandey
905 visualizações66 slides
Control unit-implementation por
Control unit-implementationControl unit-implementation
Control unit-implementationWBUTTUTORIALS
2.9K visualizações62 slides

Similar a Instruction Set Architecture(20)

Lecture1 - Computer Architecture por Volodymyr Ushenko
Lecture1 - Computer ArchitectureLecture1 - Computer Architecture
Lecture1 - Computer Architecture
Volodymyr Ushenko1.1K visualizações
instruction por Asif Iqbal
instruction instruction
instruction
Asif Iqbal562 visualizações
EMBEDDED SYSTEMS 4&5 por PRADEEP
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
PRADEEP766 visualizações
Assembler por Manish Pandey
AssemblerAssembler
Assembler
Manish Pandey905 visualizações
Control unit-implementation por WBUTTUTORIALS
Control unit-implementationControl unit-implementation
Control unit-implementation
WBUTTUTORIALS2.9K visualizações
Ec 252 ec-252-l10-instruction sets and addressing modes por 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 visualizações
5th unit Microprocessor 8085 por Mani Afranzio
5th unit Microprocessor 80855th unit Microprocessor 8085
5th unit Microprocessor 8085
Mani Afranzio143 visualizações
Computer Organization and 8085 microprocessor notes por Lakshmi Sarvani Videla
Computer Organization and 8085 microprocessor notesComputer Organization and 8085 microprocessor notes
Computer Organization and 8085 microprocessor notes
Lakshmi Sarvani Videla6.9K visualizações
Systemsoftwarenotes 100929171256-phpapp02 2 por Khaja Dileef
Systemsoftwarenotes 100929171256-phpapp02 2Systemsoftwarenotes 100929171256-phpapp02 2
Systemsoftwarenotes 100929171256-phpapp02 2
Khaja Dileef6K visualizações
Alu design-project por alphankg1
Alu design-projectAlu design-project
Alu design-project
alphankg16.4K visualizações
Examinable Question and answer system programming por Makerere university
Examinable Question and answer system programmingExaminable Question and answer system programming
Examinable Question and answer system programming
Makerere university14K visualizações
Basic processing unit by aniket bhute por Aniket Bhute
Basic processing unit by aniket bhuteBasic processing unit by aniket bhute
Basic processing unit by aniket bhute
Aniket Bhute1.4K visualizações
Ch 2.pptx por berekethailu2
Ch 2.pptxCh 2.pptx
Ch 2.pptx
berekethailu28 visualizações
Presentation computer architechure (1) por Amr Ahmed
Presentation computer architechure (1)Presentation computer architechure (1)
Presentation computer architechure (1)
Amr Ahmed274 visualizações
Presentation por Abhijit Das
PresentationPresentation
Presentation
Abhijit Das198 visualizações
Embedded system (Chapter 2) part 2 por Ikhwan_Fakrudin
Embedded system (Chapter 2) part 2Embedded system (Chapter 2) part 2
Embedded system (Chapter 2) part 2
Ikhwan_Fakrudin5.6K visualizações
CAO-Unit-I.pptx por ClassicFUKRA
CAO-Unit-I.pptxCAO-Unit-I.pptx
CAO-Unit-I.pptx
ClassicFUKRA170 visualizações
Ch5_MorrisMano.pptx por SangeetaTripathi8
Ch5_MorrisMano.pptxCh5_MorrisMano.pptx
Ch5_MorrisMano.pptx
SangeetaTripathi83 visualizações
Single Cycle Processing por inmogr
Single Cycle ProcessingSingle Cycle Processing
Single Cycle Processing
inmogr6K visualizações

Mais de Dilum Bandara

Modeling Multi-Layer Access Control Policies of a Hyperledger-Fabric-Based Ag... por
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 visualizações19 slides
A Decision Model for Choosing Patterns in Blockchain-based Applications por
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 visualizações16 slides
Smart Contract Testing por
Smart Contract TestingSmart Contract Testing
Smart Contract TestingDilum Bandara
363 visualizações19 slides
Smart Contract Security Testing por
Smart Contract Security TestingSmart Contract Security Testing
Smart Contract Security TestingDilum Bandara
672 visualizações21 slides
What's not a cloud por
What's not a cloudWhat's not a cloud
What's not a cloudDilum Bandara
516 visualizações7 slides
Blockchain - A Catalyst for Solving Age-old Distributed Systems Problems por
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 visualizações18 slides

Mais de Dilum Bandara(20)

Modeling Multi-Layer Access Control Policies of a Hyperledger-Fabric-Based Ag... por 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 visualizações
A Decision Model for Choosing Patterns in Blockchain-based Applications por 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 visualizações
Smart Contract Testing por Dilum Bandara
Smart Contract TestingSmart Contract Testing
Smart Contract Testing
Dilum Bandara363 visualizações
Smart Contract Security Testing por Dilum Bandara
Smart Contract Security TestingSmart Contract Security Testing
Smart Contract Security Testing
Dilum Bandara672 visualizações
What's not a cloud por Dilum Bandara
What's not a cloudWhat's not a cloud
What's not a cloud
Dilum Bandara516 visualizações
Blockchain - A Catalyst for Solving Age-old Distributed Systems Problems por 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 visualizações
Protocols for Fast Delivery of Large Data Volumes por 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 visualizações
Content-Centric Networking (CCN) por Dilum Bandara
Content-Centric Networking (CCN)Content-Centric Networking (CCN)
Content-Centric Networking (CCN)
Dilum Bandara977 visualizações
Internet Architecture and Design Philosophy por Dilum Bandara
Internet Architecture and Design PhilosophyInternet Architecture and Design Philosophy
Internet Architecture and Design Philosophy
Dilum Bandara904 visualizações
Cloud Computing por Dilum Bandara
Cloud ComputingCloud Computing
Cloud Computing
Dilum Bandara453 visualizações
Transactions and Concurrency Control por Dilum Bandara
Transactions and Concurrency ControlTransactions and Concurrency Control
Transactions and Concurrency Control
Dilum Bandara4.2K visualizações
Physical and Logical Clocks por Dilum Bandara
Physical and Logical ClocksPhysical and Logical Clocks
Physical and Logical Clocks
Dilum Bandara9.6K visualizações
Content Delivery Networks (CDN) por Dilum Bandara
Content Delivery Networks (CDN)Content Delivery Networks (CDN)
Content Delivery Networks (CDN)
Dilum Bandara3.1K visualizações
Message and Stream Oriented Communication por Dilum Bandara
Message and Stream Oriented CommunicationMessage and Stream Oriented Communication
Message and Stream Oriented Communication
Dilum Bandara17.9K visualizações
CAP Theorem and Split Brain Syndrome por Dilum Bandara
CAP Theorem and Split Brain SyndromeCAP Theorem and Split Brain Syndrome
CAP Theorem and Split Brain Syndrome
Dilum Bandara1.1K visualizações
Communication in Distributed Systems por Dilum Bandara
Communication in Distributed SystemsCommunication in Distributed Systems
Communication in Distributed Systems
Dilum Bandara934 visualizações
Problem Formulation por Dilum Bandara
Problem FormulationProblem Formulation
Problem Formulation
Dilum Bandara328 visualizações
02 - Topologies of Distributed Systems por Dilum Bandara
02 - Topologies of Distributed Systems02 - Topologies of Distributed Systems
02 - Topologies of Distributed Systems
Dilum Bandara3.1K visualizações
01 - Introduction to Distributed Systems por Dilum Bandara
01 - Introduction to Distributed Systems01 - Introduction to Distributed Systems
01 - Introduction to Distributed Systems
Dilum Bandara1.2K visualizações
Use of Technology in Toll Collection & Management por Dilum Bandara
Use of Technology in Toll Collection & ManagementUse of Technology in Toll Collection & Management
Use of Technology in Toll Collection & Management
Dilum Bandara578 visualizações

Último

IRJET-Productivity Enhancement Using Method Study.pdf por
IRJET-Productivity Enhancement Using Method Study.pdfIRJET-Productivity Enhancement Using Method Study.pdf
IRJET-Productivity Enhancement Using Method Study.pdfSahilBavdhankar
10 visualizações4 slides
taylor-2005-classical-mechanics.pdf por
taylor-2005-classical-mechanics.pdftaylor-2005-classical-mechanics.pdf
taylor-2005-classical-mechanics.pdfArturoArreola10
37 visualizações808 slides
REACTJS.pdf por
REACTJS.pdfREACTJS.pdf
REACTJS.pdfArthyR3
39 visualizações16 slides
BCIC - Manufacturing Conclave - Technology-Driven Manufacturing for Growth por
BCIC - Manufacturing Conclave -  Technology-Driven Manufacturing for GrowthBCIC - Manufacturing Conclave -  Technology-Driven Manufacturing for Growth
BCIC - Manufacturing Conclave - Technology-Driven Manufacturing for GrowthInnomantra
22 visualizações4 slides
Unlocking Research Visibility.pdf por
Unlocking Research Visibility.pdfUnlocking Research Visibility.pdf
Unlocking Research Visibility.pdfKhatirNaima
11 visualizações19 slides
GDSC Mikroskil Members Onboarding 2023.pdf por
GDSC Mikroskil Members Onboarding 2023.pdfGDSC Mikroskil Members Onboarding 2023.pdf
GDSC Mikroskil Members Onboarding 2023.pdfgdscmikroskil
72 visualizações62 slides

Último(20)

IRJET-Productivity Enhancement Using Method Study.pdf por SahilBavdhankar
IRJET-Productivity Enhancement Using Method Study.pdfIRJET-Productivity Enhancement Using Method Study.pdf
IRJET-Productivity Enhancement Using Method Study.pdf
SahilBavdhankar10 visualizações
taylor-2005-classical-mechanics.pdf por ArturoArreola10
taylor-2005-classical-mechanics.pdftaylor-2005-classical-mechanics.pdf
taylor-2005-classical-mechanics.pdf
ArturoArreola1037 visualizações
REACTJS.pdf por ArthyR3
REACTJS.pdfREACTJS.pdf
REACTJS.pdf
ArthyR339 visualizações
BCIC - Manufacturing Conclave - Technology-Driven Manufacturing for Growth por Innomantra
BCIC - Manufacturing Conclave -  Technology-Driven Manufacturing for GrowthBCIC - Manufacturing Conclave -  Technology-Driven Manufacturing for Growth
BCIC - Manufacturing Conclave - Technology-Driven Manufacturing for Growth
Innomantra 22 visualizações
Unlocking Research Visibility.pdf por KhatirNaima
Unlocking Research Visibility.pdfUnlocking Research Visibility.pdf
Unlocking Research Visibility.pdf
KhatirNaima11 visualizações
GDSC Mikroskil Members Onboarding 2023.pdf por gdscmikroskil
GDSC Mikroskil Members Onboarding 2023.pdfGDSC Mikroskil Members Onboarding 2023.pdf
GDSC Mikroskil Members Onboarding 2023.pdf
gdscmikroskil72 visualizações
Plant Design Report-Oil Refinery.pdf por Safeen Yaseen Ja'far
Plant Design Report-Oil Refinery.pdfPlant Design Report-Oil Refinery.pdf
Plant Design Report-Oil Refinery.pdf
Safeen Yaseen Ja'far9 visualizações
Trust Metric-Based Anomaly Detection via Deep Deterministic Policy Gradient R... por IJCNCJournal
Trust Metric-Based Anomaly Detection via Deep Deterministic Policy Gradient R...Trust Metric-Based Anomaly Detection via Deep Deterministic Policy Gradient R...
Trust Metric-Based Anomaly Detection via Deep Deterministic Policy Gradient R...
IJCNCJournal5 visualizações
Créativité dans le design mécanique à l’aide de l’optimisation topologique por LIEGE CREATIVE
Créativité dans le design mécanique à l’aide de l’optimisation topologiqueCréativité dans le design mécanique à l’aide de l’optimisation topologique
Créativité dans le design mécanique à l’aide de l’optimisation topologique
LIEGE CREATIVE9 visualizações
GPS Survery Presentation/ Slides por OmarFarukEmon1
GPS Survery Presentation/ SlidesGPS Survery Presentation/ Slides
GPS Survery Presentation/ Slides
OmarFarukEmon17 visualizações
sam_software_eng_cv.pdf por sammyigbinovia
sam_software_eng_cv.pdfsam_software_eng_cv.pdf
sam_software_eng_cv.pdf
sammyigbinovia19 visualizações
Field Programmable Gate Arrays : Architecture por Usha Mehta
Field Programmable Gate Arrays : ArchitectureField Programmable Gate Arrays : Architecture
Field Programmable Gate Arrays : Architecture
Usha Mehta23 visualizações
CCNA_questions_2021.pdf por VUPHUONGTHAO9
CCNA_questions_2021.pdfCCNA_questions_2021.pdf
CCNA_questions_2021.pdf
VUPHUONGTHAO97 visualizações
Basic Design Flow for Field Programmable Gate Arrays por Usha Mehta
Basic Design Flow for Field Programmable Gate ArraysBasic Design Flow for Field Programmable Gate Arrays
Basic Design Flow for Field Programmable Gate Arrays
Usha Mehta10 visualizações
Ansari: Practical experiences with an LLM-based Islamic Assistant por M Waleed Kadous
Ansari: Practical experiences with an LLM-based Islamic AssistantAnsari: Practical experiences with an LLM-based Islamic Assistant
Ansari: Practical experiences with an LLM-based Islamic Assistant
M Waleed Kadous12 visualizações
Programmable Logic Devices : SPLD and CPLD por Usha Mehta
Programmable Logic Devices : SPLD and CPLDProgrammable Logic Devices : SPLD and CPLD
Programmable Logic Devices : SPLD and CPLD
Usha Mehta27 visualizações
AWS Certified Solutions Architect Associate Exam Guide_published .pdf por Kiran Kumar Malik
AWS Certified Solutions Architect Associate Exam Guide_published .pdfAWS Certified Solutions Architect Associate Exam Guide_published .pdf
AWS Certified Solutions Architect Associate Exam Guide_published .pdf
Kiran Kumar Malik6 visualizações
unit 1.pptx por rrbornarecm
unit 1.pptxunit 1.pptx
unit 1.pptx
rrbornarecm5 visualizações

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