SlideShare a Scribd company logo
1 of 26
CSC 203 1.5
Computer System Architecture
Budditha Hettige
Department of Statistics and Computer Science
University of Sri Jayewardenepura
Addressing
2Budditha Hettige
Addressing
• Subject of specifying where the operands
(addresses) are
– ADD instruction requires 2 or 3 operands, and
instruction must tell where to find operands and
where to put result
• Addressing Modes
– Methods of interpreting the bits of an address field
to find operand
• Immediate Addressing
• Direct Addressing
• Register Addressing
• Register Indirect Addressing
• Indexed Addressing
3Budditha Hettige
Immediate Addressing
• Simplest way to specify where the operand is
• Address part of instruction contains operand itself
(immediate operand)
• Operand is automatically fetched from memory at
the same time the instruction it self is fetched
– Immediately available for use
• No additional memory references are required
• Disadvantages
– only a constant can be supplied
– value of the constant is limited by size of address field
• Good for specifying small integers
4Budditha Hettige
Example
Immediate Addressing
MOV R1, #8 ; Reg[R1]  8
ADD R2R2, #3 ; Reg[R2]  Reg[R2] + 3
5Budditha Hettige
Direct Addressing
• Operand is in memory, and is specified by giving
its full address (memory address is hardwired into
instruction)
• Instruction will always access exactly same
memory location, which cannot change
• Can only be used for global variables who
address is known at compile time
• Example Instruction:
– ADD R1, R1(1001) ; Reg[R1]  Reg[R1] +Mem[1001]
6Budditha Hettige
Direct Addressing Example
7Budditha Hettige
Register Addressing
• Same as direct addressing with the exception that it
specifies a register instead of memory location
• Most common addressing mode on most computers
since register accesses are very fast
• Compilers try to put most commonly accessed
variables in registers
• Cannot be used only in LOAD and STORE instructions
(one operand in is always a memory address)
• Example instruction:
– ADD R3, R4 ; Reg[R3]  Reg[R3] + Reg[R4]
8Budditha Hettige
Register Indirect Addressing
• Operand being specified comes from memory or goes
to memory
• Its address is not hardwired into instruction, but is
contained in a register (pointer)
• Can reference memory without having full memory
address in the instruction
• Different memory words can be used on different
executions of the instruction
• Example instruction:
– ADD R1,R1(R2) ; Reg[R1]  Reg[R1] +
Mem[Reg[R2]]
9Budditha Hettige
Example
• Following generic assembly program calculates the
sum of elements (1024) of an array A of integers of 4
bytes each, and stores result in register R1
– MOV R1, #0 ; sum in R1 (0 initially)
– MOV R2, #A ; Reg[R2] = address of array A
– MOV R3, #A+4096 ; Reg[R3] = address of first word
beyond A
– LOOP: ADD R1, (R2) ; register indirect via R2 to get
operand
– ADD R2, #4 ; increment R2 by one word
– CMP R2, R3 ; is R2 < R3?
– BLT LOOP ; loop if R2 < R3
10Budditha Hettige
Indexed Addressing
• Memory is addressed by giving a register plus
a constant offset
• Used to access local variables
• Example instruction:
– ADD R3, 100(R2)
; Reg[R3]  Reg[R3] + Mem[100+Reg[R2]]
11Budditha Hettige
Based-Indexed Addressing
• Memory address is computed by adding
up two registers plus an optional offset
• Example instruction:
ADD R3, (R1+R2)
;Reg[R3]  Reg[R3] + Mem[Reg[R1] +
Reg[R2]]
12Budditha Hettige
Instruction Types
• ISA level instructions are divided into few
categories
– Data Movement Instructions
• Copy data from one location to another
– Examples (Pentium II integer instructions):
• MOV DST, SRC – copies SRC (source) to DST
(destination)
• PUSH SRC – push SRC into the stack
• XCHG DS1, DS2 – exchanges DS1 and DS2
• CMOV DST, SRC – conditional move
13Budditha Hettige
Instruction Types contd..
– Dyadic Operations
• Combine two operands to produce a result (arithmetic
instructions, Boolean instructions)
– Examples (Pentium II integer instructions):
• ADD DST, SRC – adds SRC to DST, puts result in
DST
• SUB DST, SRC – subtracts DST from SRC
• AND DST, SRC – Boolean AND SRC into DST
• OR DST, SRC - Boolean OR SRC into DST
• XOR DST,DST SRC – Boolean Exclusive OR to DST
14Budditha Hettige
Instruction Types contd..
• Monadic Operations
– Have one operand and produce one result
– Shorter than dyadic instructions
• Examples (Pentium II integer
instructions):
– INC DST – adds 1 to DST
– DEC DST – subtracts 1 from DST
– NOT DST – replace DST with 1’s
complement
15Budditha Hettige
Instruction Types contd..
• Comparison and Conditional Branch
Instructions
• Examples (Pentium II integer
instructions):
– TST SRC1, SRC2 – Boolean AND operands, set flags
(EFLAGS)
– CMP SRC1, SRC2 – sets flags based on SRC1-SRC2
16Budditha Hettige
Instruction Types contd..
• Procedure (Subroutine) call Instructions
– When the procedure has finished its task,
transfer is returned to statement after the call
• Examples (Pentium II integer instructions):
– CALL ADDR -Calls procedure at ADDR
– RET - Returns from procedure
17Budditha Hettige
Instruction Types contd..
• Loop Control Instructions
– LOOPxx – loops until condition is met
• Input / Output Instructions
There are several input/output schemes
currently used in personal computers
– Programmed I/O with busy waiting
– Interrupt-driven I/O
– DMA (Direct Memory Access) I/O
18Budditha Hettige
Programmed I/O with busy waiting
• Simplest I/O method
• Commonly used in low-end processors
• Processors have a single input instruction and a
single output instruction, and each of them selects
one of the I/O devices
• A single character is transferred between a fixed
register in the processor and selected I/O device
• Processor must execute an explicit sequence of
instructions for each and every character read or
written
19Budditha Hettige
DMA I/O
• DMA controller is a chip that has a direct
access to the bus
• It consists of at least four registers, each
can be loaded by software.
– Register 1 contains memory address to be
read/written
– Register 2 contains the count of how many
bytes / words to be transferred
– Register 3 specifies the device number or I/O
space address to use
– Register 4 indicates whether data are to be read
from or written to I/O device
20Budditha Hettige
Structure of a DMA
21Budditha Hettige
Registers in the DMA
• Status register: readable by the CPU to determine the status of
the DMA device (idle, busy, etc)
• Command register: writable by the CPU to issue a command to
the DMA
• Data register: readable and writable. It is the buffering place for
data that is being transferred between the memory and the IO
device.
• Address register: contains the starting location of memory
where from or where to the data will be transferred. The Address
register must be programmed by the CPU before issuing a "start"
command to the DMA.
• Count register: contains the number of bytes that need to be
transferred. The information in the address and the count register
combined will specify exactly what information need to be
transferred.
22Budditha Hettige
Example
• Writing a block of 32 bytes from memory
address 100 to a terminal device (4)
23Budditha Hettige
Example contd..
• CPU writes numbers 32, 100, and 4 into first three
DMA registers, and writes the code for WRITE (1, for
example) in the fourth register
• DMA controller makes a bus request to read byte 100
from memory
• DMA controller makes an I/O request to device 4 to
write the byte to it
• DMA controller increments its address register by 1
and decrements its count register by 1
• If the count register is > 0, another byte is read from
memory and then written to device
• DMA controller stops transferring data when count = 0
24Budditha Hettige
Sample Questions
Q1.
1. Explain the processor architecture of 8086.
2. What are differences in Intel Pentium
Processor and dual core processor.
3. What are the advantages and disadvantage of
the multi-core processors
25Budditha Hettige
Sample Questions
Q2.
1. What is addressing.
2. Comparing advantages, disadvantages
and features briefly explain each
addressing modes.
3. What is DMA and why it useful for
Programming?. Explain your answer
26Budditha Hettige

