SlideShare a Scribd company logo
1 of 8
CSULB -- CECS 341–Examples of Addressing Modes
© 2014 -- R.W. Allison 1
2
Addressing Mode – a specification for generating an address of an operand at
run time.
However, although all processors, simple or complex, obtain operands from registers,
there are no “standards” as to the names of various of “addressing modes.”
All operands for a particular processor are in registers, both CPU and memory.
Thus, in our introduction to understanding these varieties of ways to obtain
instruction operands, we are going to “generalize” the fundamental ways, not being
“processor specific.”
For the following fundamental addressing modes, we’ll show a “pseudo” assembly
language usage, and then how that assembly language statement might be compiled.
RISC processors don’t do any CPU operations (e.g. add, shift, mul, etc.) using
memory registers—all operands must be in CPU registers. Thus, addressing
modes for memory operands only apply to “Load” and “Store” type instructions.
CISC processors do almost all CPU operations (e.g. add, shift, mul, etc.) using
both CPU registers and memory registers. Thus, addressing modes are a critical
part of compiling almost all of the instructions.
CSULB -- CECS 341–Examples of Addressing Modes
© 2014 -- R.W. Allison
- - - - - -
- - - - - -
opc r0 reg/imm
0xA39D
- - - - - -
- - - - - -
3
For the following fundamental addressing modes, we’ll show (1) a “pseudo” assembly
language usage, and then (2) how that assembly language statement might be compiled.
Mode 1: Immediate—the operand itself (not the address of the operand) is part of the
instruction. This mode is useful for initializing registers with address or data constants in programs.
0x017A add r0, #0xA39D
For the sake of illustrating in the following examples, we assume all addresses are 16-bits,
and all memory and CPU registers are 16-bits wide.
Memory Addr Instruction Addr Contents
0x0178
0x0179
0x017A
0x017B
0x017C
0x017D
• Compile the example instruction into
the appropriate memory locations
Note that since the immediate operand is
16-bits long, it is placed at memory
location 0x017B, a “trailing word.”
Thus, this is a “two-word” instruction.
one
instruction
• What is the “address” of the operand that is added to R0?
• What is the “value” of the operand that is added to R0?
CSULB -- CECS 341–Examples of Addressing Modes
© 2014 -- R.W. Allison
- - - - - -
- - - - - -
opc r0 reg/dir
0xA39D
- - - - - -
- - - - - -
4
For the following fundamental addressing modes, we’ll show (1) a “pseudo” assembly
language usage, and then (2) how that assembly language statement might be compiled.
Mode 2: Direct—the instruction contains the address of the operand. Direct addressing may also
be referred to as "absolute" addressing. The address must be known at compile time.
0x017A add r0, @0xA39D
Memory Addr Instruction Addr Contents
0x0178
0x0179
0x017A
0x017B
0x017C
0x017D
• Compile the example instruction into
the appropriate memory locations
Note that since the direct address is 16-bits
long, it is placed at memory location 0x017B,
a “trailing word.”
Again, this is a “two-word” instruction.
one
instruction
• What is the “address” of the operand that is added to R0?
• What is the “value” of the operand that is added to R0?
:
0xA39C
0xA39D
0xA39E
:
:
- - - - - -
0xBC5F
- - - - - -
CSULB -- CECS 341–Examples of Addressing Modes
© 2014 -- R.W. Allison
- - - - - -
- - - - - -
opc r0 r7 reg/regi
- - - - - -
- - - - - -
- - - - - -
5
For the following fundamental addressing modes, we’ll show (1) a “pseudo” assembly
language usage, and then (2) how that assembly language statement might be compiled.
Mode 3: Register Indirect—specifies the register holding the address of the operand. This addressing
mode is used to access memory operands pointed to by “base pointers” that are stored in registers
0x017A add r0, [r7]
Memory Addr Instruction Addr Contents
0x0178
0x0179
0x017A
0x017B
0x017C
0x017D
• Compile the example instruction into
the appropriate memory locations
Note that since the R7 contains the 16-bit
address, there is no “trailing word.”
Thus, this would be a “one-word” instruction.
one
instruction
• What is the “address” of the operand that is added to R0?
This can’t be answered without knowing the contents of R7.
For this example, let’s assume R7 = 0x875F
:
0x875E
0x875F
0x8760
:
:
- - - - - -
0x10D5
- - - - - -
• What is the “value” of the operand that is added to R0?
CSULB -- CECS 341–Examples of Addressing Modes
© 2014 -- R.W. Allison
- - - - - -
- - - - - -
opc r0 r7 reg/base
0xA39D
- - - - - -
- - - - - -
6
For the following fundamental addressing modes, we’ll show (1) a “pseudo” assembly
language usage, and then (2) how that assembly language statement might be compiled.
Mode 4: Base (Indexed) — a variation of register indirect mode, where the effective address of the
operand is calculated by the addition of a "base" register and a offset (signed displacement) included as a
field in the instruction. We could name this mode as “Register Indirect with Offset.”
0x017A add r0, [r7+ 0xA39D]
Memory Addr Instruction
Addr Contents
0x0178
0x0179
0x017A
0x017B
0x017C
0x017D
• Compile the example instruction into
the appropriate memory locations
Although R7 contains the 16-bit “base address,”
the 16-bit offset must be in a “trailing word.”
Thus, this would be a “two-word” instruction.
one
instruction
• What is the “address” of the operand that is added to R0?
This can’t be answered without knowing the contents of R7.
For this example, let’s assume R7 = 0x1700
:
0xBA9C
0xBA9D
0xBA9E
:
:
- - - - - -
0x5A17
- - - - - -
• What is the “value” of the operand that is added to R0?
CSULB -- CECS 341–Examples of Addressing Modes
© 2014 -- R.W. Allison
- - - - - -
- - - - - -
opc PC_rel
0x439D
- - - - - -
- - - - - -
7
For the following fundamental addressing modes, we’ll show (1) a “pseudo” assembly
language usage, and then (2) how that assembly language statement might be compiled.
Mode 5: PC Relative — a variation of “base mode,” where the effective address of the operand
(typically an address to jump to) is calculated by the addition of the current PC and a offset (signed
displacement) included as a field in the instruction.
0x017A jmp [PC + 0x439D]
Memory Addr Instruction
Addr Contents
0x0178
0x0179
0x017A
0x017B
0x017C
0x017D
• Compile the example instruction into
the appropriate memory locations
Although PC contains the 16-bit “base address,”
the 16-bit offset must be in a “trailing word.”
Again, this would be a “two-word” instruction.
one
instruction
• What is the “address” to jump to?
Based on all the info given above,
you should be able to answer this
:
0x4518
0x4519
0x451A
:
:
- - - - - -
instr we’ll jmp to
- - - - - -
PC  0x017C + 0x439D
CSULB -- CECS 341–Examples of Addressing Modes
© 2014 -- R.W. Allison
- - - - - -
- - - - - -
opc PC_rel
0x439D
- - - - - -
- - - - - -
8
For the following fundamental addressing modes, we’ll show (1) a “pseudo” assembly
language usage, and then (2) how that assembly language statement might be compiled.
Mode 5: PC Relative — a variation of “base mode,” where the effective address of the operand
(typically an address to jump to) is calculated by the addition of the current PC and a offset (signed
displacement) included as a field in the instruction.
0x017A jcs [PC + 0x439D]
Memory Addr Instruction
Addr Contents
0x0178
0x0179
0x017A
0x017B
0x017C
0x017D
• Compile the example instruction into
the appropriate memory locations
The difference between this example and the
previous one is that the “jmp” here is conditional. If
the C-flag is set, the PC changes; if the C-flag is clear,
the PC does not change.
• What “address” does the PC get if C=1?
:
0x4518
0x4519
0x451A
:
:
- - - - - -
instr we’ll jmp to
- - - - - -PC  0x017C + 0x439D
• What “address” does the PC get if C=0?
PC  0x017C
CSULB -- CECS 341–Examples of Addressing Modes
© 2014 -- R.W. Allison

