SlideShare a Scribd company logo
Instruction Sets
Contents
2
• What is instruction set?
• Elements of an Instruction
• Op-code Encoding
• Instruction Types
• Data Transfer, data Processing, and Control
• Types of Operand
• Instruction Formats
• Instruction Length
• Number of Addresses
What is an Instruction Set?
• It is the list of instructions available for the CPU
• RISC, CISC, VLIW, etc.
• These instructions are written in machine language(binary
representation)
• But for human understanding, we represent the instructions in
assembly level language
• Assembly language consists of mnemonics
• e.g., MOV A, B (A  B)
• Here, Op-code is  MOV and Operands are  A, B
3
Elements of an Instruction
 Operation code (Op-code)
 e.g., LOAD, STOR, ADD, SUB, MPY, DIV
 Source operand reference
 address of source operand of operation, e.g. register, memory
location, I/O
 Destination operand reference
 address of destination /result operand of operation, e.g.
register, memory location, I/O
4
Simple Instruction Format 5
Op-code Source operand reference Destination operand reference
32 bits
8 bits 12 bits 12 bits
4 byte instruction
Byte ordering
 how the bytes of an instruction are organized in a word
1. Big-endian: bytes in word are ordered from left-to-right, e.g.,
Motorola
2. Little-endian: bytes in word are ordered right-to-left, e.g., Intel
6
Big endian
0 0 1 2 3
4 4 5 6 7
8 8 9 10 11
12 12 13 14 15
Address
32 bits
Little endian
3 2 1 0 0
7 6 5 4 4
11 10 9 8 8
12 13 14 15 12
Address
32 bits
Word 0
Word 1
Word 2
Word 3
Word 0
Word 1
Word 2
Word 3
Instruction Cycle State Diagram7
Instruction
fetch
Instruction
decode
Operand
address
computation
Operand
fetch
Operation
Operand
address
computation
Operand store
Instruction
address
computation
Multiple
operands
Multiple
results
Return vector data
Fetch next instruction
Op-code Encoding
 Op-code field must have at least N bits to encode 2N instructions
 Need Op-code encoding technique
 There are 2 types of op-code encoding
1. Block-code technique
2. Expanding op-code technique
Block-code technique
 An N-to-2N decoder is used to decode all the instructions.
8
N-to-2N
decoder
N-bit op-code
instruction 0
instruction 1
instruction 2
Instruction 2N - 1
.
.
.
.
.
.
Op-code Encoding
Op-code Address 1 Address 2 Address 3
1 1 1 1 Op-code Address 1 Address 2
9
Expanding op-code technique
 If there are only 15 such three-address instructions
 then one of the unused op-code can be used to expand the instruction
set it to two-address, one-address or zero address instructions
 A compromise between large instruction set and short op-
codes, thus short instructions
 When the op-code is short, a lot of bits are left to hold the
operands
 Let an (4+12) bit instruction with a 4-bit op-code and three 4-
bit addresses
 can at most encode (24=16) three-address instructions
Expanding op-code technique
1 1 1 1 1 1 1 1 Op-code Address 1
1 1 1 1 1 1 1 1 1 1 1 1 Op-code
10
 Similarly, this expanded op-code field can encode at most 16
two-address instructions.
 if there are less than 16 such instructions, we can expand
the op-code further
 Here, the three-address instruction can hold 3 operands of 4-bit
address fields or it can hold 1 operand of12-bit address field
 Some part of the op-code can be used to specify the instruction format
and/or length
11
 Let encode the following instructions
 15 instructions with 3 addresses
 14 instructions with 2 addresses
 31 instructions with 1 address
 16 instructions with 0 address
0000 O1 O2 O3
1110 O1 O2 O3
1111 0000 O1 O2
1111 1101 O1 O2
1111 1110 0000-1111 O1
1111 1111 0000-1110 O1
1111 1111 1111 0000
1111 1111 1111 1111
Expanding op-code technique
Instruction length Vs. speed
• Shorter instructions have faster fetch and decode time
• Advantages of shorter instructions are:
1. less space in memory
2. Faster transfer to the CPU
• Each instructions in instruction set can be encoded with
minimum number of bit – Huffman encoding
• But instructions need to be decoded bit by bit, can be slow
12
Design Goals
 Operation
 How many ops?
 What can they do?
 How complex are they?
 Data types (length of words, number representation)
 Instruction formats
 Length of op-code field
 Length and number of addresses
 Registers
 Number of CPU registers available
 Which operations can be performed on which registers? General