More Related Content

What's hot

Advanced processor Principles
Advanced processor PrinciplesAdvanced processor Principles
Advanced processor PrinciplesVinit Raut
 
Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1) Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1) Subhasis Dash
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
Computer organiztion5
Computer organiztion5Computer organiztion5
Computer organiztion5Umang Gupta
 
Computer organization
Computer organizationComputer organization
Computer organizationishapadhy
 
Computer Organization : CPU, Memory and I/O organization
Computer Organization : CPU, Memory and I/O organizationComputer Organization : CPU, Memory and I/O organization
Computer Organization : CPU, Memory and I/O organizationAmrutaMehata
 
Computer organization-and-architecture-questions-and-answers
Computer organization-and-architecture-questions-and-answersComputer organization-and-architecture-questions-and-answers
Computer organization-and-architecture-questions-and-answersappasami
 
Computer Organisation and Architecture
Computer Organisation and ArchitectureComputer Organisation and Architecture
Computer Organisation and ArchitectureSubhasis Dash
 
Processor Organization
Processor OrganizationProcessor Organization
Processor OrganizationDominik Salvet
 
Computer organization basics and number systems
Computer organization basics and number systemsComputer organization basics and number systems
Computer organization basics and number systemsPrasenjit Dey
 
Computer Architecture – An Introduction
Computer Architecture – An IntroductionComputer Architecture – An Introduction
Computer Architecture – An IntroductionDilum Bandara
 
