SlideShare a Scribd company logo
1 of 28
LU3- Instructions and Sequencing
Instructions and Sequencing
• Instructions for a computer must support:
–data transfers to and from the memory
–arithmetic and logic operations on data
–program sequencing and control
–input/output transfers
• First consider data transfer & arithmetic/logic
• Control and input/output examined later
Register Transfer Notation
• Register transfer notation is used to describe
hardware-level data transfers and operations
• Predefined names for processor registers (like
R0,R1) and I/O registers (like DATAIN)
• Arbitrary names for locations in
memory(A,B,LOC,DATA)
• Use […] to denote contents of a location
• Use  to denote transfer to a destination
• Example: R2  [LOC]
(transfer from LOC in memory to register R2)
Register Transfer Notation
• RTN can be extended to also show
arithmetic operations involving locations
• Example: R4  [R2]  [R3]
(add the contents of registers R2 and R3,
place the sum in register R4)
• Right-hand expression always denotes a value,
left-hand side always names a location
Assembly-Language Notation
• RTN shows data transfers and arithmetic
• Another notation is needed to represent
machine instructions & programs using them
• Assembly language is used for this purpose
• For the two preceding examples using RTN,
the assembly-language instructions are:
Load R2, LOC
Add R4, R2, R3
Assembly-Language Notation
• An instruction specifies the desired operation
and the operands that are involved
• Examples in this chapter will use English words
for the operations (e.g., Load, Store, and Add)
• This helps emphasize fundamental concepts
• Commercial processors use mnemonics,
usually abbreviations (e.g., LD, ST, and ADD)
• Mnemonics differ from processor to processor
RISC and CISC Instruction Sets
• Nature of instructions distinguishes computer
• Two fundamentally different approaches
• Reduced Instruction Set Computers (RISC)
have one-word instructions and
require arithmetic operands to be in registers
• Complex Instruction Set Computers (CISC)
have multi-word instructions and
allow operands directly from memory
RISC Instruction Sets
• Focus on RISC first because it is simpler
• RISC instructions each occupy a single word
• A load/store architecture is used, meaning:
–only Load and Store instructions are used
to access memory operands
–operands for arithmetic/logic instructions
must be in registers, or one of them
may be given explicitly in instruction word
RISC Instruction Sets
• Instructions/data are stored in the memory
• Processor register contents are initially invalid
• Because RISC requires register operands,
data transfers are required before arithmetic
• The Load instruction is used for this purpose:
Load procr_register, mem_location
• Addressing mode specifies memory location;
different modes are discussed later
RISC Instruction Sets
• Consider high-level language statement:
C  A  B
• A, B, and C correspond to memory locations
• RTN specification with these symbolic names:
C  [A]  [B]
• Steps: fetch contents of locations A and B,
compute sum, and transfer result to location C
RISC Instruction Sets
• Sequence of simple RISC instructions for task:
Load R2, A
Load R3, B
Add R4, R2, R3
Store R4, C
• Load instruction transfers data to register
• Store instruction transfers data to the memory
• Destination differs with same operand order
A Program in the Memory
• Consider the preceding 4-instruction program
• How is it stored in the memory?
(32-bit word length, byte-addressable)
• Place first RISC instruction word at address i
• Remaining instructions are at i  4, i  8, i  12
• For now, assume that Load/Store instructions
specify desired operand address directly;
this issue is discussed in detail later
Instruction Execution/Sequencing
• How is the program executed?
• Processor has program counter (PC) register
• Address i for first instruction placed in PC
• Control circuits fetch and execute instructions,
one after another  straight-line sequencing
• During execution of each instruction,
PC register is incremented by 4
• PC contents are i  16 after Store is executed
Details of Instruction Execution
• Two-phase procedure: fetch and execute
• Fetch involves Read operation using PC value
• Data placed in processor instruction register (IR)
• To complete execution, control circuits
examine encoded machine instruction in IR
• Specified operation is performed in steps,
e.g., transfer operands, perform arithmetic
• Also, PC is incremented, ready for next fetch
Branching
• Concept of branching illustrated with a
program that adds a list of numbers
• Same operations performed repeatedly,
so the program contains a loop
• Loop body is straight-line instruction sequence
• It must determine address of next number,
load value from the memory, and add to sum
• Branch instruction causes repetition of body
Branching
• Assume that size of list, n, stored at location N
• Use register R2 as a counter, initialized from N
• Body of loop includes the instruction
Subtract R2, R2, #1
to decrement counter in each loop pass
• Branch_if_[R2]0 goes to branch target LOOP
as long as contents of R2 are greater than zero
• Therefore, this is a conditional branch
Branching
• Branches that test a condition are used in
loops and various other programming tasks
• One way to implement conditional branches
is to compare contents of two registers, e.g.,
Branch_if_[R4][R5] LOOP
• In generic assembly language with mnemonics
the same instruction might actually appear as
BGT R4, R5, LOOP
Generating Memory Addresses
• Loop must obtain next number in each pass
• Load instruction cannot contain full address since
address size (32 bits)  instruction size
• Also, Load instruction itself would have to be
modified in each pass to change address
• Instead, use register Ri for address location
• Initialize to NUM1, increment by 4 inside loop
• Addressing modes - flexible ways to specify the
address of an operand.
LU5- Addressing Modes
Addressing Modes
• Addressing modes provide compiler with
different ways to specify operand locations
• Consider modes used in RISC-style processors
Addressing Modes
• Immediate
ADD R2, R3, #5 – Immediate data; data as part of
the instruction
• Register
ADD R2, R3, R5 – data in the registers
• Absolute
Load R3, DATA - address in the instruction
• Register Indirect
Load R2, (R3) - address in the register
Addressing Modes
• Index
Load R2, X(R3) – address specified as two parts
• Base With Index
Load R2, (R3,R4) – address specified in two
registers
Sum of N numbers
Addressing Modes
• RISC-style instructions have a fixed size, hence
absolute mode information limited to 16 bits
• Usually sign-extended to full 32-bit address
• Absolute mode is therefore limited
to a subset of the full 32-bit address space
• Assume programs are limited to this subset
Try Yourself
• Write a assembly language program to sum N
numbers using indexed addressing mode.
sum = sum + a[i]
• Write a assembly language program to add a
scalar(constant) to an array of N numbers.
a[i] = a[i] + c
• Write a assembly language program to add
two arrays of size N.
c[i] = a[i] + b[i]