purpose and specific registers
 Addressing modes (next class)
13
Types of the instructions
There are 3 types of instructions
1. Data transfer: registers, main memory, stack or I/O
2. Data processing:
1. Arithmetic, e.g., ADD, SUB
2. logical, e.g., AND, OR
3. Control:
1. system control, e.g., Test-And-Set
2. Program Control
1. Unconditional branch, e.g., J B
2. Conditional branch, e.g., BEQ A, B, target
3. Subroutine call, e.g., RET
4. Interrupt-handling, e.g., TRAP
14
Data Transfer
15
I/O Operations
.
 In case of I/O mapped I/O, dedicated I/O instructions are used , e.g.
INPUT, OUTPUT
 But, in case of memory mapped I/O, data transfer instructions are used
 Or it may be done by a separate controller (DMA), e.g., Start I/O, Test I/O
 Load, Store, move, clear, set, push, pop, etc.
 Contains source and destination operand
 Register, memory, stack
Arithmetic
 ADD, SUB, MUL, DIV, INC, DEC, etc.
 May include data transfer instructions
16
Logical
 AND, OR, NOT, XOR, SET, CMP
 May include shift instructions to perform complex tasks
 Arithmetic left shift multiply the operand by 2 (without overflow)
 Arithmetic right shift divide the operand by 2 (truncate for odd number)
 logical right shift is used to transfer the lower order byte from from 16-bit
word
Control Instruction
System control
 privileged instructions used to accessing control registers or
process table, e.g., STOP, HALT, RTE, etc.
 Used by operating systems in kernel mode
17
Program Control/ Control Transfer
 Unconditional branch:
 jump into any location without condition, e.g., J
 conditional branch:
 Jump into any location based upon some condition, e.g., BEQ
 Subroutine call:
 used to call a subroutine, e.g., CALL, RET
 Interrupt-handling:
 used to invoke an interrupt, e.g., TRAP
Branch Instruction 18
Memory
Address
500
501
502
.
.
.
700
701
.
.
.
ADD A, B
BRZ 701
BR 501
unconditional
branch
conditional
branch
Instructions
Nested Subroutine Calls 19
Memory
……
Call Subroutine 1
……
Return
Subroutine 1
Subroutine 2
Main Program
……
Call Subroutine 2
……
Call Subroutine 2
……
Return
……
……
……
Return
Control flow diagram
Address
500
600
601
1000
1100
1101
2000
1200
1201
Use of Stack and stack pointer 20
601
1201
601
601
1101
601
601
Next address
after
call subroutine 1
SP = 601
Next address
after
call subroutine 2
SP = 1101
Return from
subroutine 2
Pop  1101
Next address
after
call subroutine 2
SP = 1201
Return from
subroutine 2
Pop  1201
Return from
subroutine 1
Pop  601
500 : Main Program
600 : call Subroutine 1
1100 : call Subroutine 2
1200 : call Subroutine 2
Types of Operand
 Addressing mode: direct, indirect, etc.
 Number representation:
 integer, fixed point (2scomplement)
 floating point (sign, significant, exponent)
 (packed) decimal
 Character coding: ASCII
 Flag bits (Boolean 0 or Boolean 1)
21
Instruction Formats
 It is the bit encoding in an instruction
 It consists of 2 fields
1. Op-code field
2. Operand field
 Operand(s) can be implicit or explicit
 There exists different instruction formats in an instruction set
22
Instruction Length
 The length of an instruction depends on the followings:
1. Memory size
2. Addressing mode
3. Bus structure, e.g., width
4. CPU complexity
5. CPU speed
 Trade off between powerful instruction set and saving space
 Expanding op-code technique
23
Number of Addresses in an instruction
 More addresses
 Registers and inter-register operations are quicker
 Less instructions per program
 More complex instructions
 Fewer addresses
 Faster fetch/execution of instructions
 More instructions per program, e.g. data movement
 Less complex instructions
24
Based on number of addresses instructions can be of 4 types
1. 3 address instruction
2. 2 address instruction
3. 1 address instruction
4. 0(zero) address instruction
3 address instruction
 Needs very long words to hold everything
 Not common
