0% found this document useful (0 votes)
14 views27 pages

CH 3

Addressing modes in microprocessors define how operands are accessed and specified in instructions, providing flexibility for data retrieval and storage. The Intel 8086 microprocessor introduced several addressing modes that enhance programming efficiency by allowing access to various data locations. Key addressing modes include immediate, register, direct, indirect, indexed, and relative addressing, each with distinct characteristics for efficient memory and data manipulation.

Uploaded by

elsayendale643
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views27 pages

CH 3

Addressing modes in microprocessors define how operands are accessed and specified in instructions, providing flexibility for data retrieval and storage. The Intel 8086 microprocessor introduced several addressing modes that enhance programming efficiency by allowing access to various data locations. Key addressing modes include immediate, register, direct, indirect, indexed, and relative addressing, each with distinct characteristics for efficient memory and data manipulation.

Uploaded by

elsayendale643
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 27

Addressing Mode of µP

Chapter 3
Introduction to Addressing Modes
What Are Addressing Modes?
 Addressing modes determine how the operand (data) is accessed
and specified in the instruction.
 Different modes offer flexibility in how data is retrieved or stored,
improving programming efficiency.
Why Are Addressing Modes Important?
 Provide flexibility to the programmer.
 Allow access to various locations (registers, memory, or I/O).
 Help in efficient use of memory and speed optimization.
Introduction to Addressing Modes
The Intel 8086 microprocessor was one of the first 16-bit
processors in the x86 family, and it introduced several addressing
modes to facilitate flexible and efficient memory and data
manipulation. These addressing modes determine how operands
are accessed by instructions, and they directly influence the
performance and efficiency of programs written for the 8086.
The 8086 uses segment-based addressing and supports a
variety of addressing modes that allow it to access data and
instructions in different ways. This flexibility is particularly useful
for assembly programming and system-level software
development.
The 8086 microprocessor supports six primary addressing modes
for accessing operands. These modes provide the ability to
reference data located in registers, memory, or constants, and
they can be combined in various ways for complex operations.
Introduction to Addressing Modes
Key Concepts in Addressing Modes
1. Operand Location
 Operand: The data on which the operation is performed (e.g., values in
registers, memory locations, or immediate constants).
 Addressing modes define how and where to find the operand.
2. Types of Operands
 Immediate Operands: Data is provided directly in the instruction itself
