SlideShare a Scribd company logo
1 of 34
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

More Related Content

What's hot

Data transfer and manipulation
Data transfer and manipulationData transfer and manipulation
Data transfer and manipulationSanjeev Patel
 
Computer architecture
Computer architectureComputer architecture
Computer architectureZuhaib Zaroon
 
Chapter 03 arithmetic for computers
Chapter 03   arithmetic for computersChapter 03   arithmetic for computers
Chapter 03 arithmetic for computersBảo Hoang
 
Computer registers
Computer registersComputer registers
Computer registersDeepikaT13
 
instruction format and addressing modes
instruction format and addressing modesinstruction format and addressing modes
instruction format and addressing modesRamaPrabha24
 
Processor Organization
Processor OrganizationProcessor Organization
Processor OrganizationDominik Salvet
 
Register transfer language
Register transfer languageRegister transfer language
Register transfer languageSanjeev Patel
 
General register organization (computer organization)
General register organization  (computer organization)General register organization  (computer organization)
General register organization (computer organization)rishi ram khanal
 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and ArchitectureVinit Raut
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 80869840596838
 
Computer architecture pipelining
Computer architecture pipeliningComputer architecture pipelining
Computer architecture pipeliningMazin Alwaaly
 
Types of Addressing modes- COA
Types of Addressing modes- COATypes of Addressing modes- COA
Types of Addressing modes- COARuchi Maurya
 
Computer architecture register transfer languages rtl
Computer architecture register transfer languages rtlComputer architecture register transfer languages rtl
Computer architecture register transfer languages rtlMazin Alwaaly
 
Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1) Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1) Subhasis Dash
 
Computer architecture addressing modes and formats
Computer architecture addressing modes and formatsComputer architecture addressing modes and formats
Computer architecture addressing modes and formatsMazin Alwaaly
 
Computer Organization Lecture Notes
Computer Organization Lecture NotesComputer Organization Lecture Notes
Computer Organization Lecture NotesFellowBuddy.com
 

What's hot (20)

Data transfer and manipulation
Data transfer and manipulationData transfer and manipulation
Data transfer and manipulation
 
Computer architecture
Computer architectureComputer architecture
Computer architecture
 
Chapter 03 arithmetic for computers
Chapter 03   arithmetic for computersChapter 03   arithmetic for computers
Chapter 03 arithmetic for computers
 
Computer registers
Computer registersComputer registers
Computer registers
 
instruction format and addressing modes
instruction format and addressing modesinstruction format and addressing modes
instruction format and addressing modes
 
Processor Organization
Processor OrganizationProcessor Organization
Processor Organization
 
Register transfer language
Register transfer languageRegister transfer language
Register transfer language
 
General register organization (computer organization)
General register organization  (computer organization)General register organization  (computer organization)
General register organization (computer organization)
 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and Architecture
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Computer architecture pipelining
Computer architecture pipeliningComputer architecture pipelining
Computer architecture pipelining
 
Types of Addressing modes- COA
Types of Addressing modes- COATypes of Addressing modes- COA
Types of Addressing modes- COA
 
Computer architecture register transfer languages rtl
Computer architecture register transfer languages rtlComputer architecture register transfer languages rtl
Computer architecture register transfer languages rtl
 
mano.ppt
mano.pptmano.ppt
mano.ppt
 
CISC & RISC Architecture
CISC & RISC Architecture CISC & RISC Architecture
CISC & RISC Architecture
 
Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1) Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1)
 
Instruction code
Instruction codeInstruction code
Instruction code
 
Instruction format
Instruction formatInstruction format
Instruction format
 
Computer architecture addressing modes and formats
Computer architecture addressing modes and formatsComputer architecture addressing modes and formats
Computer architecture addressing modes and formats
 
Computer Organization Lecture Notes
Computer Organization Lecture NotesComputer Organization Lecture Notes
Computer Organization Lecture Notes
 

Viewers also liked

Mips implementation
Mips implementationMips implementation
Mips implementationhoang974
 
05 instruction set design and architecture
05 instruction set design and architecture05 instruction set design and architecture
05 instruction set design and architectureWaqar Jamil
 
