Download as pdf or txt
Download as pdf or txt
You are on page 1of 35

Microprocessor and

Interfacing
Ch2_lec2_8086 Addressing Modes
and Instruction Formats

Kassahun Tamir 1
Register Addressing Mode
 Transfers a copy of a byte or word from the source
register or memory location to the destination register
or memory location.
 This mode specifies the source operand, destination
operand, or both to be contained in the 8086 register.
 Register addressing is the most common form of data
addressing modes.
 Example:
MOV AX , BX
Destination Source

Kassahun Tamir 2
Register Addressing Mode
 Example:
Assembly Size Operation
Language
MOV AL, BL 8-bits Copies BL into AL
MOV AX, CX 16-bits Copies CX into AX
MOV DS, AX 16-bits Copies AX into DS
MOV ES, DS --- Not allowed
(segment to segment)
MOV BL, DX --- Not allowed
(Mixed Size)

Kassahun Tamir 3
Immediate Addressing Mode
 Transfer the source-immediate byte or word of data into
the destination register.
 The term immediate implies that the data immediately
follow the hexadecimal opcode in the memory. Also note
that immediate data are con­stant data, while the
data transferred from a register are variable data.
 Example
MOV BL, 26H
MOV CX, 4567H

Kassahun Tamir 4
Direct Addressing Mode
 In this mode, the 16-bit effective address (EA) is taken
directly from the displacement field of the instruction.
 Direct addressing with a MOV instruction transfers data
between a memory location, located within the data
segment, and a given reg­ister.

 Example
MOV CX, [9823H]
MOV AL, [1234H]
Kassahun Tamir 5
Direct Addressing Mode
 The operation of the MOV AL, [1234H]
when DS = 1000H. Memory
Registers XXH 11235H

AX AH AL 8AH 11234H
XXH XXH
8AH
XXH 11233H
BX BH BL
XXH XXH XXH 11232H

XXH 11231H
Physical address DS = 10000H
+ BX = Kassahun
1234H Tamir
11234H 6
Register Indirect Addressing Mode
 Transfers a byte or word between a register and
memory location addressed by an index or base
register.
 It allows data to be addressed at any memory location
through an offset address held in any of the following
registers: BP, BX, DI, and SI.


Example
MOV CX, [DI]
MOV [BX], AX
Kassahun Tamir 7
Register Indirect Addressing Mode
 The operation of the MOV [BX], AX instruction when
BX = 1000H and DS = 0100H.
Regist Memo
ers ry
02002
AX AH AL XXH H
02001
34H 12H XXH
34H H
02000
BX BH BL XXH
12H H
01FFF
10H 00H XXH H
01FFE
XXH H
 Physical address DS = 01000H
+ BX = Kassahun
1000H Tamir 02000H 8
Base-Plus-Index Addressing Mode
 Transfers a byte or word between a register and the
memory location addressed by a base register (BP or
BX) plus index register ( DI or SI).

 Example
MOV [BX + DI], CL
MOV AX, [BP + SI]

Kassahun Tamir 9
Register Relative Addressing Mode
 Moves a byte or word between a register and the
memory location addressed by an index or base register
plus a displacement.
 In register relative addressing, the data in a segment of
memory are addressed by adding the displacement to
the contents of a base or an index register (BP, BX, Dl,
or SI).
 Example
MOV AX, [BX+4]
MOV [SI+8], DL
Kassahun Tamir 10
Base Relative-Plus-Index
 Transfers a byte or word between a register and the
memory location addressed by a base register (BP or
BX) plus index register ( DI or SI) plus a displacement.
 In this addressing, the data in a segment of memory are
addressed by adding the displacement to the contents
of a base plus index register.

 Example
MOV DH, [BX+DI+20H]

Kassahun Tamir 11
Questions and Answers
 What do the following MOV instructions accomplish?
Instruction Accomplish
(a) MOV AX, BX Copy the contents of
register BX into register AX
(b)MOV BX, AX Copy the contents of
register AX into register BX
(c) MOV BL, CH Copy the contents of
register CH into register BL
(d)MOV AX, CS Copy the contents of
register CS into register AX
Kassahun Tamir 12
Questions and Answers
 Write an instruction for each of the following tasks:
Task Instruction
(a)copy BL into CL MOV CL, BL
(b)copy SI into BX MOV BX, SI
(c)copy DS into AX MOV AX, DS
(d)move a 12H into AL MOV AL, 12H
(e) move a 1000H into MOV SI,
SI 1000H
(f) move a CH into CL MOV CL, CH
Kassahun Tamir 13
Questions and Answers
 Suppose that
DS = 0200H, BX= 0300H, and DI = 400H.
Determine the memory address ac­cessed by each of the
following instructions, assuming real mode operation:
(a) MOV AL, [1234H]
(b) MOV AX, [BX]
(c) MOV [DI], AL

Kassahun Tamir 14
Questions and Answers
 Starting address of the segment (DS) 02000H
+ displacement (1234H) + 1234H
Memory location address 03234H
 Starting address of the segment (DS) 02000H
+ displacement (BX) + 0300H
Memory location address 02300H
 Starting address of the segment (DS) 02000H
+ displacement (DI) + 0400H
Memory location address 02400H
Kassahun Tamir 15
Questions and Answers

Suppose that
DS = 1000H, SS = 2000H, BP = 1000H, DI = 0100H,
BX=3900H and SI = 0250H
Determine the memory address accessed by each of
the following instructions, assuming real mode
operation:
(a) MOV AL, [BP+DI]
(b) MOV DX, [BX+100H]
(c) MOV CH, [BX+SI+200H]

Kassahun Tamir 16
Questions and Answers

