You are on page 1of 18

8086 Addressing Modes

What is the Addressing Mode ?


add dest, source ; dest
+source→dest
add ax,bx ; ax
+bx→ax

The addressing mode means where and how


the CPU gets the operands when the
instruction is executed.
Three types of 8086
addressing modes

• Immediate Addressing Mode


---CPU gets the operand from the instruction

• Register Addressing Mode


---CPU gets the operand from one of the internal registers

• Memory Addressing Mode


---CPU gets the operand from the memory location(s)
1. Immediate Addressing Mode
Exp:
Exp:
MOV AL, 80H
80H MOV AX, 1234H
Machine code:
code:B080H
80H Machine code:B83412H

Instruction Queue

AH AL
Instruction Queue
AL 80H 12 34
B8
MACHINE
B0H MACHINE
34H
34 CODE
CODE
80H 12H
12
2. Register Addressing Mode
:MOV AX, CX
Exp:

Memory
AX

89
CX Machine code
C1
3. Memory Addressing Mode

• Specify an offset address (effective address) using expressions of the


form (different parts of expression are optional):
– [ Base Register + Index Register+ Displacement]
• 1) Base Register---BX, BP
• 2) Index Register---SI, DI
• 3) Displacement ---constant value
• Example: 1) add ax,[20h] 2) add
ax,[bx]
3) add ax,[bx+20h] 4) add
ax, [bx+si]
5) add ax, [bx+si+20h]
3. Memory Addressing Mode

⑴ Direct Addressing Mode


Exp: MOV AL, [1064H]
Machine code:A06410H

• The offset address of the operand is


provided in the instruction directly;
• The physical address can be calculated
using the content of DS and the offset :
PA = (DS)*10H+Offset
⑴ Direct Addressing Mode
Example: MOV AL, [1064h]
;Assume (DS)=2000H
Machine code: A06410H
A0 Code
(DS)*10H=20000H
64 Segment
+ 1064H
10
21064H

AL 45 20000H
Data

Segment
21064H
45
3. Memory Addressing
Mode
⑵ Register Indirect Addressing Mode
• The address of memory location is in a
register (SI,DI,or BX only)

• The physical address is calculated using the


content of DS and the register(SI,DI,BX)

PA = (DS)*10H+(SI)/(DI)/(BX)
⑵ Register Indirect Addressing Mode
ASSUME: (DS)=3000H, (SI)=2000H, (BX)=1000H

MOV AX, [SI] MOV [BX], AL


(DS)*10H=30000H (DS)*10h= 30000H
M M
+ (SI)= 2000H + (BX)= 1000H
32000H 31000H


AX 30000H AL 30000H

40 50 64H


32000H 31000H
50 64H
40
⑶ Register Relative Addressing

(BX)
(BP)
EA= + Displacement
(DI)
(SI)

For physical address calculation:


DS is used for BX,DI,SI;
SS is used for BP

PA=(DS)*10H+(BX)/(DI)/(SI)+Disp
OR
PA=(SS)*10H+(BP)+Disp
⑶ Register Relative Addressing
MOV CL, [BX+1064H] ;assume: (DS)=2000h,
(bx)=1000h 8A
;Machine Code: 8A8F6410 Code
PA=(ds)*10h+(bx)+1064h 8F Segment

64
(DS)*10h= 20000H
(BX)= 1000H 10
+ 1064H
22064H 20000H


Data
CL 45 21000H Segment


22064H
45
⑷ Based Indexed Addressing

(BX) (DI)
EA= (BP) + (SI)

• Base register(bx or bp) determines which segment(data or stack) the operand


is stored;
• if using BX, the operand is defaultly located in Data segment,then:
PA=(DS)*10H+(BX)+(DI)/(SI)

• if using BP, the operand is defaultly located in stack segment,then:


PA=(SS)*10H+(BP)+(DI)/(SI)
⑷ Based Indexed Addressing

Example: MOV AH,


[BP][SI];Assume(ss)=4000h,(bp)=2000h,(si)=1200h
PA=(ss)*10h+(bp)+(si)
(SS)*10H= 40000H
(BP)= 2000H
M
+ (SI)= 1200H
43200H


AH 40000H
56H …
43200H
56H
⑸ Based Indexed Relative
Addressing
(BX) (DI)
EA= + + Displacement
(BP) (SI)

if using BX, the operand is defaultly located in Data segment,then:


PA=(DS)*10H+(BX)+(DI)/(SI)+disp

if using BP, the operand is defaultly located in stack segment,then:


PA=(SS)*10H+(BP)+(DI)/(SI)+disp
⑸ Based Indexed Relative
Addressing 88
Code
MOV [BX+DI+1234H], AH A1 segment

;assume (ds)=4000h,(bx)=0200h,(di)=0010h 34
;machine code:88A13412h
(DS)*10H=40000H 12
(BX)= 0200H
(DI)= 0010H
+ 1234H 40000H

41444H

Data
segment

AH 45 …
41444H
45
Summary on the 8086 memory addressing modes
operand offset address Default Overridden
(effective address) Segment Register Segment Register

1. Direct Addressing [disp] disp DS CS ES SS

2. Register [BX]/[SI] /[DI] Content of the R DS CS ES SS


Indirect Addressing

3. Register [SI/DI/BX/BP+disp] (SI)/(DI)/(BX)/(BP)+disp DS CS ES SS


Relative Addressing

4. Based Indexed [BX+SI/DI] (BX)+disp DS CS ES SS


Addressing [BP+SI/DI] (BP)+disp SS CS ES DS

5. Based Indexed [BX+SI/DI+disp] (BX)+(SI)/(DI)+disp DS CS ES SS


Relative Addressing [BP+SI/DI+disp] (BP)+(SI)/(DI)+disp SS CS ES DS
Examples:
Assume: (BX)=6000H, (BP)=4000H, (SI)=2000H,
(DS)=3000H, (ES)=3500H, (SS)=5000H

Instruction addressing logical physical


mode address address
1. MOV AX, [0520H] Direct Addressing 3000:0520 30520H

2. MOV AX, [BX] Register Indirect Addressing 3000:6000 36000H

3. MOV AX, [SI+1000H] Register Relative Addressing 3000:3000 33000H

4. MOV AX, [BP+6060H] Register Relative Addressing 5000:A060 5A060H

5. MOV AX, ES: [BX+SI+0050H] Based Indexed Relative 3500:8050 3D050H


Addressing

You might also like