8 bit single cycle processor
8 bit single cycle processor8 bit single cycle processor
8 bit single cycle processorDhaval Kaneria
 
Micro Programmed Control Unit
Micro Programmed Control UnitMicro Programmed Control Unit
Micro Programmed Control UnitKamal Acharya
 
MicroProgrammed Explained .
MicroProgrammed Explained .MicroProgrammed Explained .
MicroProgrammed Explained .Muhammad Umar
 
15 control-computer organization and archietecture-CO-COA
15 control-computer organization and archietecture-CO-COA15 control-computer organization and archietecture-CO-COA
15 control-computer organization and archietecture-CO-COAJay Patel
 
Computer architecture
Computer architectureComputer architecture
Computer architectureneclinux
 
Micro programmed control
Micro programmed  controlMicro programmed  control
Micro programmed controlShashank Singh
 
basic computer programming and micro programmed control
basic computer programming and micro programmed controlbasic computer programming and micro programmed control
basic computer programming and micro programmed controlRai University
 
Lec 12-15 mips instruction set processor
Lec 12-15 mips instruction set processorLec 12-15 mips instruction set processor
Lec 12-15 mips instruction set processorMayank Roy
 
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...
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...Rahul Borthakur
 
Origin of Microprocessor and Classification of Microprocessor
Origin of Microprocessor and  Classification of Microprocessor Origin of Microprocessor and  Classification of Microprocessor
Origin of Microprocessor and Classification of Microprocessor Vijay Kumar
 
Computer Architecture – An Introduction
Computer Architecture – An IntroductionComputer Architecture – An Introduction
Computer Architecture – An IntroductionDilum Bandara
 
Microprogram Control
Microprogram Control Microprogram Control
Microprogram Control Anuj Modi
 
Types of instructions
Types of instructionsTypes of instructions
Types of instructionsihsanjamil
 

Viewers also liked (18)

Mips implementation
Mips implementationMips implementation
Mips implementation
 
06 mips-isa
06 mips-isa06 mips-isa
06 mips-isa
 
Case study of digital camera
Case study of digital cameraCase study of digital camera
Case study of digital camera
 
05 instruction set design and architecture
05 instruction set design and architecture05 instruction set design and architecture
05 instruction set design and architecture
 
8 bit alu design
8 bit alu design8 bit alu design
8 bit alu design
 
8 bit single cycle processor
8 bit single cycle processor8 bit single cycle processor
8 bit single cycle processor
 
Micro Programmed Control Unit
Micro Programmed Control UnitMicro Programmed Control Unit
Micro Programmed Control Unit
 
MicroProgrammed Explained .
MicroProgrammed Explained .MicroProgrammed Explained .
MicroProgrammed Explained .
 
15 control-computer organization and archietecture-CO-COA
15 control-computer organization and archietecture-CO-COA15 control-computer organization and archietecture-CO-COA
15 control-computer organization and archietecture-CO-COA
 
Computer architecture
Computer architectureComputer architecture
Computer architecture
 
Micro programmed control
Micro programmed  controlMicro programmed  control
Micro programmed control
 
basic computer programming and micro programmed control
basic computer programming and micro programmed controlbasic computer programming and micro programmed control
basic computer programming and micro programmed control
 
Lec 12-15 mips instruction set processor
Lec 12-15 mips instruction set processorLec 12-15 mips instruction set processor
Lec 12-15 mips instruction set processor
 
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...
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...
 
Origin of Microprocessor and Classification of Microprocessor
Origin of Microprocessor and  Classification of Microprocessor Origin of Microprocessor and  Classification of Microprocessor
Origin of Microprocessor and Classification of Microprocessor
 
Computer Architecture – An Introduction
Computer Architecture – An IntroductionComputer Architecture – An Introduction
Computer Architecture – An Introduction
 
Microprogram Control
Microprogram Control Microprogram Control
Microprogram Control
 
Types of instructions
Types of instructionsTypes of instructions
Types of instructions
 

Similar to Instruction Set Architecture

multi cycle in microprocessor 8086 sy B-tech
multi cycle  in microprocessor 8086 sy B-techmulti cycle  in microprocessor 8086 sy B-tech
multi cycle in microprocessor 8086 sy B-techRushikeshThorat24
 