Starting address of the segment (SS) 20000H
+ register (BP) + 1000H
+ register (DI) + 0100H
Memory location address 21100H

Starting address of the segment (DS) 10000H
+ register (BX) + 3900H
+ displacement (100H) + 0100H
Memory location address 13A00H

Starting address of the segment (DS) 10000H
+ register (BX) + 3900H
+ register (SI) + 0250H
+ displacement (200H) + 0200H
Memory location address
Kassahun Tamir
13D50H 17
Instruction Format
 The 8086 Has around 117 instruction
✗ No operand,
✗ Single operand, and
✗ Two operand instructions

 No memory to memory operations except for string


instructions

Kassahun Tamir 18
µP Programming Languages
Machine Language
 Binary Instructions
 Difficult to decipher and write
✗ Error-prone
 All programs converted into machine language for
execution

Kassahun Tamir 19
µP Programming Languages
Assembly Language
 Machine instructions represented in mnemonics
 One-to-one correspondence
 Efficient execution and use of memory
 Machine-specific

Kassahun Tamir 20
µP Programming Languages
High-Level Languages
 BASIC, C, and C++
 Written in statements of spoken languages
 Machine independent
 Easy to write and troubleshoot
 Larger memory and less efficient execution

Kassahun Tamir 21
Instruction Format

Kassahun Tamir 22
Operands Memory Operands Reg Operands

MOD 00
No Disp
Instruction
01
8-bit Disp
Format10
16-bit Disp
11

W=1 W=0
R/M
000 [BX]+[SI] [BX]+[SI]+d8 [BX]+[SI]+d16 AX AL

001 [BX]+[DI] [BX]+[DI]+d8 [BX]+[DI]+d16 CX CL

010 [BP]+[SI] [BP]+[SI]+d8 [BP]+[SI]+d16 DX DL

011 [BP]+[DI] [BP]+[DI]+d8 [BP]+[DI]+d16 BX BL

100 [SI] [SI]+d8 [SI]+d16 SP AH

101 [DI] [DI]+d8 [DI]+d16 BP CH

110 D16(Direct [BP]+d8 [BP]+d16 SI DH


Addressing)
111 [BX] [BX]+d8
Kassahun Tamir [BX]+d16 DI BH 23
Instruction Format

Kassahun Tamir 24
Example-1
 Consider the instruction MOV BL, [BX]

 opcode 100010
 moving a byte to BL, then D = 1
 Byte is moving, W = 0

Kassahun Tamir 25
Operands Memory Operands Reg Operands

MOD 00
No Disp
Example-1
01
8-bit Disp
10
16-bit Disp
11

W=1 W=0
R/M
000 [BX]+[SI] [BX]+[SI]+d8 [BX]+[SI]+d16 AX AL

001 [BX]+[DI] [BX]+[DI]+d8 [BX]+[DI]+d16 CX CL

010 [BP]+[SI] [BP]+[SI]+d8 [BP]+[SI]+d16 DX DL

011 [BP]+[DI] [BP]+[DI]+d8 [BP]+[DI]+d16 BX BL

100 [SI] [SI]+d8 [SI]+d16 SP AH

101 [DI] [DI]+d8 [DI]+d16 BP CH

110 D16(Direct [BP]+d8 [BP]+d16 SI DH


Addressing)
111 [BX] [BX]+d8
Kassahun Tamir [BX]+d16 DI BH 26
Example-1
 Consider the instruction MOV BL, [BX]

 opcode 100010
 moving a byte to BL, then D = 1
 Byte is moving, W = 0
 MOD field will be 00
 R/M field is 111 Kassahun Tamir 27
Example-1

Kassahun Tamir 28
Example-1
 Consider the instruction MOV BL, [BX]

1 0 0 0 0 1 1 1 1 1

 opcode 100010
 moving a byte to BL, then D = 1
 Byte is moving, W = 0
 MOD field will be 00
 R/M field is 111
 REG = 011 to represent BL
Kassahun Tamir 29
Example-2
 Consider the instruction MOV SP, BX

1 1

 move either to SP or from BX


 moving a word to SP, then D = 1
 Word is moving, W = 1

Kassahun Tamir 30
Operands Memory Operands Reg Operands

MOD 00
No Disp
Example-2
Example-1
01
8-bit Disp
10
16-bit Disp
11

W=1 W=0
R/M
000 [BX]+[SI] [BX]+[SI]+d8 [BX]+[SI]+d16 AX AL

001 [BX]+[DI] [BX]+[DI]+d8 [BX]+[DI]+d16 CX CL

010 [BP]+[SI] [BP]+[SI]+d8 [BP]+[SI]+d16 DX DL

011 [BP]+[DI] [BP]+[DI]+d8 [BP]+[DI]+d16 BX BL

100 [SI] [SI]+d8 [SI]+d16 SP AH

101 [DI] [DI]+d8 [DI]+d16 BP CH

110 D16(Direct [BP]+d8 [BP]+d16 SI DH


Addressing)
111 [BX] [BX]+d8
Kassahun Tamir [BX]+d16 DI BH 31
Example-2
 Consider the instruction MOV SP, BX

1 1 1 1 0 1 1

 move either to SP or from BX


 moving a word to SP, then D = 1
 Word is moving, W = 1
 MOD field will be 11
 R/M field is 011

Kassahun Tamir 32
Example-2

Kassahun Tamir 33
Example-2
 Consider the instruction MOV SP, BX

1 1 1 1 1 0 0 0 1 1

 move either to SP or from BX


 moving a word to SP, then D = 1
 Word is moving, W = 1
 MOD field will be 11
 R/M field is 011
 REG = 100 to represent SP
Kassahun Tamir 34
Questions?

Kassahun Tamir 35

You might also like