(e.g., MOV R1, #5).
 Register Operands: Data is stored in registers (e.g., MOV R1, R2).
 Memory Operands: Data is stored in memory and accessed via an address
(e.g., MOV R1, [2000]).
 Effective Address: In modes like indirect or indexed addressing, the
operand is located by calculating an address, which is called the effective
address.
3. Instruction Flexibility
 Different addressing modes allow the same instruction to access data in
different ways. This flexibility is crucial for efficient memory and data
manipulation.
Introduction to Addressing Modes
Key Concepts in Addressing Modes
4. Efficient Memory Use
Some addressing modes (like indirect or indexed) allow more
flexible memory management, enabling access to larger or
more complex data structures without directly specifying
every address in the instruction.
5. Mode of Access
Direct Access: The operand’s address is directly provided in
the instruction (e.g., MOV R1, 1000 where 1000 is a memory
address).
 Indirect Access: The address of the operand is stored in a register or memory
location, and the processor fetches the operand from that address (e.g., MOV R1,
[R2] where R2 contains the address of the operand).

6. Flexibility in Instruction Length


Immediate addressing can use a shorter instruction format
Introduction to Addressing Modes
Key Concepts in Addressing Modes
Base address, Offset and Effective address
Base Address: The starting memory location or
reference point used in certain addressing modes (like
indexed or base-register addressing). It's typically
stored in a register or a fixed memory location.

Offset: A value (either an immediate constant or the


contents of a register) that is added to or subtracted
from the base address to compute the final location of
the operand.
Introduction to Addressing Modes
Categories of Addressing Modes
Addressing modes can be broadly categorized into
three main types:
1. Data Addressing Modes
2. Program Memory Addressing Modes
3. Stack Memory Addressing Modes
These categories help us understand how operands
(data) are located in different parts of memory or
registers.
Data Addressing Modes
Data addressing modes refer specifically to how a microprocessor locates and
accesses operands (data) used by an instruction. These operands can be
constants, memory locations, or registers, and the addressing mode determines
how the processor fetches or manipulates this data. Below is a list and
explanation of the key data addressing modes, focusing on the specific ways the
processor can access data for operations like reading from or writing to memory,
registers, or constants.
1. Immediate Addressing Mode
In immediate addressing, the operand is directly provided in the instruction itself as a constant
value. The processor doesn’t need to fetch the data from memory or a register—it is embedded
within the instruction.
Example:
 MOV R1, #5
 Here, #5 is an immediate operand that is directly loaded into register R1.
Characteristics:
 The operand is a constant, and it is specified directly in the instruction.
Very fast, as no memory access is required.
Data Addressing Modes
2. Register Addressing Mode
 The operand is located in one of the CPU's registers. The instruction
refers directly to the register where the data is stored. There’s no need
to access memory.
 Example:
 MOV R1, R2
 This instruction copies the contents of register R2 into register R1.

 Characteristics:
The operand is in one of the processor’s registers (e.g., R1, R2, etc.).
This is the fastest data access mode because accessing registers is faster than
memory access.
Commonly used for operations between registers.
Data Addressing Modes
3. Direct Addressing Mode
 In direct addressing, the operand is located at a specific, known
memory address. The address is explicitly specified in the
instruction.
 Example:
MOV R1, [0x2000]
This instruction loads the value stored at memory address 0x2000 into
register R1.
 Characteristics:
The memory address is directly given in the instruction.
Fast because the address is known in advance.
Suitable for accessing fixed memory locations or variables.
Data Addressing Modes
4. Indirect Addressing Mode
 In indirect addressing, the operand is stored at an address that is
contained within a register. The instruction references the register, and
the contents of the register provide the memory address where the
operand is located.
 Example:
MOV R1, [R2]
In this case, R2 contains the address of the operand, so the instruction loads
the value from memory at the address R2 into register R1.
 Characteristics:
The operand’s address is stored in a register (e.g., R2).
This provides flexibility because the address is determined at runtime.
Commonly used with pointers or for dynamically accessing data.
Data Addressing Modes
5. Indexed Addressing Mode
 In indexed addressing, the effective address of the operand is computed by adding
an offset (displacement) to the contents of an index register. This mode is useful
for accessing data structures like arrays.
 Example:
MOV R1, [R2 + 4]
Here, the operand is located at the address R2 + 4, where R2 is the base
address and 4 is the offset.
 Characteristics:
The effective address is calculated as the sum of an index register (e.g., R2)
and an offset (e.g., 4).
Typically used for accessing array elements or sequential data.
The offset can be an immediate value or a constant.
Data Addressing Modes
6. Based Indexed Addressing Mode
 Based indexed addressing is a combination of base and index registers, where the
operand’s address is computed by adding the contents of the base register and the
index register, with an optional displacement.
 Example:
MOV R1, [R2 + R3 + 8]
In this case, the effective address is computed by adding the values in registers
R2 (base) and R3 (index), and then adding the displacement 8.
 Characteristics:
Combines both a base register and an index register.
Used for accessing more complex data structures such as multi-dimensional
arrays or records.
Displacement (optional) provides an additional offset.
Data Addressing Modes
7. Relative Addressing Mode
 In relative addressing, the operand’s address is calculated relative to the current
value of the Program Counter (PC). This mode is typically used for jump or
branch instructions, where the target address is an offset from the current
instruction location.
 Example:
JMP [PC + 10]
This instruction causes a jump to the address PC + 10, which is a relative
offset from the current program counter.
 Characteristics:
The operand’s address is calculated relative to the current position of the Program
Counter (PC).
This mode is often used in jump or branch instructions.
Enables position-independent code, which is useful in creating relocatable code.
Data Addressing Modes
8. Scaled-Index Addressing Mode
 In Scaled-Index Addressing, the effective address is calculated by adding a base
address to the product of an index register and a scale factor (1, 2, 4, or 8). It's
commonly used for accessing array elements where each element has a fixed size.
 Example:
For an array of 32-bit integers starting at 0x4000, to access the 3rd element (if
BX = 3):
Effective Address=0x4000+(BX×4)=0x400C
 Characteristics:
Combines a base address and an index register.
Multiplies the index by a scale factor (1, 2, 4, or 8).
Efficient for accessing arrays or structured data with elements of different
sizes.
Data Addressing Modes
Addressing Mode Description Data Movement Example
Data is moved from the
The operand is directly specified
Immediate Addressing instruction immediate value to a MOV AX, 5 (Move constant 5 to AX)
in the instruction (constant value).
register or memory.
The operand is located in a MOV BX, AX (Move contents of AX to
Register Addressing Data is moved between registers.
register. BX)
The operand is located at a Data is moved between memory MOV AX, [0x2000] (Move data from
Direct Addressing
specific memory address. (address) and register. address 0x2000 to AX)

The operand's address is specified Data is moved from memory MOV AX, [BX] (Move data from
Indirect Addressing
by a register. (address in register) to register. address in BX to AX)
The operand's address is
Data is moved from memory MOV AX, [SI + 4] (Move data at SI + 4
Indexed Addressing calculated by adding an index to a
(calculated address) to register. to AX)
base address.
The operand's address is
Data is moved from memory MOV AX, [BX + 4] (Move data from
Base-Register Addressing calculated by adding a base
(base + offset) to register. BX + 4 to AX)
register value to an offset.
The operand's address is specified
Data is moved from memory MOV AX, [SI] (Move data from
Register-Indirect Addressing by a register, which contains the
(address in register) to register. address in SI to AX)
memory address.
The operand's address is
Data is moved from memory
calculated by adding an index MOV AX, [BX + SI * 2] (Move data
Scaled-Index Addressing (calculated address with scaled
multiplied by a scale factor to a from BX + SI * 2 to AX
index) to register.
base address.
Data Addressing Modes
Generally:
Data Addressing Modes are used to access
operands (data) in registers or memory. The key
difference is in how the address of the operand is
calculated or specified.
Immediate addressing directly uses the
constant value in the instruction, while register
addressing operates directly with registers.
Indirect, Indexed, Base-Register, and
Scaled-Index addressing modes involve using
memory addresses that are either directly given,
Program Memory Addressing Modes
Program memory addressing modes refer to how a program can address memory locations
related to the execution flow, such as instructions, function calls, or jumps. These modes are
used primarily in control flow instructions (like jumps and branches) to manage program
execution.
1. Direct Program Memory Addressing
 In Direct Program Memory Addressing, the operand (usually a memory address) is
directly specified in the instruction. This allows the processor to jump to or call a specific
address without needing to calculate or modify the address at runtime.
 Characteristics:
The instruction contains the absolute memory address to jump to or load.
Typically used in jump or call instructions.
The target address is known at compile time.
Example:
JMP 0x1000 ; Jump to the program memory address 0x1000
In this example, the program will jump to the absolute memory address 0x1000.
Program Memory Addressing Modes
2. Relative Program Memory Addressing
 In Relative Program Memory Addressing, the target address is specified as an
offset relative to the current Program Counter (PC). This mode is typically used
for branching or looping, where the jump distance is small and depends on the
position of the current instruction.
 Characteristics:
The target address is computed as PC + offset.
The offset is usually a signed value, allowing both forward and backward
jumps.
Commonly used in conditional branches and looping instructions.
 Example:
JMP [PC + 5] ; Jump 5 bytes ahead from the current PC
If the Program Counter (PC) is at 0x2000, the target address would be 0x2005.
Program Memory Addressing Modes
3. Indirect Program Memory Addressing
 In Indirect Program Memory Addressing, the memory address of the operand (or
target) is stored in a register or memory location. The instruction specifies a register
or memory location that contains the address to which control should be transferred.
 Characteristics:
The instruction contains a register or memory address that holds the actual target
address.
Allows dynamic jump or call, where the target address is computed at runtime.
Useful for function pointers or dynamic jumps.
 Example:
 MOV SI, 0x1000 ; Load the address of the target (0x1000) into SI
 JMP [SI] ; Jump to the address contained in SI (0x1000)
 In this case, the target address 0x1000 is stored in the SI register, and the jump will occur at
the address 0x1000.
Program Memory Addressing Modes
Addressing Mode Description Data Movement Example

The operand's Data is moved from


Direct Program address is directly memory (target JMP 0x1000 (Jump
Memory Addressing specified in the address) to register to address 0x1000)
instruction. or PC.
The operand's
PC is updated with
Relative Program address is specified JMP [PC + 5] (Jump
the offset to jump to
Memory Addressing as an offset from the 5 bytes ahead)
the target address.
current PC.
Data is moved from
The operand's
a register or memory MOV SI, 0x1000;
Indirect Program address is stored in a
(address pointer) to JMP [SI] (Jump to
Memory Addressing register or memory
memory (target address in SI)
location.
address).
Program Memory Addressing Modes
Program Memory Addressing modes are
used for control flow (e.g., jumps, calls) by
directly specifying or calculating memory
addresses.
Stack Memory Addressing Modes
 Stack addressing modes refer to how operands are accessed from the stack, a special region of
memory used for storing temporary data such as function arguments, return addresses, and
local variables. These addressing modes are crucial for function calls and interrupt handling.
1. Push and Pop (Stack Addressing)
 In Push and Pop Stack Addressing, data is transferred to or from the stack using specific
instructions. The stack pointer (SP) is automatically adjusted during these operations.
 Characteristics:
Push: Decrements the stack pointer and stores the operand at the new stack address.
Pop: Loads the operand from the stack and increments the stack pointer.
 Example:
PUSH AX ; Push the value of AX onto the stack
POP BX ; Pop the top value of the stack into BX
In the above example:
PUSH AX: Saves the value in AX to the stack.
POP BX: Loads the value from the stack into BX.
Stack Memory Addressing Modes
2. Indexed Stack Addressing
 In Indexed Stack Addressing, the stack pointer is modified by an index value (an
offset). This allows more flexible access to multiple stack elements, such as
accessing multiple function parameters or local variables.
 Characteristics:
The stack pointer is adjusted by an offset value.
Used for more complex stack operations where accessing specific stack
locations is required.
 Example:
MOV AX, [SP + 4] ; Access a value from the stack at SP + 4
Here, the value at the memory location SP + 4 is loaded into the AX register.
The stack pointer (SP) is offset by 4 bytes.
Stack Memory Addressing Modes
Addressing Mode Description Data Movement Example

Push: Data moves


from register to stack
Data is transferred memory (SP is
PUSH AX; POP BX
Push and Pop Stack to/from the stack decremented).
(Push AX to stack,
Addressing using the stack Pop: Data moves
Pop to BX)
pointer (SP). from stack memory
to register (SP is
incremented).
Data is accessed
Memory (stack at SP MOV AX, [SP + 4]
Indexed Stack from the stack using
+ offset) is moved to (Access stack value
Addressing an offset from the
register. at SP + 4)
stack pointer.
Stack Memory Addressing Modes
Generally:
Stack Memory Addressing modes handle data
manipulation on the stack, typically used in
function calls or temporary storage, with the
stack pointer automatically adjusting during
push and pop operations.
End

You might also like