1. ADD F,A,B F  A+B
2. MPY T,D,E T  DxE
3. SUB T,T,C T  T-C
4. DIV F,F,T F  F/T
25
Op-code Result Operand 1 Operand 2
F = (A + B) / [(C - (D x E)]
2 address instruction
 Reduces length of instruction
 Requires extra work: temporary storage
1. MOVE F,A F  A
2. ADD F,B F  F+B
3. MOVE T,D T  D
4. MPY T,E T  TxE
5. SUB T,C T  T-C
6. DIV F,T F  F:T
26
Op-code Result Operand 1
F = (A + B) / [(C - (D x E)]
1 address instruction
 Implicit second address, usually a register (accumulator, AC)
1. LOAD D AC  D
2. MPY E AC  ACxE
3. SUB C AC  AC-C
4. STOR F F  AC
5. LOAD A AC  A
6. ADD B AC  AC+B
7. DIV F AC  AC:F
8. STOR F F  AC
27
Op-code Operand 1
F = (A + B) : [(C - (D x E)]
0 (zero) address instruction
All addresses are implicit, e.g. ADD
 Uses a stack
1. pop A
2. pop B
3. ADD
4. Push
28
Op-code
C = (A + B)

More Related Content

What's hot

Computer Organisation - Addressing Modes
Computer Organisation - Addressing ModesComputer Organisation - Addressing Modes
Computer Organisation - Addressing Modes
ArunaDevi63
 
Addressing modes/Addressing Mode with illustration/ Addressing mode in 8086
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
samirbharat77
 
Addressing Modes
Addressing ModesAddressing Modes
Addressing Modes
Mayank Garg
 
Computer organization and architecture
Computer organization and architectureComputer organization and architecture
Computer organization and architectureSubesh Kumar Yadav
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
Shehrevar Davierwala
 
Memory Addressing
Memory AddressingMemory Addressing
Memory Addressing
chauhankapil
 
Assembly Language Basics
Assembly Language BasicsAssembly Language Basics
Assembly Language Basics
Education Front
 
Data transfer and manipulation
Data transfer and manipulationData transfer and manipulation
Data transfer and manipulation
Sanjeev Patel
 
isa architecture
isa architectureisa architecture
isa architecture
AJAL A J
 
Addressing modes ppt
Addressing modes pptAddressing modes ppt
Addressing modes ppt
sanjay pachauri
 
Part I:Introduction to assembly language
Part I:Introduction to assembly languagePart I:Introduction to assembly language
Part I:Introduction to assembly languageAhmed M. Abed
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
Mukta Garg
 
Computer instruction
Computer instructionComputer instruction
Computer instruction
Sanjeev Patel
 
Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA)Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA)
Gaditek
 
Data transfer and manipulation
Data transfer and manipulationData transfer and manipulation
Data transfer and manipulation
janani thirupathi
 
Instruction codes and computer registers
Instruction codes and computer registersInstruction codes and computer registers
Instruction codes and computer registers
Sanjeev Patel
 
11 instruction sets addressing modes
11  instruction sets addressing modes 11  instruction sets addressing modes
11 instruction sets addressing modes Sher Shah Merkhel
 
loaders and linkers
 loaders and linkers loaders and linkers
loaders and linkers
Temesgen Molla
 
ADDRESSING MODE
ADDRESSING MODEADDRESSING MODE
ADDRESSING MODE
Anika Shahabuddin
 
Instruction format
Instruction formatInstruction format
Instruction format
Sanjeev Patel
 

What's hot (20)

Computer Organisation - Addressing Modes
Computer Organisation - Addressing ModesComputer Organisation - Addressing Modes
Computer Organisation - Addressing Modes
 
Addressing modes/Addressing Mode with illustration/ Addressing mode in 8086
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
 
Addressing Modes
Addressing ModesAddressing Modes
Addressing Modes
 
Computer organization and architecture
Computer organization and architectureComputer organization and architecture
Computer organization and architecture
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 
Memory Addressing
Memory AddressingMemory Addressing
Memory Addressing
 
Assembly Language Basics
Assembly Language BasicsAssembly Language Basics
Assembly Language Basics
 
Data transfer and manipulation
Data transfer and manipulationData transfer and manipulation
Data transfer and manipulation
 
isa architecture
isa architectureisa architecture
isa architecture
 
Addressing modes ppt
Addressing modes pptAddressing modes ppt
Addressing modes ppt
 
Part I:Introduction to assembly language
Part I:Introduction to assembly languagePart I:Introduction to assembly language
Part I:Introduction to assembly language
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
Computer instruction
Computer instructionComputer instruction
Computer instruction
 
Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA)Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA)
 
Data transfer and manipulation
Data transfer and manipulationData transfer and manipulation
Data transfer and manipulation
 