Lecture1 - Computer Architecture
Lecture1 - Computer ArchitectureLecture1 - Computer Architecture
Lecture1 - Computer ArchitectureVolodymyr Ushenko
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5PRADEEP
 
Control unit-implementation
Control unit-implementationControl unit-implementation
Control unit-implementationWBUTTUTORIALS
 
Ec 252 ec-252-l10-instruction sets and addressing modes
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 modesbhshmuec
 
5th unit Microprocessor 8085
5th unit Microprocessor 80855th unit Microprocessor 8085
5th unit Microprocessor 8085Mani Afranzio
 
Computer Organization and 8085 microprocessor notes
Computer Organization and 8085 microprocessor notesComputer Organization and 8085 microprocessor notes
Computer Organization and 8085 microprocessor notesLakshmi Sarvani Videla
 
Systemsoftwarenotes 100929171256-phpapp02 2
Systemsoftwarenotes 100929171256-phpapp02 2Systemsoftwarenotes 100929171256-phpapp02 2
Systemsoftwarenotes 100929171256-phpapp02 2Khaja Dileef
 
Alu design-project
Alu design-projectAlu design-project
Alu design-projectalphankg1
 
Examinable Question and answer system programming
Examinable Question and answer system programmingExaminable Question and answer system programming
Examinable Question and answer system programmingMakerere university
 
Basic processing unit by aniket bhute
Basic processing unit by aniket bhuteBasic processing unit by aniket bhute
Basic processing unit by aniket bhuteAniket Bhute
 
Presentation computer architechure (1)
Presentation computer architechure (1)Presentation computer architechure (1)
Presentation computer architechure (1)Amr Ahmed
 
Embedded system (Chapter 2) part 2
Embedded system (Chapter 2) part 2Embedded system (Chapter 2) part 2
Embedded system (Chapter 2) part 2Ikhwan_Fakrudin
 

Similar to Instruction Set Architecture (20)

multi cycle in microprocessor 8086 sy B-tech
multi cycle  in microprocessor 8086 sy B-techmulti cycle  in microprocessor 8086 sy B-tech
multi cycle in microprocessor 8086 sy B-tech
 
Lecture1 - Computer Architecture
Lecture1 - Computer ArchitectureLecture1 - Computer Architecture
Lecture1 - Computer Architecture
 
viva q&a for mp lab
viva q&a for mp labviva q&a for mp lab
viva q&a for mp lab
 
instruction
instruction instruction
instruction
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
 
Assembler
AssemblerAssembler
Assembler
 
Control unit-implementation
Control unit-implementationControl unit-implementation
Control unit-implementation
 
Ec 252 ec-252-l10-instruction sets and addressing modes
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
 
5th unit Microprocessor 8085
5th unit Microprocessor 80855th unit Microprocessor 8085
5th unit Microprocessor 8085
 
Computer Organization and 8085 microprocessor notes
Computer Organization and 8085 microprocessor notesComputer Organization and 8085 microprocessor notes
Computer Organization and 8085 microprocessor notes
 
Systemsoftwarenotes 100929171256-phpapp02 2
Systemsoftwarenotes 100929171256-phpapp02 2Systemsoftwarenotes 100929171256-phpapp02 2
Systemsoftwarenotes 100929171256-phpapp02 2
 
Alu design-project
Alu design-projectAlu design-project
Alu design-project
 
Examinable Question and answer system programming
Examinable Question and answer system programmingExaminable Question and answer system programming
Examinable Question and answer system programming
 
Basic processing unit by aniket bhute
Basic processing unit by aniket bhuteBasic processing unit by aniket bhute
Basic processing unit by aniket bhute
 
Ch 2.pptx
Ch 2.pptxCh 2.pptx
Ch 2.pptx
 
Presentation computer architechure (1)
Presentation computer architechure (1)Presentation computer architechure (1)
Presentation computer architechure (1)
 
Presentation
PresentationPresentation
Presentation
 
Embedded system (Chapter 2) part 2
Embedded system (Chapter 2) part 2Embedded system (Chapter 2) part 2
Embedded system (Chapter 2) part 2
 