Computer organisation -morris mano
Computer organisation  -morris manoComputer organisation  -morris mano
Computer organisation -morris manovishnu murthy
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
12 processor structure and function
12 processor structure and function12 processor structure and function
12 processor structure and functionSher Shah Merkhel
 
Coa module1
Coa module1Coa module1
Coa module1cs19club
 
Unit 1 computer architecture (1)
Unit 1   computer architecture (1)Unit 1   computer architecture (1)
Unit 1 computer architecture (1)DevaKumari Vijay
 

What's hot (20)

Advanced processor Principles
Advanced processor PrinciplesAdvanced processor Principles
Advanced processor Principles
 
Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1) Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1)
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Computer organiztion5
Computer organiztion5Computer organiztion5
Computer organiztion5
 
Computer organization
Computer organizationComputer organization
Computer organization
 
Computer Organization : CPU, Memory and I/O organization
Computer Organization : CPU, Memory and I/O organizationComputer Organization : CPU, Memory and I/O organization
Computer Organization : CPU, Memory and I/O organization
 
Computer organization-and-architecture-questions-and-answers
Computer organization-and-architecture-questions-and-answersComputer organization-and-architecture-questions-and-answers
Computer organization-and-architecture-questions-and-answers
 
Computer Organisation and Architecture
Computer Organisation and ArchitectureComputer Organisation and Architecture
Computer Organisation and Architecture
 
Lecture#06 inner workings of the cpu
Lecture#06   inner workings of the cpuLecture#06   inner workings of the cpu
Lecture#06 inner workings of the cpu
 
Processor Organization
Processor OrganizationProcessor Organization
Processor Organization
 
Computer organization basics and number systems
Computer organization basics and number systemsComputer organization basics and number systems
Computer organization basics and number systems
 
Computer Architecture – An Introduction
Computer Architecture – An IntroductionComputer Architecture – An Introduction
Computer Architecture – An Introduction
 
DMA
DMADMA
DMA
 
Computer organisation -morris mano
Computer organisation  -morris manoComputer organisation  -morris mano
Computer organisation -morris mano
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Computer architecture
Computer architectureComputer architecture
Computer architecture
 
12 processor structure and function
12 processor structure and function12 processor structure and function
12 processor structure and function
 
Control unit
Control  unitControl  unit
Control unit
 
Coa module1
Coa module1Coa module1
Coa module1
 
Unit 1 computer architecture (1)
Unit 1   computer architecture (1)Unit 1   computer architecture (1)
Unit 1 computer architecture (1)
 

Similar to Computer System Architecture Lecture Note 7 addressing

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.pptxManimegalaM3
 
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
 
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
 
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
 
instruction sets (1).pptx
instruction sets (1).pptxinstruction sets (1).pptx
instruction sets (1).pptxAmanMomin9
 
LU3- 4 Instructions and Sequencing.pptx
LU3- 4 Instructions and Sequencing.pptxLU3- 4 Instructions and Sequencing.pptx
LU3- 4 Instructions and Sequencing.pptxAKumaraGuru
 