More Related Content

What's hot

8086 microprocessor instruction set by Er. Swapnil Kaware
8086 microprocessor instruction set by Er. Swapnil Kaware8086 microprocessor instruction set by Er. Swapnil Kaware
8086 microprocessor instruction set by Er. Swapnil Kaware
Prof. Swapnil V. Kaware
 
10 8086 instruction set
10 8086 instruction set10 8086 instruction set
10 8086 instruction set
Shivam Singhal
 

What's hot (20)

Lecture6
Lecture6Lecture6
Lecture6
 
8086 microprocessor instruction set by Er. Swapnil Kaware
8086 microprocessor instruction set by Er. Swapnil Kaware8086 microprocessor instruction set by Er. Swapnil Kaware
8086 microprocessor instruction set by Er. Swapnil Kaware
 
Lecture5(1)
Lecture5(1)Lecture5(1)
Lecture5(1)
 
Instruction set
Instruction setInstruction set
Instruction set
 
10 8086 instruction set
10 8086 instruction set10 8086 instruction set
10 8086 instruction set
 
instruction set of 8086
instruction set of 8086instruction set of 8086
instruction set of 8086
 
Intel µp instruction encoding and decoding
Intel µp instruction encoding and decodingIntel µp instruction encoding and decoding
Intel µp instruction encoding and decoding
 