CAO-Unit-I.pptx
CAO-Unit-I.pptxCAO-Unit-I.pptx
CAO-Unit-I.pptx
 
Ch5_MorrisMano.pptx
Ch5_MorrisMano.pptxCh5_MorrisMano.pptx
Ch5_MorrisMano.pptx
 

More from Dilum Bandara

Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine LearningDilum Bandara
 
Time Series Analysis and Forecasting in Practice
Time Series Analysis and Forecasting in PracticeTime Series Analysis and Forecasting in Practice
Time Series Analysis and Forecasting in PracticeDilum Bandara
 
Introduction to Dimension Reduction with PCA
Introduction to Dimension Reduction with PCAIntroduction to Dimension Reduction with PCA
Introduction to Dimension Reduction with PCADilum Bandara
 
Introduction to Descriptive & Predictive Analytics
Introduction to Descriptive & Predictive AnalyticsIntroduction to Descriptive & Predictive Analytics
Introduction to Descriptive & Predictive AnalyticsDilum Bandara
 
Introduction to Concurrent Data Structures
Introduction to Concurrent Data StructuresIntroduction to Concurrent Data Structures
Introduction to Concurrent Data StructuresDilum Bandara
 
Hard to Paralelize Problems: Matrix-Vector and Matrix-Matrix
Hard to Paralelize Problems: Matrix-Vector and Matrix-MatrixHard to Paralelize Problems: Matrix-Vector and Matrix-Matrix
Hard to Paralelize Problems: Matrix-Vector and Matrix-MatrixDilum Bandara
 
Introduction to Map-Reduce Programming with Hadoop
Introduction to Map-Reduce Programming with HadoopIntroduction to Map-Reduce Programming with Hadoop
Introduction to Map-Reduce Programming with HadoopDilum Bandara
 
Embarrassingly/Delightfully Parallel Problems
Embarrassingly/Delightfully Parallel ProblemsEmbarrassingly/Delightfully Parallel Problems
Embarrassingly/Delightfully Parallel ProblemsDilum Bandara
 
Introduction to Warehouse-Scale Computers
Introduction to Warehouse-Scale ComputersIntroduction to Warehouse-Scale Computers
Introduction to Warehouse-Scale ComputersDilum Bandara
 
Introduction to Thread Level Parallelism
Introduction to Thread Level ParallelismIntroduction to Thread Level Parallelism
Introduction to Thread Level ParallelismDilum Bandara
 
CPU Memory Hierarchy and Caching Techniques
CPU Memory Hierarchy and Caching TechniquesCPU Memory Hierarchy and Caching Techniques
CPU Memory Hierarchy and Caching TechniquesDilum Bandara
 
Data-Level Parallelism in Microprocessors
Data-Level Parallelism in MicroprocessorsData-Level Parallelism in Microprocessors
Data-Level Parallelism in MicroprocessorsDilum Bandara
 
Instruction Level Parallelism – Hardware Techniques
Instruction Level Parallelism – Hardware TechniquesInstruction Level Parallelism – Hardware Techniques
Instruction Level Parallelism – Hardware TechniquesDilum Bandara
 
Instruction Level Parallelism – Compiler Techniques
Instruction Level Parallelism – Compiler TechniquesInstruction Level Parallelism – Compiler Techniques
Instruction Level Parallelism – Compiler TechniquesDilum Bandara
 
CPU Pipelining and Hazards - An Introduction
CPU Pipelining and Hazards - An IntroductionCPU Pipelining and Hazards - An Introduction
CPU Pipelining and Hazards - An IntroductionDilum Bandara
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
High Performance Networking with Advanced TCP
High Performance Networking with Advanced TCPHigh Performance Networking with Advanced TCP
High Performance Networking with Advanced TCPDilum Bandara
 
Introduction to Content Delivery Networks
Introduction to Content Delivery NetworksIntroduction to Content Delivery Networks
Introduction to Content Delivery NetworksDilum Bandara
 
Peer-to-Peer Networking Systems and Streaming
Peer-to-Peer Networking Systems and StreamingPeer-to-Peer Networking Systems and Streaming
Peer-to-Peer Networking Systems and StreamingDilum Bandara
 