Instruction codes and computer registers
Instruction codes and computer registersInstruction codes and computer registers
Instruction codes and computer registers
 
11 instruction sets addressing modes
11  instruction sets addressing modes 11  instruction sets addressing modes
11 instruction sets addressing modes
 
loaders and linkers
 loaders and linkers loaders and linkers
loaders and linkers
 
ADDRESSING MODE
ADDRESSING MODEADDRESSING MODE
ADDRESSING MODE
 
Instruction format
Instruction formatInstruction format
Instruction format
 

Similar to Instruction set (prasenjit dey)

Compreport
CompreportCompreport
Compreport
xdarlord
 
Computer architecture instruction formats
Computer architecture instruction formatsComputer architecture instruction formats
Computer architecture instruction formats
Mazin Alwaaly
 
Instruction codes
Instruction codesInstruction codes
Instruction codes
pradeepa velmurugan
 
(246431835) instruction set principles (2) (1)
(246431835) instruction set principles (2) (1)(246431835) instruction set principles (2) (1)
(246431835) instruction set principles (2) (1)Alveena Saleem
 
Instruction-Sets-2.pptx
Instruction-Sets-2.pptxInstruction-Sets-2.pptx
Instruction-Sets-2.pptx
ClaivemaxGonzales
 
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
 
MCA-I-COA- overview of register transfer, micro operations and basic computer...
MCA-I-COA- overview of register transfer, micro operations and basic computer...MCA-I-COA- overview of register transfer, micro operations and basic computer...
MCA-I-COA- overview of register transfer, micro operations and basic computer...
Rai University
 
10 Instruction Sets Characteristics
10  Instruction  Sets Characteristics10  Instruction  Sets Characteristics
10 Instruction Sets CharacteristicsJeanie Delos Arcos
 
Bca 2nd sem-u-2.2-overview of register transfer, micro operations and basic c...
Bca 2nd sem-u-2.2-overview of register transfer, micro operations and basic c...Bca 2nd sem-u-2.2-overview of register transfer, micro operations and basic c...
Bca 2nd sem-u-2.2-overview of register transfer, micro operations and basic c...
Rai University
 
B.sc cs-ii-u-2.2-overview of register transfer, micro operations and basic co...
B.sc cs-ii-u-2.2-overview of register transfer, micro operations and basic co...B.sc cs-ii-u-2.2-overview of register transfer, micro operations and basic co...
B.sc cs-ii-u-2.2-overview of register transfer, micro operations and basic co...
Rai University
 
instruction sets (1).pptx
instruction sets (1).pptxinstruction sets (1).pptx
instruction sets (1).pptx
AmanMomin9
 
instruction format.pptx
instruction format.pptxinstruction format.pptx
instruction format.pptx
AshokRachapalli1
 
instruction
instruction instruction
instruction
Asif Iqbal
 
Computer_Organization and architecture _unit 1.pptx
Computer_Organization and architecture _unit 1.pptxComputer_Organization and architecture _unit 1.pptx
Computer_Organization and architecture _unit 1.pptx
ManimegalaM3
 
Central processor organization
Central processor organizationCentral processor organization
Central processor organization
Prof. Dr. K. Adisesha
 
CO_Chapter2.ppt
CO_Chapter2.pptCO_Chapter2.ppt
CO_Chapter2.ppt
Pranav726214
 
Introduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM ProcessorIntroduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM Processor
Darling Jemima
 
module-3.pptx
module-3.pptxmodule-3.pptx
module-3.pptx
Ambika Naik
 

Similar to Instruction set (prasenjit dey) (20)

Compreport
CompreportCompreport
Compreport
 
Computer architecture instruction formats
Computer architecture instruction formatsComputer architecture instruction formats
Computer architecture instruction formats
 
Instruction codes
Instruction codesInstruction codes
Instruction codes
 
(246431835) instruction set principles (2) (1)
(246431835) instruction set principles (2) (1)(246431835) instruction set principles (2) (1)
(246431835) instruction set principles (2) (1)
 
Instruction-Sets-2.pptx
Instruction-Sets-2.pptxInstruction-Sets-2.pptx
Instruction-Sets-2.pptx
 
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
 
MCA-I-COA- overview of register transfer, micro operations and basic computer...
MCA-I-COA- overview of register transfer, micro operations and basic computer...MCA-I-COA- overview of register transfer, micro operations and basic computer...
MCA-I-COA- overview of register transfer, micro operations and basic computer...
 
