ADDRESSING MODES
Introduction to Programming
Machine Language
• Programs can be written as simply a sequence
of the binary codes for the instructions the
microcomputer to execute.
• It is difficult for a programmer to memorize
1000’s of binary instruction codes for a CPU
such as the 8086.
• It is easy for an error to occur when working
with long series of 1’s and 0’s
Introduction to Programming
Assembly Language
• Assembly language statements are usually written in
a standard form that has four fields
Label Field Opcode Field Operand Field Comment Field
Next: ADD AL, 05H Add Correction
Factor
• Assembly language programs (ALP) cannot be
directly run on the 8086.
• ALP must be translated to an equivalent machine
language program for execution by 8086. This
conversion is done by ASSEMBLER.
Introduction to Programming
High Level Language
• Programs can usually written faster in high level
languages than in assembly language
• An interpreter or a compiler program is used to
translate high level language statements to machine
codes which can be loaded into memory and
executed.
• Each high level statement may represent many
machine code instructions
• Execution gets slowly and require more memory when
compared to ALP
Addressing Modes
• The different ways in which an 8086 can access data
that it operates on referred to as Addressing Modes.
• When the 8086 executes an instruction, it performs
the specified function on data
• These data called the operands may be
• Part of Instruction
• May reside in one of the internal registers of
the processor
• May be stored at an address in memory
• May be held at an I/O port
Addressing Modes
• Addressing Modes are of two categories, those for
Data and those for Branch addresses
Data Related Branch Related
• Immediate • Intrasegment Direct
• Register • Intrasegment InDirect
• Direct • Intersegment Direct
• Indirect • Intersegment Indirect
• Register Relative
• Based Indexed
• Relative Based Indexed
• Implied
Addressing Modes-Data Related
Immediate operand Addressing mode
Immediate
Instruction
Data is part of Instruction
either 8 bits or 16 bits
Data
Eg. MOV AX,1234H
MOV AL,15H
8086 Address Memory Instruction
Content
IP 0000
01000 B0 MOV AL,15H
CS 0100 01001 15
After Execution 01002 XX Next Instruction
DS
SS IP 0002 01003 XX
ES CS 0100
AX 1234 AX 1215
Addressing Modes-Data Related
Register operand Addressing mode
Register
Data is in the register that is
Instruction Register specified by the instruction
Register Data For a 16-bit operand, a register
may be AX,BX,CX, DX, SI, DI,
Eg. MOV AX,BX SP or BP
MOV AX,BX
8086 Address Memory Instruction
IP 0100 Content
01100 8B MOV AX,BX
CS 0100 After Execution
01101 C3
DS 0200 01102 XX Next Instruction
IP 0102
SS 01103 XX
ES CS 0100
AX 1234 AX 5768
BX 5768 BX 5768
Addressing Modes-Data Related
Memory operand Addressing mode
The16-bit EA of the data is part of
Direct the instruction
Instruction Memory PA
EA + Data
EA Data
MOV CX,[1234H] Eg. MOV AX,[2400H]
Shifted Segment Register
8086
Address Memory Instruction
Content
IP 0000
01000 8B MOV CX,[1234H]
CS 0100 After Execution 01001 0E
DS 0200 01002 34
IP 0002 01003 12
SS
ES CS 0100 01004 XX Next Instruction
AX :
5768
CX 5678
BX 5768
Addressing Modes-Data Related
Memory operand Addressing mode
Direct Instruction Memory
EA Data
EA + Data Address Memory Instruction
PA Content
Shifted Segment Register
01000 8B MOV CX,[1234H]
MOV CX,[1234H] 01001 0E
8086
01002 34
01003 12
IP 0000
01004 XX Next Instruction
CS 0100 After Execution : Shifted DS
DS 0200 02000 XX 02000
IP 0004
SS 02000 EA 1234
ES CS 0100 :
PA 03234
CX 9500 03234 00
CX 5678
03235 95
Addressing Modes-Data Related
Memory operand Addressing mode
Register PA
Register Indirect
Instruction Register Memory EA + Data
Register EA Data Shifted Segment Register
Eg. MOV CX, [BX]
Address Memory Instruction
Content
MOV AX,[SI] 01000 8B MOV AX,[SI]
01001 04
8086
01002 XX Next Instruction
IP 0000
:
CS 0100 After Execution Shifted DS
02000 XX
DS 0200 02000 02000
IP 0002
SS : EA 1234
AX 4566 CS 0100 03234 00 PA 03234
SI 1234 AX 9500 03235 95
Addressing Modes-Data Related
Memory operand Addressing mode
Register Relative + Data
Register + EA
Instruction PA
Register Displacement
Displacement Shifted Segment Register
Register EA
Memory
Address Memory Instruction
Address + Data Content
Eg. MOV CX, 1234H[BX] 01000 88 MOV CX, 1234H[BX[
MOV CX,[1234H] 01001 87
8086
01002 34
01003 12
IP 0000
01004 XX Next Instruction
CS 0100 After Execution : Shifted DS
DS 0200 02000 XX 02000
IP 0004 02000
SS 1234
CX 6723 CS 0100 : EA 1000
04234 DE
BX 1000 CX 85DE 04235 85
PA 04234
Addressing Modes-Data Related
Memory operand Addressing mode
Based Indexed Index Address Shifted
Segment Memory
Instruction Register Register
BaseRegister Index Register PA
Register + EA + Data
Base
Address Eg. MOV CX, [BX][SI] Address Memory Instruction
Content
MOV AX,[SI] 01000 8B MOV CX,[BX][DI]
01001 77
8086
01002 XX Next Instruction
IP 0000
0100 :
CS
After Execution
ES
02000 XX Shifted ES
SS IP 0002 02000 03000
0300 : 1234
DS
CS 0100 05234 CD EA 1000
DI 1234
BX 1000
CX 67CD 05235 67 PA 05234
Addressing Modes-Data Related
Memory operand Addressing mode
Memory
Relative Based Indexed Shifted Segment Register
Instruction PA
Base Register Index Register Displacement + EA + Data
Register
Address Memory Instruction
Index Address
Register Content
Eg. MOV CX, 1234H[BX][SI]
Base Address 01000 88 MOV CX,
34H[BX[SI]
MOV CX,[1234H] 01001 80
8086 01002 34
IP 0000 01003 XX Next
Instruction
CS 0100 After Execution : Shifted
DS
02000
DS 0200 02000 XX
IP 0003 02000
34
SS EA 1000
SI 3000
CS 0100 :
3000
06034 DE
BX 1000 CX 85DE 06035 85
PA 06034