More Related Content

Similar to LU3- 4 Instructions and Sequencing.pptx

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
 
11_ Instruction Sets addressing modes .ppt
11_ Instruction Sets addressing modes .ppt11_ Instruction Sets addressing modes .ppt
11_ Instruction Sets addressing modes .pptSwarajKumarPradhan
 
Computer organization basics
Computer organization  basicsComputer organization  basics
Computer organization basicsDeepak John
 
310471266 chapter-7-notes-computer-organization
310471266 chapter-7-notes-computer-organization310471266 chapter-7-notes-computer-organization
310471266 chapter-7-notes-computer-organizationsrinoni
 
COMPUTER ORGANIZATION NOTES Unit 7
COMPUTER ORGANIZATION NOTES Unit 7COMPUTER ORGANIZATION NOTES Unit 7
COMPUTER ORGANIZATION NOTES Unit 7Dr.MAYA NAYAK
 
unit1COA Computer Organisation and Architecture
unit1COA Computer Organisation and Architectureunit1COA Computer Organisation and Architecture
unit1COA Computer Organisation and ArchitectureSwapnitaSrivastava1
 
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
 
computer-system-architecture-morris-mano-220720124304-fefd641d.pdf
computer-system-architecture-morris-mano-220720124304-fefd641d.pdfcomputer-system-architecture-morris-mano-220720124304-fefd641d.pdf
computer-system-architecture-morris-mano-220720124304-fefd641d.pdfKunalSahu180994
 
11_ Instruction Sets addressing modes -1.ppt
11_ Instruction Sets addressing modes -1.ppt11_ Instruction Sets addressing modes -1.ppt
11_ Instruction Sets addressing modes -1.pptSuchikage
 
Computer organiztion4
Computer organiztion4Computer organiztion4
Computer organiztion4Umang Gupta
 
instruction sets (1).pptx
instruction sets (1).pptxinstruction sets (1).pptx
instruction sets (1).pptxAmanMomin9
 