Bc0040
Bc0040Bc0040
Bc0040
 
10 Instruction Sets Characteristics
10  Instruction  Sets Characteristics10  Instruction  Sets Characteristics
10 Instruction Sets Characteristics
 
Bca 2nd sem-u-2.2-overview of register transfer, micro operations and basic c...
Bca 2nd sem-u-2.2-overview of register transfer, micro operations and basic c...Bca 2nd sem-u-2.2-overview of register transfer, micro operations and basic c...
Bca 2nd sem-u-2.2-overview of register transfer, micro operations and basic c...
 
9.cs instrset
9.cs instrset9.cs instrset
9.cs instrset
 
B.sc cs-ii-u-2.2-overview of register transfer, micro operations and basic co...
B.sc cs-ii-u-2.2-overview of register transfer, micro operations and basic co...B.sc cs-ii-u-2.2-overview of register transfer, micro operations and basic co...
B.sc cs-ii-u-2.2-overview of register transfer, micro operations and basic co...
 
instruction sets (1).pptx
instruction sets (1).pptxinstruction sets (1).pptx
instruction sets (1).pptx
 
instruction format.pptx
instruction format.pptxinstruction format.pptx
instruction format.pptx
 
instruction
instruction instruction
instruction
 
Computer_Organization and architecture _unit 1.pptx
Computer_Organization and architecture _unit 1.pptxComputer_Organization and architecture _unit 1.pptx
Computer_Organization and architecture _unit 1.pptx
 
Central processor organization
Central processor organizationCentral processor organization
Central processor organization
 
CO_Chapter2.ppt
CO_Chapter2.pptCO_Chapter2.ppt
CO_Chapter2.ppt
 
Introduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM ProcessorIntroduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM Processor
 
module-3.pptx
module-3.pptxmodule-3.pptx
module-3.pptx
 

More from Prasenjit Dey

Dynamic interconnection networks
Dynamic interconnection networksDynamic interconnection networks
Dynamic interconnection networks
Prasenjit Dey
 
Machine Learning in Agriculture Module 6: classification
Machine Learning in Agriculture Module 6: classificationMachine Learning in Agriculture Module 6: classification
Machine Learning in Agriculture Module 6: classification
Prasenjit Dey
 
Machine Learning in Agriculture Module 3: linear regression
Machine Learning in Agriculture Module 3: linear regressionMachine Learning in Agriculture Module 3: linear regression
Machine Learning in Agriculture Module 3: linear regression
Prasenjit Dey
 
Machine learning in agriculture module 2
Machine learning in agriculture module 2Machine learning in agriculture module 2
Machine learning in agriculture module 2
Prasenjit Dey
 
Machine Learning in Agriculture Module 1
Machine Learning in Agriculture Module 1Machine Learning in Agriculture Module 1
Machine Learning in Agriculture Module 1
Prasenjit Dey
 
Support vector machine
Support vector machineSupport vector machine
Support vector machine
Prasenjit Dey
 
Numerical on general pipelines
Numerical on general pipelinesNumerical on general pipelines
Numerical on general pipelines
Prasenjit Dey
 
General pipeline concepts
General pipeline conceptsGeneral pipeline concepts
General pipeline concepts
Prasenjit Dey
 
Evaluation of computer performance
Evaluation of computer performanceEvaluation of computer performance
Evaluation of computer performance
Prasenjit Dey
 
Instruction Set Architecture: MIPS
Instruction Set Architecture: MIPSInstruction Set Architecture: MIPS
Instruction Set Architecture: MIPS
Prasenjit Dey
 
Page replacement and thrashing
Page replacement and thrashingPage replacement and thrashing
Page replacement and thrashing
Prasenjit Dey
 
Addressing mode
Addressing modeAddressing mode
Addressing mode
Prasenjit Dey
 
Register transfer and microoperations part 2
Register transfer and microoperations part 2Register transfer and microoperations part 2
Register transfer and microoperations part 2
Prasenjit Dey
 
Register transfer and microoperations part 1
Register transfer and microoperations part 1Register transfer and microoperations part 1
Register transfer and microoperations part 1
Prasenjit Dey
 
Different types of memory and hardware designs of RAM and ROM
Different types of memory and hardware designs of RAM and ROMDifferent types of memory and hardware designs of RAM and ROM
Different types of memory and hardware designs of RAM and ROM
Prasenjit Dey
 
Cache memory
Cache  memoryCache  memory
Cache memory
Prasenjit Dey
 
