Addressing Modes related Mathematics in 8086 Microprocessor
Rules of Segmentation
process follows some rules as follows:
The starting address of a
segment should be such that it can be evenly divided by 16.
Minimum size of a segment
can be 16 bytes and the maximum can be 64 kB.
|
Segment |
Function |
|
|
CS |
IP |
Address of the next instruction |
|
DS |
BX, DI, SI |
Address of data |
|
SS |
SP, BP |
Address in the stack |
|
ES |
BX, DI, SI |
Address of destination data (for string operations) |
Physical Address
Calculation
The formula to calculate
the physical address (also called the absolute address) from a segmented
address involves multiplying the segment address by a constant and then adding
the offset address:
·
Effective Physical Address = Starting
address of Segment + Offset
Problem – 1: Let the
content of different registers in 8086 be as follows:
DS = 1000H, SS = 2000H,
ES = 3000H, BP = 7000H, SI = 5000H, DI = 6000H,
BX = 4000H
i.
MOV AX [BX]
ii.
MOV BX [SI]
iii.
MOV CX [BP]
iv.
MOV AL [DI]
v.
MOV BH, SS: [SI]
vi.
MOV CX, ES: [DI]
vii.
MOV AH, [BX + 10H]
Find
the memory address/addresses from where the 8086 accesses the data while
executing the following instructions:
Solution:
The formula for
calculating the Physical Address is:
Physical Address=(Segment×10H)
+ Offset [Note: ×10H is for converting 16-bit
to 20-bit address]
1) MOV AX, [BX]
Default Segment: DS
Offset: BX
P.A = (DS × 10H) + BX
= (1000H × 10H) + 4000H
= 10000H+4000H
= 14000H
So, the physical address is 14000H, 14001H
2) MOV BX, [SI]
Default Segment: DS
Offset: SI
P.A = (DS × 10H) + SI
= (1000H × 10H) + 5000H
= 10000H + 5000H
= 15000H
So, the physical address is 15000H,15001H
3) MOV CX, [BP]
Default Segment: SS
Offset: BP
P.A = (SS × 10H) + BP
= (2000H × 10H) + 7000H
= 20000H + 7000H
= 27000H
So, the physical address is 27000H
4) MOV AL, [DI]
Default Segment: DS
Offset: DI
P.A = (DS × 10H) + DI
= (1000H × 10H) + 6000H
= 10000H + 6000H
= 16000H
So, the physical address is 16000H
5) MOV BH, SS: [SI]
Explicit Segment: SS
Offset: SI
P.A = (SS × 10H) + SI
= (2000H × 10H) + 5000H
= 20000H + 5000H
= 25000H
So, the physical address is 25000H
6) MOV CX, ES: [DI]
Explicit Segment: ES
Offset: DI
P.A = (ES × 10H) + DI
= (3000H × 10H) + 6000H
= 30000H + 6000H
= 36000H
So, the physical address is 36000H,36001H
7) MOV AH, [BX + 10H]
Default Segment: DS
Offset: BX + 10H
P.A = (DS × 10H) + (BX + 10H)
= (1000H × 10H) + (4000H + 10H)
= 10000H + 4010H
= 14010H
So, the physical address is 14010H
Problem – 2: Let the content of different
registers in 8086 be as follows:
DS = 2000H, SS = 8000H, ES = 5000H, BP = 0200H,
SI = 0030H, DI = 0300H,
BX = 0800H, Value (displacement) = 0400H
i.
MOV AX, [BX] [SI]
ii.
ADD AL, [BP + 20H]
iii.
MOV CX, Values [BP]
iv.
MOV ES: [1500H], 30H
v.
MOV BX, [SI + 10H]
vi.
MOV CX, [BX + DI]
vii.
MOV AL, ES: [DI + 100H]
Find
the memory address/addresses from where the 8086 accesses the data while executing the following instructions:
Solution:
The formula for calculating the Physical Address is:
Physical Address=(Segment×10H) + Offset [Note: ×10H is for converting 16-bit to 20-bit
address]
i. MOV AX, [BX] [SI]
Segment: DS (Default
Segment)
Offset: BX + SI
P.A = (DS × 10H) + [BX +
SI]
= (2000H × 10H) + (0800H + 0030H)
= 20000H + 0830H
= 20830H
So, the physical address is 20830H
ii. ADD AL, [BP + 20H]
Segment: SS (Stack
Segment, used by default when BP is involved)
Offset: BP + 20H
P.A = (SS × 10H) + [BP +
20H]
= (8000H × 10H) + (0200H + 20H)
= 80000H + 0220H
= 80220H
So, the physical address is 80220H
iii. MOV CX, Values [BP]
Segment: SS (Stack
Segment, used by default when BP is involved)
Offset: BP
P.A = (SS × 10H) + [BP +
Values]
= (8000H × 10H) + (0200H + 0400H)
= 80000H + 0600H
= 80600H
So, the physical address is 80600H
iv. MOV ES: [1500H], 30H
Segment: ES (Explicitly
specified segment)
Offset: 1500H
P.A = (ES × 10H) + (1500H
+ 30H)
= (5000H × 10H) + (1500H + 30H)
= 50000H + 1530H
= 51530H
So, the physical address is 51530H
v. MOV BX, [SI + 10H]
Segment: DS (Default
Segment)
Offset: SI + 10H
P.A = (DS × 10H) + (SI +
10H)
= (2000H × 10H) +(0030H + 10H)
= 20000H + 0040H
= 20040H
So, the physical address is 20040H, 20041H
vi. MOV CX, [BX + DI]
Segment: DS (Default
Segment)
Offset: BX + DI
P.A = (DS × 10H) + (BX +
DI)
= (2000H × 10H) + (0800H + 0300H)
= 20000H + 0B00H
= 20B00H
So, the physical address is 20B00H, 20B01H
vii. MOV AL, ES: [DI + 100H]
Segment: ES (Explicitly
specified segment)
Offset: DI + 100H
P.A = (ES × 10H) + (DI +
100H)
= (5000H × 10H) + (0300H + 100H)
= 50000H + 0400H
= 50400H
So, the physical address is 50400H
Problem
– 3: Let the content of different registers in 8086 be as follows:
DS
= 1000H, SS = 2000H, ES = 3000H, BP = 7000H, SI = 5000H, DI = 6000H, BX = 4000H
i.
mov AX, [BX]
ii.
mov BX, [SI]
iii.
mov CX, [BP]
iv.
mov AL, [DI]
v.
mov BH, SS: [SI]
vi.
mov CX, ES: [DI]
vii.
mov AX, [BX + DI]
viii.
mov BX, [BP + DI + 5]
ix.
mov AH, [BX + 10H]
x.
mov EX, DS: [BP + 4]
xi.
mov BX, [SI - 5]
xii.
mov AX, [BX + 10]
Find the memory
address/addresses from where the 8086 accesses the data while executing the
following instructions:
0 Comments