Instruction set-of-8086
Instruction set-of-8086Instruction set-of-8086
Instruction set-of-8086
 
Assembly basics
Assembly basicsAssembly basics
Assembly basics
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Instruction formats-in-8086
Instruction formats-in-8086Instruction formats-in-8086
Instruction formats-in-8086
 
N_Asm Assembly arithmetic instructions (sol)
N_Asm Assembly arithmetic instructions (sol)N_Asm Assembly arithmetic instructions (sol)
N_Asm Assembly arithmetic instructions (sol)
 
Instruction Set of 8086 Microprocessor
Instruction Set of 8086 MicroprocessorInstruction Set of 8086 Microprocessor
Instruction Set of 8086 Microprocessor
 
Assembly 8086
Assembly 8086Assembly 8086
Assembly 8086
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086
 
Chapter 4 programming concepts III
Chapter 4  programming concepts IIIChapter 4  programming concepts III
Chapter 4 programming concepts III
 
Logical Instructions used in 8086 microprocessor
Logical Instructions used in 8086 microprocessorLogical Instructions used in 8086 microprocessor
Logical Instructions used in 8086 microprocessor
 
Introduction to Assembly Language
Introduction to Assembly LanguageIntroduction to Assembly Language
Introduction to Assembly Language
 
Instruction Set Of 8086 DIU CSE
Instruction Set Of 8086 DIU CSEInstruction Set Of 8086 DIU CSE
Instruction Set Of 8086 DIU CSE
 
8086 alp
8086 alp8086 alp
8086 alp
 

Similar to Orca share media1492336349924

Msp 430 addressing modes module 2
Msp 430 addressing modes module 2Msp 430 addressing modes module 2
Msp 430 addressing modes module 2
SARALA T
 
Micro controller(pratheesh)
Micro controller(pratheesh)Micro controller(pratheesh)
Micro controller(pratheesh)
Pratheesh Pala
 
Instruction set summary
Instruction set summary Instruction set summary
Instruction set summary
janicetiong
 

Similar to Orca share media1492336349924 (20)

Msp 430 addressing modes module 2
Msp 430 addressing modes module 2Msp 430 addressing modes module 2
Msp 430 addressing modes module 2
 
Unit II arm 7 Instruction Set
Unit II arm 7 Instruction SetUnit II arm 7 Instruction Set
Unit II arm 7 Instruction Set
 
Arm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.pptArm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.ppt
 
ARMbuilt-inshift_2a6f2cdd75038e8c46c6d481aac833ec.pdf
ARMbuilt-inshift_2a6f2cdd75038e8c46c6d481aac833ec.pdfARMbuilt-inshift_2a6f2cdd75038e8c46c6d481aac833ec.pdf
ARMbuilt-inshift_2a6f2cdd75038e8c46c6d481aac833ec.pdf
 
Module 2 PPT of ES.pptx
Module 2 PPT of ES.pptxModule 2 PPT of ES.pptx
Module 2 PPT of ES.pptx
 
MES_MODULE 2.pptx
MES_MODULE 2.pptxMES_MODULE 2.pptx
MES_MODULE 2.pptx
 
Unit vi
Unit viUnit vi
Unit vi
 
Micro controller(pratheesh)
Micro controller(pratheesh)Micro controller(pratheesh)
Micro controller(pratheesh)
 
Computer Architecture Assignment Help
Computer Architecture Assignment HelpComputer Architecture Assignment Help
Computer Architecture Assignment Help
 
Instruction set.pptx
Instruction set.pptxInstruction set.pptx
Instruction set.pptx
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
C from hello world to 010101
C from hello world to 010101C from hello world to 010101
C from hello world to 010101
 