Computer Organization & Architecture (COA) Unit 2
Computer Organization & Architecture (COA) Unit 2Computer Organization & Architecture (COA) Unit 2
Computer Organization & Architecture (COA) Unit 2parthivrathodlits
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristicsSher Shah Merkhel
 
UNIT 3 - General Purpose Processors
UNIT 3 - General Purpose ProcessorsUNIT 3 - General Purpose Processors
UNIT 3 - General Purpose ProcessorsButtaRajasekhar2
 

Similar to Computer System Architecture Lecture Note 7 addressing (20)

Instruction codes
Instruction codesInstruction codes
Instruction codes
 
Lecture 10
Lecture 10Lecture 10
Lecture 10
 
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
 
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...
 
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...
 
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...
 
instruction sets (1).pptx
instruction sets (1).pptxinstruction sets (1).pptx
instruction sets (1).pptx
 
CO_Chapter2.ppt
CO_Chapter2.pptCO_Chapter2.ppt
CO_Chapter2.ppt
 
Frist slider share
Frist slider shareFrist slider share
Frist slider share
 
instruction format.pptx
instruction format.pptxinstruction format.pptx
instruction format.pptx
 
LU3- 4 Instructions and Sequencing.pptx
LU3- 4 Instructions and Sequencing.pptxLU3- 4 Instructions and Sequencing.pptx
LU3- 4 Instructions and Sequencing.pptx
 
CPU.ppd
CPU.ppdCPU.ppd
CPU.ppd
 
module-3.pptx
module-3.pptxmodule-3.pptx
module-3.pptx
 
Computer Organization & Architecture (COA) Unit 2
Computer Organization & Architecture (COA) Unit 2Computer Organization & Architecture (COA) Unit 2
Computer Organization & Architecture (COA) Unit 2
 
Control unit
Control unitControl unit
Control unit
 
Central processor organization
Central processor organizationCentral processor organization
Central processor organization
 
Chapter 7
Chapter 7Chapter 7
Chapter 7
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristics
 
Unit 2.ppt
Unit 2.pptUnit 2.ppt
Unit 2.ppt
 
UNIT 3 - General Purpose Processors
UNIT 3 - General Purpose ProcessorsUNIT 3 - General Purpose Processors
UNIT 3 - General Purpose Processors
 

More from Budditha Hettige

More from Budditha Hettige (18)

Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysis
 
Sorting
SortingSorting
Sorting
 
Link List
Link ListLink List
Link List
 
Queue
QueueQueue
Queue
 
02 Stack
02 Stack02 Stack
02 Stack
 
Data Structures 01
Data Structures 01Data Structures 01
Data Structures 01
 
Drawing Fonts
Drawing FontsDrawing Fonts
Drawing Fonts
 
Texture Mapping
Texture Mapping Texture Mapping
Texture Mapping
 
Lighting
LightingLighting
Lighting
 
Viewing
ViewingViewing
Viewing
 
OpenGL 3D Drawing
OpenGL 3D DrawingOpenGL 3D Drawing
OpenGL 3D Drawing
 
2D Drawing
2D Drawing2D Drawing
2D Drawing
 
Graphics Programming OpenGL & GLUT in Code::Blocks
Graphics Programming OpenGL & GLUT in Code::BlocksGraphics Programming OpenGL & GLUT in Code::Blocks
Graphics Programming OpenGL & GLUT in Code::Blocks
 
Introduction to Computer Graphics
Introduction to Computer GraphicsIntroduction to Computer Graphics
Introduction to Computer Graphics
 
Computer System Architecture Lecture Note 8.1 primary Memory
Computer System Architecture Lecture Note 8.1 primary MemoryComputer System Architecture Lecture Note 8.1 primary Memory
Computer System Architecture Lecture Note 8.1 primary Memory
 
Computer System Architecture Lecture Note 8.2 Cache Memory
Computer System Architecture Lecture Note 8.2 Cache MemoryComputer System Architecture Lecture Note 8.2 Cache Memory
Computer System Architecture Lecture Note 8.2 Cache Memory
 
