Addressing Modes related Mathematics in 8086 Microprocessor
A logical address is
generated by the CPU while a program runs. It represents the address from the
process’s perspective and does not exist physically; hence it is also called a
virtual address.
The logical address space
is the set of all logical addresses a process can generate. Programs use
logical addresses to reference memory, and the MMU translates them into
physical addresses when accessing actual memory.
A physical address is the
real location in main memory (RAM) where data or instructions are stored. The
physical address space consists of all physical addresses corresponding to
logical addresses.
The MMU performs address
translation using a page table, mapping each logical page to a physical frame.
This allows processes to access memory transparently, without knowing actual
memory locations.
Memory Management Unit
The Memory
Management Unit (MMU) is a hardware component in the computer system
that handles all memory and caching operations associated with the CPU. Its
main function is to translate logical (virtual) addresses generated
by the CPU into physical addresses in main memory.
Difference Between Logical address and
Physical Address:
|
Parameter |
LOGICAL ADDRESS |
PHYSICAL ADDRESS |
|
Basic |
generated by CPU |
location in a memory unit |
|
Address Space |
Logical Address Space is set of all
logical addresses generated by CPU in reference to a program. |
Physical Address is set of all physical
addresses mapped to the corresponding logical addresses. |
|
Visibility |
User can view the logical address of a
program. |
User can never view physical address of
program. |
|
Generation |
generated by the CPU |
Computed by MMU |
|
Access |
The user can use the logical address to
access the physical address. |
The user can indirectly access physical
address but not directly. |
|
Editable |
Logical address can be change. |
Physical address will not change. |
|
Also called |
virtual address. |
real address. |
In the 8086 microprocessors,
the effective address (EA) is a 16-bit offset value that,
when combined with a 16-bit segment register, produces the 20-bit physical
memory address. The EA is also known as the offset address because it indicates
the distance from the beginning of a memory segment to the actual memory
location of the operand.
The EA is not a single
value but is calculated differently depending on the instruction's addressing
mode. The calculation can involve up to three components:
- Displacement: An
immediate 8-bit or 16-bit value included in the instruction.
- Base: The
value of a base register, either BX (Base Register) or BP (Base
Pointer).
- Index: The
value of an index register, either SI (Source Index) or DI (Destination
Index).
Effective address
calculation by addressing mode
Here is how the EA is
calculated in different 8086 memory addressing modes:
The 16-bit effective
address is directly specified as part of the instruction.
Ø Example: MOV AX, [5000H]
Ø Effective Address (EA): 5000H
Ø Physical Address: DS × 10H + 5000H
Register
indirect addressing
The
EA is held in one of the bases (BX, BP) or index (SI, DI) registers.
- Example:
MOV AX, [BX]
- Effective Address (EA):
The value of BX.
- Physical Address: (DS X 10H) + [BX] ; (if BX, SI, or DI is used). If BP is
used, the default segment is SS.
Based
addressing
The
EA is the sum of a base register (BX or BP) and an 8-bit or 16-bit
displacement.
- Example:
MOV DX, [BX+04H]
- Effective Address (EA): [BX] + 04H
- Physical Address: (DS X 10H) + [BX] + 04H
Indexed
addressing
The
EA is the sum of an index register (SI or DI) and an 8-bit or 16-bit
displacement.
- Example:
MOV BX, [SI+16H]
- Effective Address (EA): [SI] + 16H
- Physical Address: (DS X 10H) + [SI] + 16H
Based-indexed
addressing
The
EA is the sum of a base register (BX or BP) and an index register (SI or DI).
- Example:
MOV AX, [BX][SI] or MOV AX, [BX+SI]
- Effective Address (EA): [BX] + [SI]
- Physical Address: (DS X 10H) + [BX] + [SI] + 16H
Relative
based-indexed addressing
The
EA is the sum of a base register (BX or BP), an index register (SI or DI), and
an 8-bit or 16-bit displacement.
- Example:
MOV DL, [BX+SI+50H]
- Effective Address (EA): [BX] + [SI] + 50H
- Physical Address: (DS X 10H) + [BX] + [SI] + 50H
Physical
address calculation
Once
the 16-bit effective address is determined, the 8086 calculates the 20-bit
physical address using one of the four segment registers (CS, DS, SS, ES):
Physical
Address = (Segment Register X 10H) + Effective
Address (EA) / Offset Address
The
default segment register depends on the memory access:
- For data accesses, the default is the
DS (Data Segment) register.
- For stack operations (PUSH, POP), the
default is the SS (Stack Segment) register.
- For instruction fetches, the CS (Code
Segment) register is used.
- For string operations, the DI
register uses the ES (Extra Segment) register.
0 Comments