More from Dilum Bandara (20)

Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learning
 
Time Series Analysis and Forecasting in Practice
Time Series Analysis and Forecasting in PracticeTime Series Analysis and Forecasting in Practice
Time Series Analysis and Forecasting in Practice
 
Introduction to Dimension Reduction with PCA
Introduction to Dimension Reduction with PCAIntroduction to Dimension Reduction with PCA
Introduction to Dimension Reduction with PCA
 
Introduction to Descriptive & Predictive Analytics
Introduction to Descriptive & Predictive AnalyticsIntroduction to Descriptive & Predictive Analytics
Introduction to Descriptive & Predictive Analytics
 
Introduction to Concurrent Data Structures
Introduction to Concurrent Data StructuresIntroduction to Concurrent Data Structures
Introduction to Concurrent Data Structures
 
Hard to Paralelize Problems: Matrix-Vector and Matrix-Matrix
Hard to Paralelize Problems: Matrix-Vector and Matrix-MatrixHard to Paralelize Problems: Matrix-Vector and Matrix-Matrix
Hard to Paralelize Problems: Matrix-Vector and Matrix-Matrix
 
Introduction to Map-Reduce Programming with Hadoop
Introduction to Map-Reduce Programming with HadoopIntroduction to Map-Reduce Programming with Hadoop
Introduction to Map-Reduce Programming with Hadoop
 
Embarrassingly/Delightfully Parallel Problems
Embarrassingly/Delightfully Parallel ProblemsEmbarrassingly/Delightfully Parallel Problems
Embarrassingly/Delightfully Parallel Problems
 
Introduction to Warehouse-Scale Computers
Introduction to Warehouse-Scale ComputersIntroduction to Warehouse-Scale Computers
Introduction to Warehouse-Scale Computers
 
Introduction to Thread Level Parallelism
Introduction to Thread Level ParallelismIntroduction to Thread Level Parallelism
Introduction to Thread Level Parallelism
 
CPU Memory Hierarchy and Caching Techniques
CPU Memory Hierarchy and Caching TechniquesCPU Memory Hierarchy and Caching Techniques
CPU Memory Hierarchy and Caching Techniques
 
Data-Level Parallelism in Microprocessors
Data-Level Parallelism in MicroprocessorsData-Level Parallelism in Microprocessors
Data-Level Parallelism in Microprocessors
 
Instruction Level Parallelism – Hardware Techniques
Instruction Level Parallelism – Hardware TechniquesInstruction Level Parallelism – Hardware Techniques
Instruction Level Parallelism – Hardware Techniques
 
Instruction Level Parallelism – Compiler Techniques
Instruction Level Parallelism – Compiler TechniquesInstruction Level Parallelism – Compiler Techniques
Instruction Level Parallelism – Compiler Techniques
 
CPU Pipelining and Hazards - An Introduction
CPU Pipelining and Hazards - An IntroductionCPU Pipelining and Hazards - An Introduction
CPU Pipelining and Hazards - An Introduction
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
High Performance Networking with Advanced TCP
High Performance Networking with Advanced TCPHigh Performance Networking with Advanced TCP
High Performance Networking with Advanced TCP
 
Introduction to Content Delivery Networks
Introduction to Content Delivery NetworksIntroduction to Content Delivery Networks
Introduction to Content Delivery Networks
 
Peer-to-Peer Networking Systems and Streaming
Peer-to-Peer Networking Systems and StreamingPeer-to-Peer Networking Systems and Streaming
Peer-to-Peer Networking Systems and Streaming
 
Mobile Services
Mobile ServicesMobile Services
Mobile Services
 

Recently uploaded

home automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadhome automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadaditya806802
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptNarmatha D
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating SystemRashmi Bhat
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsSachinPawar510423
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdfCaalaaAbdulkerim
 
Industrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESIndustrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESNarmatha D
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - GuideGOPINATHS437943
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxsiddharthjain2303
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating SystemRashmi Bhat
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 

Recently uploaded (20)

home automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadhome automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasad
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.ppt
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documents
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdf
 
Industrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESIndustrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIES
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - Guide
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptx
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating System
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 

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