Carry look ahead adder
Carry look ahead adder Carry look ahead adder
Carry look ahead adder
Prasenjit Dey
 
Binary division restoration and non restoration algorithm
Binary division restoration and non restoration algorithmBinary division restoration and non restoration algorithm
Binary division restoration and non restoration algorithm
Prasenjit Dey
 
Booth's algorithm
Booth's algorithm Booth's algorithm
Booth's algorithm
Prasenjit Dey
 
Computer organization basics and number systems
Computer organization basics and number systemsComputer organization basics and number systems
Computer organization basics and number systems
Prasenjit Dey
 

More from Prasenjit Dey (20)

Dynamic interconnection networks
Dynamic interconnection networksDynamic interconnection networks
Dynamic interconnection networks
 
Machine Learning in Agriculture Module 6: classification
Machine Learning in Agriculture Module 6: classificationMachine Learning in Agriculture Module 6: classification
Machine Learning in Agriculture Module 6: classification
 
Machine Learning in Agriculture Module 3: linear regression
Machine Learning in Agriculture Module 3: linear regressionMachine Learning in Agriculture Module 3: linear regression
Machine Learning in Agriculture Module 3: linear regression
 
Machine learning in agriculture module 2
Machine learning in agriculture module 2Machine learning in agriculture module 2
Machine learning in agriculture module 2
 
Machine Learning in Agriculture Module 1
Machine Learning in Agriculture Module 1Machine Learning in Agriculture Module 1
Machine Learning in Agriculture Module 1
 
Support vector machine
Support vector machineSupport vector machine
Support vector machine
 
Numerical on general pipelines
Numerical on general pipelinesNumerical on general pipelines
Numerical on general pipelines
 
General pipeline concepts
General pipeline conceptsGeneral pipeline concepts
General pipeline concepts
 
Evaluation of computer performance
Evaluation of computer performanceEvaluation of computer performance
Evaluation of computer performance
 
Instruction Set Architecture: MIPS
Instruction Set Architecture: MIPSInstruction Set Architecture: MIPS
Instruction Set Architecture: MIPS
 
Page replacement and thrashing
Page replacement and thrashingPage replacement and thrashing
Page replacement and thrashing
 
Addressing mode
Addressing modeAddressing mode
Addressing mode
 
Register transfer and microoperations part 2
Register transfer and microoperations part 2Register transfer and microoperations part 2
Register transfer and microoperations part 2
 
Register transfer and microoperations part 1
Register transfer and microoperations part 1Register transfer and microoperations part 1
Register transfer and microoperations part 1
 
Different types of memory and hardware designs of RAM and ROM
Different types of memory and hardware designs of RAM and ROMDifferent types of memory and hardware designs of RAM and ROM
Different types of memory and hardware designs of RAM and ROM
 
Cache memory
Cache  memoryCache  memory
Cache memory
 
Carry look ahead adder
Carry look ahead adder Carry look ahead adder
Carry look ahead adder
 
Binary division restoration and non restoration algorithm
Binary division restoration and non restoration algorithmBinary division restoration and non restoration algorithm
Binary division restoration and non restoration algorithm
 
Booth's algorithm
Booth's algorithm Booth's algorithm
Booth's algorithm
 
Computer organization basics and number systems
Computer organization basics and number systemsComputer organization basics and number systems
Computer organization basics and number systems
 

Recently uploaded

Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 

Recently uploaded (20)

Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 