Instruction set summary
Instruction set summary Instruction set summary
Instruction set summary
 
Compreport
CompreportCompreport
Compreport
 
Different addressing mode and risc, cisc microprocessor
Different addressing mode and risc, cisc microprocessorDifferent addressing mode and risc, cisc microprocessor
Different addressing mode and risc, cisc microprocessor
 
Introduction to debugging linux applications
Introduction to debugging linux applicationsIntroduction to debugging linux applications
Introduction to debugging linux applications
 
12 mt06ped008
12 mt06ped008 12 mt06ped008
12 mt06ped008
 
ISA.pptx
ISA.pptxISA.pptx
ISA.pptx
 
Lecture9
Lecture9Lecture9
Lecture9
 
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
 

Recently uploaded

Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
FIDO Alliance
 

Recently uploaded (20)

CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational Performance
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 

Orca share media1492336349924

  • 1. CSULB -- CECS 341–Examples of Addressing Modes © 2014 -- R.W. Allison 1
  • 2. 2 Addressing Mode – a specification for generating an address of an operand at run time. However, although all processors, simple or complex, obtain operands from registers, there are no “standards” as to the names of various of “addressing modes.” All operands for a particular processor are in registers, both CPU and memory. Thus, in our introduction to understanding these varieties of ways to obtain instruction operands, we are going to “generalize” the fundamental ways, not being “processor specific.” For the following fundamental addressing modes, we’ll show a “pseudo” assembly language usage, and then how that assembly language statement might be compiled. RISC processors don’t do any CPU operations (e.g. add, shift, mul, etc.) using memory registers—all operands must be in CPU registers. Thus, addressing modes for memory operands only apply to “Load” and “Store” type instructions. CISC processors do almost all CPU operations (e.g. add, shift, mul, etc.) using both CPU registers and memory registers. Thus, addressing modes are a critical part of compiling almost all of the instructions. CSULB -- CECS 341–Examples of Addressing Modes © 2014 -- R.W. Allison
  • 3. - - - - - - - - - - - - opc r0 reg/imm 0xA39D - - - - - - - - - - - - 3 For the following fundamental addressing modes, we’ll show (1) a “pseudo” assembly language usage, and then (2) how that assembly language statement might be compiled. Mode 1: Immediate—the operand itself (not the address of the operand) is part of the instruction. This mode is useful for initializing registers with address or data constants in programs. 0x017A add r0, #0xA39D For the sake of illustrating in the following examples, we assume all addresses are 16-bits, and all memory and CPU registers are 16-bits wide. Memory Addr Instruction Addr Contents 0x0178 0x0179 0x017A 0x017B 0x017C 0x017D • Compile the example instruction into the appropriate memory locations Note that since the immediate operand is 16-bits long, it is placed at memory location 0x017B, a “trailing word.” Thus, this is a “two-word” instruction. one instruction • What is the “address” of the operand that is added to R0? • What is the “value” of the operand that is added to R0? CSULB -- CECS 341–Examples of Addressing Modes © 2014 -- R.W. Allison
  • 4. - - - - - - - - - - - - opc r0 reg/dir 0xA39D - - - - - - - - - - - - 4 For the following fundamental addressing modes, we’ll show (1) a “pseudo” assembly language usage, and then (2) how that assembly language statement might be compiled. Mode 2: Direct—the instruction contains the address of the operand. Direct addressing may also be referred to as "absolute" addressing. The address must be known at compile time. 0x017A add r0, @0xA39D Memory Addr Instruction Addr Contents 0x0178 0x0179 0x017A 0x017B 0x017C 0x017D • Compile the example instruction into the appropriate memory locations Note that since the direct address is 16-bits long, it is placed at memory location 0x017B, a “trailing word.” Again, this is a “two-word” instruction. one instruction • What is the “address” of the operand that is added to R0? • What is the “value” of the operand that is added to R0? : 0xA39C 0xA39D 0xA39E : : - - - - - - 0xBC5F - - - - - - CSULB -- CECS 341–Examples of Addressing Modes © 2014 -- R.W. Allison
  • 5. - - - - - - - - - - - - opc r0 r7 reg/regi - - - - - - - - - - - - - - - - - - 5 For the following fundamental addressing modes, we’ll show (1) a “pseudo” assembly language usage, and then (2) how that assembly language statement might be compiled. Mode 3: Register Indirect—specifies the register holding the address of the operand. This addressing mode is used to access memory operands pointed to by “base pointers” that are stored in registers 0x017A add r0, [r7] Memory Addr Instruction Addr Contents 0x0178 0x0179 0x017A 0x017B 0x017C 0x017D • Compile the example instruction into the appropriate memory locations Note that since the R7 contains the 16-bit address, there is no “trailing word.” Thus, this would be a “one-word” instruction. one instruction • What is the “address” of the operand that is added to R0? This can’t be answered without knowing the contents of R7. For this example, let’s assume R7 = 0x875F : 0x875E 0x875F 0x8760 : : - - - - - - 0x10D5 - - - - - - • What is the “value” of the operand that is added to R0? CSULB -- CECS 341–Examples of Addressing Modes © 2014 -- R.W. Allison
  • 6. - - - - - - - - - - - - opc r0 r7 reg/base 0xA39D - - - - - - - - - - - - 6 For the following fundamental addressing modes, we’ll show (1) a “pseudo” assembly language usage, and then (2) how that assembly language statement might be compiled. Mode 4: Base (Indexed) — a variation of register indirect mode, where the effective address of the operand is calculated by the addition of a "base" register and a offset (signed displacement) included as a field in the instruction. We could name this mode as “Register Indirect with Offset.” 0x017A add r0, [r7+ 0xA39D] Memory Addr Instruction Addr Contents 0x0178 0x0179 0x017A 0x017B 0x017C 0x017D • Compile the example instruction into the appropriate memory locations Although R7 contains the 16-bit “base address,” the 16-bit offset must be in a “trailing word.” Thus, this would be a “two-word” instruction. one instruction • What is the “address” of the operand that is added to R0? This can’t be answered without knowing the contents of R7. For this example, let’s assume R7 = 0x1700 : 0xBA9C 0xBA9D 0xBA9E : : - - - - - - 0x5A17 - - - - - - • What is the “value” of the operand that is added to R0? CSULB -- CECS 341–Examples of Addressing Modes © 2014 -- R.W. Allison
  • 7. - - - - - - - - - - - - opc PC_rel 0x439D - - - - - - - - - - - - 7 For the following fundamental addressing modes, we’ll show (1) a “pseudo” assembly language usage, and then (2) how that assembly language statement might be compiled. Mode 5: PC Relative — a variation of “base mode,” where the effective address of the operand (typically an address to jump to) is calculated by the addition of the current PC and a offset (signed displacement) included as a field in the instruction. 0x017A jmp [PC + 0x439D] Memory Addr Instruction Addr Contents 0x0178 0x0179 0x017A 0x017B 0x017C 0x017D • Compile the example instruction into the appropriate memory locations Although PC contains the 16-bit “base address,” the 16-bit offset must be in a “trailing word.” Again, this would be a “two-word” instruction. one instruction • What is the “address” to jump to? Based on all the info given above, you should be able to answer this : 0x4518 0x4519 0x451A : : - - - - - - instr we’ll jmp to - - - - - - PC  0x017C + 0x439D CSULB -- CECS 341–Examples of Addressing Modes © 2014 -- R.W. Allison
  • 8. - - - - - - - - - - - - opc PC_rel 0x439D - - - - - - - - - - - - 8 For the following fundamental addressing modes, we’ll show (1) a “pseudo” assembly language usage, and then (2) how that assembly language statement might be compiled. Mode 5: PC Relative — a variation of “base mode,” where the effective address of the operand (typically an address to jump to) is calculated by the addition of the current PC and a offset (signed displacement) included as a field in the instruction. 0x017A jcs [PC + 0x439D] Memory Addr Instruction Addr Contents 0x0178 0x0179 0x017A 0x017B 0x017C 0x017D • Compile the example instruction into the appropriate memory locations The difference between this example and the previous one is that the “jmp” here is conditional. If the C-flag is set, the PC changes; if the C-flag is clear, the PC does not change. • What “address” does the PC get if C=1? : 0x4518 0x4519 0x451A : : - - - - - - instr we’ll jmp to - - - - - -PC  0x017C + 0x439D • What “address” does the PC get if C=0? PC  0x017C CSULB -- CECS 341–Examples of Addressing Modes © 2014 -- R.W. Allison