CSE-3103: Microprocessor and Microcontroller
Dept. of Computer Science and Engineering
University of Dhaka
Prof. Sazzad M.S. Imran, PhD
Dept. of Electrical and Electronic Engineering
[Link]
Immediate Addressing Mode
Operands are specified within instructions.
Example
MOV AL, 15H
ADD AX, 0B14H
Register Addressing Mode
Operands are stored within any of internal registers.
Example
MOV AX, BX
ADD AL, BL
8-bit register
AH, AL, BH, BL, CH, CL, DH, DL.
16-bit register
AX, BX, CX, DX, SP, BP, SI, DI.
Instructions have to use same size registers.
Register Addressing Mode
Operands are stored within any of internal registers.
Example
MOV AX, BX
ADD AL, BL
8-bit register
AH, AL, BH, BL, CH, CL, DH, DL.
16-bit register
AX, BX, CX, DX, SP, BP, SI, DI.
Instructions have to use same size registers.
Direct Addressing Mode
16-bit offset address is directly specified in instruction.
Example
MOV CX, BETA
physical address = DS×10H + 1234H
= 0200×10H + 1234H
= 03234H
CL [03234H]
CH [03235H]
PA = Base segment : Direct address.
= DS/ES/SS : EA
Memory address
default segment address = DS
alternate segment address = SEG (ES/SS).
SEG = segment override prefix.
Direct Addressing Mode
16-bit offset address is directly specified in instruction.
Example
MOV CX, BETA
physical address = DS×10H + 1234H
= 0200×10H + 1234H
= 03234H
CL [03234H]
CH [03235H]
PA = Base segment : Direct address.
= DS/ES/SS : EA
memory address
default segment address = DS
alternate segment address = SEG (ES/SS).
SEG = segment override prefix.
Register Indirect Addressing Mode
Data is available at address
offset address BX, SI or DI.
segment DS (default) or ES.
another option SS : BP
Difference
direct addressing
EA = constant
register indirect addressing
EA = variable.
Example
MOV AX, [SI]
physical address = DS×10H + SI
= 0200×10H + 1234H
= 03234H
direct addressing:
MOV CX, [BETA]
Register Indirect Addressing Mode
Example
MOV AX, [SI]
physical address = DS×10H + SI
= 0200×10H + 1234H
= 03234H
Based Addressing Mode
Operand offset address
BX/BP registers + 8-bit/16-bit displacement.
Default segment address
DS for BX.
SS for BP.
PA = Base segment : Base + Displacement
Change displacement value
access different elements within same
data structure.
Change base register value
access same element in another
data structure.
Example
MOV [BX].BETA, AL
physical address = DS×10H + [BX] + BETA
= 0200×10H + 1000H + 1234H
= 04234H
Based Addressing Mode
Operand offset address
BX/BP registers + 8-bit/16-bit displacement.
Default segment address
DS for BX.
SS for BP.
PA = Base segment : Base + Displacement
Change displacement value
access different elements within same
data structure.
Change base register value
access same element in another
data structure.
Example
MOV [BX].BETA, AL
physical address = DS×10H + [BX] + BETA
= 0200×10H + 1000H + 1234H
= 04234H
Based Addressing Mode
operand offset address
BX/BP registers + 8-bit/16-bit displacement.
default segment address
DS for BX.
SS for BP.
PA = Base segment : Base + Displacement
change displacement value
access different elements within same
data structure.
change base register value
access same element in another
data structure.
Example
MOV [BX].BETA, AL
physical address = DS×10H + [BX] + BETA
= 0200×10H + 1000H + 1234H
= 04234H
Indexed Addressing Mode
Operand offset address
SI or DI register + 8-bit/16-bit displacements.
Default segment address
DS for SI.
ES for DI.
PA = Base segment : Index + Displacement
Change index register value
access different elements within same data structure.
Change displacement value
access same element in another data structure.
Example
MOV AL, ARRAY[SI]
physical address = DS×10H + [SI] + ARRAY
= 0200×10H + 2000H + 1234H
= 05234H
Indexed Addressing Mode
Operand offset address
SI or DI register + 8-bit/16-bit displacements.
Default segment address
DS for SI.
ES for DI.
PA = Base segment : Index + Displacement
Change index register value
access different elements within same
data structure.
Change displacement value
access same element in another
data structure.
Example
MOV AL, ARRAY[SI]
physical address = DS×10H + [SI] + ARRAY
= 0200×10H + 2000H + 1234H
= 05234H
Indexed Addressing Mode
operand offset address
SI or DI register + 8-bit/16-bit displacements.
default segment address
DS for SI.
ES for DI.
PA = Base segment : Index + Displacement
change index register value
access different elements within same
data structure.
change displacement value
access same element in another
data structure.
example
MOV AL, ARRAY[SI]
physical address = DS×10H + [SI] + ARRAY
= 0200×10H + 2000H + 1234H
= 05234H
Based Indexed Addressing Mode
Based indexed addressing = based addressing + indexed addressing.
Offset address
Base register (BX or BP) + Index register (SI or DI).
Segment address
DS or SS.
PA = Base segment : Base + Index
= DS : BX + SI or
= SS : BP + DI
Example
MOV AL, [BX].[SI]
physical address = DS×10H + [BX] + [SI]
= 0300×10H + 1000H + 1234H
= 05234H
Relative Based Indexed Addressing
Offset address
BX or BP + SI or DI
+ 8- or 16-bit displacement.
Segment address
DS or SS.
PA = Base segment : Base + Index
+ Displacement
Used to access 2-D (m×n) array.
Displacement = starting position of array.
Base register = one coordinate (say m),
Index register = other coordinate (say n).
Example
MOV AH, [BX] [SI] + BETA
physical address = DS×10H + [BX] + [SI] + BETA
= 0200×10H + 1000H + 2000H + 1234H
= 06234H
Relative Based Indexed Addressing
Offset address
BX or BP + SI or DI
+ 8- or 16-bit displacement.
Segment address
DS or SS.
PA = Base segment : Base + Index
+ Displacement
Used to access 2-D (m×n) array.
Displacement = starting position of array.
Base register = one coordinate (say m),
Index register = other coordinate (say n).
Example
MOV AH, [BX] [SI] + BETA
physical address = DS×10H + [BX] + [SI] + BETA
= 0200×10H + 1000H + 2000H + 1234H
= 06234H
Relative Based Indexed Addressing
Offset address
BX or BP + SI or DI
+ 8- or 16-bit displacement.
Segment address
DS or SS.
PA = Base segment : Base + Index
+ Displacement
Used to access 2-D (m×n) array.
Displacement = starting position of array.
Base register = one coordinate (say m),
Index register = other coordinate (say n).
Example
MOV AH, [BX] [SI] + BETA
physical address = DS×10H + [BX] + [SI] + BETA
= 0200×10H + 1000H + 2000H + 1234H
= 06234H