Computer System Architecture Lecture Note 3: computer architecture
Computer System Architecture Lecture Note 3: computer architectureComputer System Architecture Lecture Note 3: computer architecture
Computer System Architecture Lecture Note 3: computer architecture
 
Computer System Architecture Lecture Note 2: History
Computer System Architecture Lecture Note 2: HistoryComputer System Architecture Lecture Note 2: History
Computer System Architecture Lecture Note 2: History
 

Recently uploaded

JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 

Recently uploaded (20)

JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 

Computer System Architecture Lecture Note 7 addressing

  • 1. CSC 203 1.5 Computer System Architecture Budditha Hettige Department of Statistics and Computer Science University of Sri Jayewardenepura
  • 3. Addressing • Subject of specifying where the operands (addresses) are – ADD instruction requires 2 or 3 operands, and instruction must tell where to find operands and where to put result • Addressing Modes – Methods of interpreting the bits of an address field to find operand • Immediate Addressing • Direct Addressing • Register Addressing • Register Indirect Addressing • Indexed Addressing 3Budditha Hettige
  • 4. Immediate Addressing • Simplest way to specify where the operand is • Address part of instruction contains operand itself (immediate operand) • Operand is automatically fetched from memory at the same time the instruction it self is fetched – Immediately available for use • No additional memory references are required • Disadvantages – only a constant can be supplied – value of the constant is limited by size of address field • Good for specifying small integers 4Budditha Hettige
  • 5. Example Immediate Addressing MOV R1, #8 ; Reg[R1]  8 ADD R2R2, #3 ; Reg[R2]  Reg[R2] + 3 5Budditha Hettige
  • 6. Direct Addressing • Operand is in memory, and is specified by giving its full address (memory address is hardwired into instruction) • Instruction will always access exactly same memory location, which cannot change • Can only be used for global variables who address is known at compile time • Example Instruction: – ADD R1, R1(1001) ; Reg[R1]  Reg[R1] +Mem[1001] 6Budditha Hettige
  • 8. Register Addressing • Same as direct addressing with the exception that it specifies a register instead of memory location • Most common addressing mode on most computers since register accesses are very fast • Compilers try to put most commonly accessed variables in registers • Cannot be used only in LOAD and STORE instructions (one operand in is always a memory address) • Example instruction: – ADD R3, R4 ; Reg[R3]  Reg[R3] + Reg[R4] 8Budditha Hettige
  • 9. Register Indirect Addressing • Operand being specified comes from memory or goes to memory • Its address is not hardwired into instruction, but is contained in a register (pointer) • Can reference memory without having full memory address in the instruction • Different memory words can be used on different executions of the instruction • Example instruction: – ADD R1,R1(R2) ; Reg[R1]  Reg[R1] + Mem[Reg[R2]] 9Budditha Hettige
  • 10. Example • Following generic assembly program calculates the sum of elements (1024) of an array A of integers of 4 bytes each, and stores result in register R1 – MOV R1, #0 ; sum in R1 (0 initially) – MOV R2, #A ; Reg[R2] = address of array A – MOV R3, #A+4096 ; Reg[R3] = address of first word beyond A – LOOP: ADD R1, (R2) ; register indirect via R2 to get operand – ADD R2, #4 ; increment R2 by one word – CMP R2, R3 ; is R2 < R3? – BLT LOOP ; loop if R2 < R3 10Budditha Hettige
  • 11. Indexed Addressing • Memory is addressed by giving a register plus a constant offset • Used to access local variables • Example instruction: – ADD R3, 100(R2) ; Reg[R3]  Reg[R3] + Mem[100+Reg[R2]] 11Budditha Hettige
  • 12. Based-Indexed Addressing • Memory address is computed by adding up two registers plus an optional offset • Example instruction: ADD R3, (R1+R2) ;Reg[R3]  Reg[R3] + Mem[Reg[R1] + Reg[R2]] 12Budditha Hettige
  • 13. Instruction Types • ISA level instructions are divided into few categories – Data Movement Instructions • Copy data from one location to another – Examples (Pentium II integer instructions): • MOV DST, SRC – copies SRC (source) to DST (destination) • PUSH SRC – push SRC into the stack • XCHG DS1, DS2 – exchanges DS1 and DS2 • CMOV DST, SRC – conditional move 13Budditha Hettige
  • 14. Instruction Types contd.. – Dyadic Operations • Combine two operands to produce a result (arithmetic instructions, Boolean instructions) – Examples (Pentium II integer instructions): • ADD DST, SRC – adds SRC to DST, puts result in DST • SUB DST, SRC – subtracts DST from SRC • AND DST, SRC – Boolean AND SRC into DST • OR DST, SRC - Boolean OR SRC into DST • XOR DST,DST SRC – Boolean Exclusive OR to DST 14Budditha Hettige
  • 15. Instruction Types contd.. • Monadic Operations – Have one operand and produce one result – Shorter than dyadic instructions • Examples (Pentium II integer instructions): – INC DST – adds 1 to DST – DEC DST – subtracts 1 from DST – NOT DST – replace DST with 1’s complement 15Budditha Hettige
  • 16. Instruction Types contd.. • Comparison and Conditional Branch Instructions • Examples (Pentium II integer instructions): – TST SRC1, SRC2 – Boolean AND operands, set flags (EFLAGS) – CMP SRC1, SRC2 – sets flags based on SRC1-SRC2 16Budditha Hettige
  • 17. Instruction Types contd.. • Procedure (Subroutine) call Instructions – When the procedure has finished its task, transfer is returned to statement after the call • Examples (Pentium II integer instructions): – CALL ADDR -Calls procedure at ADDR – RET - Returns from procedure 17Budditha Hettige
  • 18. Instruction Types contd.. • Loop Control Instructions – LOOPxx – loops until condition is met • Input / Output Instructions There are several input/output schemes currently used in personal computers – Programmed I/O with busy waiting – Interrupt-driven I/O – DMA (Direct Memory Access) I/O 18Budditha Hettige
  • 19. Programmed I/O with busy waiting • Simplest I/O method • Commonly used in low-end processors • Processors have a single input instruction and a single output instruction, and each of them selects one of the I/O devices • A single character is transferred between a fixed register in the processor and selected I/O device • Processor must execute an explicit sequence of instructions for each and every character read or written 19Budditha Hettige
  • 20. DMA I/O • DMA controller is a chip that has a direct access to the bus • It consists of at least four registers, each can be loaded by software. – Register 1 contains memory address to be read/written – Register 2 contains the count of how many bytes / words to be transferred – Register 3 specifies the device number or I/O space address to use – Register 4 indicates whether data are to be read from or written to I/O device 20Budditha Hettige
  • 21. Structure of a DMA 21Budditha Hettige
  • 22. Registers in the DMA • Status register: readable by the CPU to determine the status of the DMA device (idle, busy, etc) • Command register: writable by the CPU to issue a command to the DMA • Data register: readable and writable. It is the buffering place for data that is being transferred between the memory and the IO device. • Address register: contains the starting location of memory where from or where to the data will be transferred. The Address register must be programmed by the CPU before issuing a "start" command to the DMA. • Count register: contains the number of bytes that need to be transferred. The information in the address and the count register combined will specify exactly what information need to be transferred. 22Budditha Hettige
  • 23. Example • Writing a block of 32 bytes from memory address 100 to a terminal device (4) 23Budditha Hettige
  • 24. Example contd.. • CPU writes numbers 32, 100, and 4 into first three DMA registers, and writes the code for WRITE (1, for example) in the fourth register • DMA controller makes a bus request to read byte 100 from memory • DMA controller makes an I/O request to device 4 to write the byte to it • DMA controller increments its address register by 1 and decrements its count register by 1 • If the count register is > 0, another byte is read from memory and then written to device • DMA controller stops transferring data when count = 0 24Budditha Hettige
  • 25. Sample Questions Q1. 1. Explain the processor architecture of 8086. 2. What are differences in Intel Pentium Processor and dual core processor. 3. What are the advantages and disadvantage of the multi-core processors 25Budditha Hettige
  • 26. Sample Questions Q2. 1. What is addressing. 2. Comparing advantages, disadvantages and features briefly explain each addressing modes. 3. What is DMA and why it useful for Programming?. Explain your answer 26Budditha Hettige