Instruction set (prasenjit dey)

  • 2. Contents 2 • What is instruction set? • Elements of an Instruction • Op-code Encoding • Instruction Types • Data Transfer, data Processing, and Control • Types of Operand • Instruction Formats • Instruction Length • Number of Addresses
  • 3. What is an Instruction Set? • It is the list of instructions available for the CPU • RISC, CISC, VLIW, etc. • These instructions are written in machine language(binary representation) • But for human understanding, we represent the instructions in assembly level language • Assembly language consists of mnemonics • e.g., MOV A, B (A  B) • Here, Op-code is  MOV and Operands are  A, B 3
  • 4. Elements of an Instruction  Operation code (Op-code)  e.g., LOAD, STOR, ADD, SUB, MPY, DIV  Source operand reference  address of source operand of operation, e.g. register, memory location, I/O  Destination operand reference  address of destination /result operand of operation, e.g. register, memory location, I/O 4
  • 5. Simple Instruction Format 5 Op-code Source operand reference Destination operand reference 32 bits 8 bits 12 bits 12 bits 4 byte instruction
  • 6. Byte ordering  how the bytes of an instruction are organized in a word 1. Big-endian: bytes in word are ordered from left-to-right, e.g., Motorola 2. Little-endian: bytes in word are ordered right-to-left, e.g., Intel 6 Big endian 0 0 1 2 3 4 4 5 6 7 8 8 9 10 11 12 12 13 14 15 Address 32 bits Little endian 3 2 1 0 0 7 6 5 4 4 11 10 9 8 8 12 13 14 15 12 Address 32 bits Word 0 Word 1 Word 2 Word 3 Word 0 Word 1 Word 2 Word 3
  • 7. Instruction Cycle State Diagram7 Instruction fetch Instruction decode Operand address computation Operand fetch Operation Operand address computation Operand store Instruction address computation Multiple operands Multiple results Return vector data Fetch next instruction
  • 8. Op-code Encoding  Op-code field must have at least N bits to encode 2N instructions  Need Op-code encoding technique  There are 2 types of op-code encoding 1. Block-code technique 2. Expanding op-code technique Block-code technique  An N-to-2N decoder is used to decode all the instructions. 8 N-to-2N decoder N-bit op-code instruction 0 instruction 1 instruction 2 Instruction 2N - 1 . . . . . .
  • 9. Op-code Encoding Op-code Address 1 Address 2 Address 3 1 1 1 1 Op-code Address 1 Address 2 9 Expanding op-code technique  If there are only 15 such three-address instructions  then one of the unused op-code can be used to expand the instruction set it to two-address, one-address or zero address instructions  A compromise between large instruction set and short op- codes, thus short instructions  When the op-code is short, a lot of bits are left to hold the operands  Let an (4+12) bit instruction with a 4-bit op-code and three 4- bit addresses  can at most encode (24=16) three-address instructions
  • 10. Expanding op-code technique 1 1 1 1 1 1 1 1 Op-code Address 1 1 1 1 1 1 1 1 1 1 1 1 1 Op-code 10  Similarly, this expanded op-code field can encode at most 16 two-address instructions.  if there are less than 16 such instructions, we can expand the op-code further  Here, the three-address instruction can hold 3 operands of 4-bit address fields or it can hold 1 operand of12-bit address field  Some part of the op-code can be used to specify the instruction format and/or length
  • 11. 11  Let encode the following instructions  15 instructions with 3 addresses  14 instructions with 2 addresses  31 instructions with 1 address  16 instructions with 0 address 0000 O1 O2 O3 1110 O1 O2 O3 1111 0000 O1 O2 1111 1101 O1 O2 1111 1110 0000-1111 O1 1111 1111 0000-1110 O1 1111 1111 1111 0000 1111 1111 1111 1111 Expanding op-code technique
  • 12. Instruction length Vs. speed • Shorter instructions have faster fetch and decode time • Advantages of shorter instructions are: 1. less space in memory 2. Faster transfer to the CPU • Each instructions in instruction set can be encoded with minimum number of bit – Huffman encoding • But instructions need to be decoded bit by bit, can be slow 12
  • 13. Design Goals  Operation  How many ops?  What can they do?  How complex are they?  Data types (length of words, number representation)  Instruction formats  Length of op-code field  Length and number of addresses  Registers  Number of CPU registers available  Which operations can be performed on which registers? General purpose and specific registers  Addressing modes (next class) 13
  • 14. Types of the instructions There are 3 types of instructions 1. Data transfer: registers, main memory, stack or I/O 2. Data processing: 1. Arithmetic, e.g., ADD, SUB 2. logical, e.g., AND, OR 3. Control: 1. system control, e.g., Test-And-Set 2. Program Control 1. Unconditional branch, e.g., J B 2. Conditional branch, e.g., BEQ A, B, target 3. Subroutine call, e.g., RET 4. Interrupt-handling, e.g., TRAP 14
  • 15. Data Transfer 15 I/O Operations .  In case of I/O mapped I/O, dedicated I/O instructions are used , e.g. INPUT, OUTPUT  But, in case of memory mapped I/O, data transfer instructions are used  Or it may be done by a separate controller (DMA), e.g., Start I/O, Test I/O  Load, Store, move, clear, set, push, pop, etc.  Contains source and destination operand  Register, memory, stack
  • 16. Arithmetic  ADD, SUB, MUL, DIV, INC, DEC, etc.  May include data transfer instructions 16 Logical  AND, OR, NOT, XOR, SET, CMP  May include shift instructions to perform complex tasks  Arithmetic left shift multiply the operand by 2 (without overflow)  Arithmetic right shift divide the operand by 2 (truncate for odd number)  logical right shift is used to transfer the lower order byte from from 16-bit word
  • 17. Control Instruction System control  privileged instructions used to accessing control registers or process table, e.g., STOP, HALT, RTE, etc.  Used by operating systems in kernel mode 17 Program Control/ Control Transfer  Unconditional branch:  jump into any location without condition, e.g., J  conditional branch:  Jump into any location based upon some condition, e.g., BEQ  Subroutine call:  used to call a subroutine, e.g., CALL, RET  Interrupt-handling:  used to invoke an interrupt, e.g., TRAP
  • 18. Branch Instruction 18 Memory Address 500 501 502 . . . 700 701 . . . ADD A, B BRZ 701 BR 501 unconditional branch conditional branch Instructions
  • 19. Nested Subroutine Calls 19 Memory …… Call Subroutine 1 …… Return Subroutine 1 Subroutine 2 Main Program …… Call Subroutine 2 …… Call Subroutine 2 …… Return …… …… …… Return Control flow diagram Address 500 600 601 1000 1100 1101 2000 1200 1201
  • 20. Use of Stack and stack pointer 20 601 1201 601 601 1101 601 601 Next address after call subroutine 1 SP = 601 Next address after call subroutine 2 SP = 1101 Return from subroutine 2 Pop  1101 Next address after call subroutine 2 SP = 1201 Return from subroutine 2 Pop  1201 Return from subroutine 1 Pop  601 500 : Main Program 600 : call Subroutine 1 1100 : call Subroutine 2 1200 : call Subroutine 2
  • 21. Types of Operand  Addressing mode: direct, indirect, etc.  Number representation:  integer, fixed point (2scomplement)  floating point (sign, significant, exponent)  (packed) decimal  Character coding: ASCII  Flag bits (Boolean 0 or Boolean 1) 21
  • 22. Instruction Formats  It is the bit encoding in an instruction  It consists of 2 fields 1. Op-code field 2. Operand field  Operand(s) can be implicit or explicit  There exists different instruction formats in an instruction set 22
  • 23. Instruction Length  The length of an instruction depends on the followings: 1. Memory size 2. Addressing mode 3. Bus structure, e.g., width 4. CPU complexity 5. CPU speed  Trade off between powerful instruction set and saving space  Expanding op-code technique 23
  • 24. Number of Addresses in an instruction  More addresses  Registers and inter-register operations are quicker  Less instructions per program  More complex instructions  Fewer addresses  Faster fetch/execution of instructions  More instructions per program, e.g. data movement  Less complex instructions 24 Based on number of addresses instructions can be of 4 types 1. 3 address instruction 2. 2 address instruction 3. 1 address instruction 4. 0(zero) address instruction
  • 25. 3 address instruction  Needs very long words to hold everything  Not common 1. ADD F,A,B F  A+B 2. MPY T,D,E T  DxE 3. SUB T,T,C T  T-C 4. DIV F,F,T F  F/T 25 Op-code Result Operand 1 Operand 2 F = (A + B) / [(C - (D x E)]
  • 26. 2 address instruction  Reduces length of instruction  Requires extra work: temporary storage 1. MOVE F,A F  A 2. ADD F,B F  F+B 3. MOVE T,D T  D 4. MPY T,E T  TxE 5. SUB T,C T  T-C 6. DIV F,T F  F:T 26 Op-code Result Operand 1 F = (A + B) / [(C - (D x E)]
  • 27. 1 address instruction  Implicit second address, usually a register (accumulator, AC) 1. LOAD D AC  D 2. MPY E AC  ACxE 3. SUB C AC  AC-C 4. STOR F F  AC 5. LOAD A AC  A 6. ADD B AC  AC+B 7. DIV F AC  AC:F 8. STOR F F  AC 27 Op-code Operand 1 F = (A + B) : [(C - (D x E)]
  • 28. 0 (zero) address instruction All addresses are implicit, e.g. ADD  Uses a stack 1. pop A 2. pop B 3. ADD 4. Push 28 Op-code C = (A + B)

Editor's Notes

  1. 2
  2. 3
  3. 12
  4. 6
  5. 19
  6. 20
  7. 24
  8. 14
  9. 11
  10. 7
  11. 8
  12. 9
  13. 10