(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
 
Computer System Architecture Lecture Note 7 addressing
Computer System Architecture Lecture Note 7 addressingComputer System Architecture Lecture Note 7 addressing
Computer System Architecture Lecture Note 7 addressingBudditha Hettige
 

Similar to LU3- 4 Instructions and Sequencing.pptx (20)

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...
 
11_ Instruction Sets addressing modes .ppt
11_ Instruction Sets addressing modes .ppt11_ Instruction Sets addressing modes .ppt
11_ Instruction Sets addressing modes .ppt
 
Computer organization basics
Computer organization  basicsComputer organization  basics
Computer organization basics
 
310471266 chapter-7-notes-computer-organization
310471266 chapter-7-notes-computer-organization310471266 chapter-7-notes-computer-organization
310471266 chapter-7-notes-computer-organization
 
COMPUTER ORGANIZATION NOTES Unit 7
COMPUTER ORGANIZATION NOTES Unit 7COMPUTER ORGANIZATION NOTES Unit 7
COMPUTER ORGANIZATION NOTES Unit 7
 
unit1COA Computer Organisation and Architecture
unit1COA Computer Organisation and Architectureunit1COA Computer Organisation and Architecture
unit1COA Computer Organisation and Architecture
 
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...
 
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...
 
mano.ppt
mano.pptmano.ppt
mano.ppt
 
computer-system-architecture-morris-mano-220720124304-fefd641d.pdf
computer-system-architecture-morris-mano-220720124304-fefd641d.pdfcomputer-system-architecture-morris-mano-220720124304-fefd641d.pdf
computer-system-architecture-morris-mano-220720124304-fefd641d.pdf
 
11_ Instruction Sets addressing modes -1.ppt
11_ Instruction Sets addressing modes -1.ppt11_ Instruction Sets addressing modes -1.ppt
11_ Instruction Sets addressing modes -1.ppt
 
Computer organiztion4
Computer organiztion4Computer organiztion4
Computer organiztion4
 
instruction sets (1).pptx
instruction sets (1).pptxinstruction sets (1).pptx
instruction sets (1).pptx
 
MES_MODULE 2.pptx
MES_MODULE 2.pptxMES_MODULE 2.pptx
MES_MODULE 2.pptx
 
8051d
8051d8051d
8051d
 
(246431835) instruction set principles (2) (1)
(246431835) instruction set principles (2) (1)(246431835) instruction set principles (2) (1)
(246431835) instruction set principles (2) (1)
 
Computer System Architecture Lecture Note 7 addressing
Computer System Architecture Lecture Note 7 addressingComputer System Architecture Lecture Note 7 addressing
Computer System Architecture Lecture Note 7 addressing
 
THE PROCESSOR
THE PROCESSORTHE PROCESSOR
THE PROCESSOR
 
Basic non pipelined cpu architecture
Basic non pipelined cpu architectureBasic non pipelined cpu architecture
Basic non pipelined cpu architecture
 
COA LESSON.ppt
COA LESSON.pptCOA LESSON.ppt
COA LESSON.ppt
 

Recently uploaded

Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...ranjana rawat
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 

Recently uploaded (20)

Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 

LU3- 4 Instructions and Sequencing.pptx

  • 2. Instructions and Sequencing • Instructions for a computer must support: –data transfers to and from the memory –arithmetic and logic operations on data –program sequencing and control –input/output transfers • First consider data transfer & arithmetic/logic • Control and input/output examined later
  • 3. Register Transfer Notation • Register transfer notation is used to describe hardware-level data transfers and operations • Predefined names for processor registers (like R0,R1) and I/O registers (like DATAIN) • Arbitrary names for locations in memory(A,B,LOC,DATA) • Use […] to denote contents of a location • Use  to denote transfer to a destination • Example: R2  [LOC] (transfer from LOC in memory to register R2)
  • 4. Register Transfer Notation • RTN can be extended to also show arithmetic operations involving locations • Example: R4  [R2]  [R3] (add the contents of registers R2 and R3, place the sum in register R4) • Right-hand expression always denotes a value, left-hand side always names a location
  • 5. Assembly-Language Notation • RTN shows data transfers and arithmetic • Another notation is needed to represent machine instructions & programs using them • Assembly language is used for this purpose • For the two preceding examples using RTN, the assembly-language instructions are: Load R2, LOC Add R4, R2, R3
  • 6. Assembly-Language Notation • An instruction specifies the desired operation and the operands that are involved • Examples in this chapter will use English words for the operations (e.g., Load, Store, and Add) • This helps emphasize fundamental concepts • Commercial processors use mnemonics, usually abbreviations (e.g., LD, ST, and ADD) • Mnemonics differ from processor to processor
  • 7. RISC and CISC Instruction Sets • Nature of instructions distinguishes computer • Two fundamentally different approaches • Reduced Instruction Set Computers (RISC) have one-word instructions and require arithmetic operands to be in registers • Complex Instruction Set Computers (CISC) have multi-word instructions and allow operands directly from memory
  • 8. RISC Instruction Sets • Focus on RISC first because it is simpler • RISC instructions each occupy a single word • A load/store architecture is used, meaning: –only Load and Store instructions are used to access memory operands –operands for arithmetic/logic instructions must be in registers, or one of them may be given explicitly in instruction word
  • 9. RISC Instruction Sets • Instructions/data are stored in the memory • Processor register contents are initially invalid • Because RISC requires register operands, data transfers are required before arithmetic • The Load instruction is used for this purpose: Load procr_register, mem_location • Addressing mode specifies memory location; different modes are discussed later
  • 10. RISC Instruction Sets • Consider high-level language statement: C  A  B • A, B, and C correspond to memory locations • RTN specification with these symbolic names: C  [A]  [B] • Steps: fetch contents of locations A and B, compute sum, and transfer result to location C
  • 11. RISC Instruction Sets • Sequence of simple RISC instructions for task: Load R2, A Load R3, B Add R4, R2, R3 Store R4, C • Load instruction transfers data to register • Store instruction transfers data to the memory • Destination differs with same operand order
  • 12. A Program in the Memory • Consider the preceding 4-instruction program • How is it stored in the memory? (32-bit word length, byte-addressable) • Place first RISC instruction word at address i • Remaining instructions are at i  4, i  8, i  12 • For now, assume that Load/Store instructions specify desired operand address directly; this issue is discussed in detail later
  • 13.
  • 14. Instruction Execution/Sequencing • How is the program executed? • Processor has program counter (PC) register • Address i for first instruction placed in PC • Control circuits fetch and execute instructions, one after another  straight-line sequencing • During execution of each instruction, PC register is incremented by 4 • PC contents are i  16 after Store is executed
  • 15. Details of Instruction Execution • Two-phase procedure: fetch and execute • Fetch involves Read operation using PC value • Data placed in processor instruction register (IR) • To complete execution, control circuits examine encoded machine instruction in IR • Specified operation is performed in steps, e.g., transfer operands, perform arithmetic • Also, PC is incremented, ready for next fetch
  • 16. Branching • Concept of branching illustrated with a program that adds a list of numbers • Same operations performed repeatedly, so the program contains a loop • Loop body is straight-line instruction sequence • It must determine address of next number, load value from the memory, and add to sum • Branch instruction causes repetition of body
  • 17.
  • 18. Branching • Assume that size of list, n, stored at location N • Use register R2 as a counter, initialized from N • Body of loop includes the instruction Subtract R2, R2, #1 to decrement counter in each loop pass • Branch_if_[R2]0 goes to branch target LOOP as long as contents of R2 are greater than zero • Therefore, this is a conditional branch
  • 19. Branching • Branches that test a condition are used in loops and various other programming tasks • One way to implement conditional branches is to compare contents of two registers, e.g., Branch_if_[R4][R5] LOOP • In generic assembly language with mnemonics the same instruction might actually appear as BGT R4, R5, LOOP
  • 20. Generating Memory Addresses • Loop must obtain next number in each pass • Load instruction cannot contain full address since address size (32 bits)  instruction size • Also, Load instruction itself would have to be modified in each pass to change address • Instead, use register Ri for address location • Initialize to NUM1, increment by 4 inside loop • Addressing modes - flexible ways to specify the address of an operand.
  • 22. Addressing Modes • Addressing modes provide compiler with different ways to specify operand locations • Consider modes used in RISC-style processors
  • 23.
  • 24. Addressing Modes • Immediate ADD R2, R3, #5 – Immediate data; data as part of the instruction • Register ADD R2, R3, R5 – data in the registers • Absolute Load R3, DATA - address in the instruction • Register Indirect Load R2, (R3) - address in the register
  • 25. Addressing Modes • Index Load R2, X(R3) – address specified as two parts • Base With Index Load R2, (R3,R4) – address specified in two registers
  • 26. Sum of N numbers
  • 27. Addressing Modes • RISC-style instructions have a fixed size, hence absolute mode information limited to 16 bits • Usually sign-extended to full 32-bit address • Absolute mode is therefore limited to a subset of the full 32-bit address space • Assume programs are limited to this subset
  • 28. Try Yourself • Write a assembly language program to sum N numbers using indexed addressing mode. sum = sum + a[i] • Write a assembly language program to add a scalar(constant) to an array of N numbers. a[i] = a[i] + c • Write a assembly language program to add two arrays of size N. c[i] = a[i] + b[i]