Microprocessors & Assembly Language Lesson 4 (Addressing Modes in 8086 Programming)

Prepared by: Assist. Lect. Omar Haitham Alhabieb Microprocessors & Assembly Language Lesson 4 (Addressing Modes in 8086 Programming)  When the micr...
11 downloads 0 Views 395KB Size
Prepared by: Assist. Lect. Omar Haitham Alhabieb

Microprocessors & Assembly Language Lesson 4 (Addressing Modes in 8086 Programming)

 When the microprocessor executes an instruction, it performs the specified function on data.  These data called operands, may be part of the instruction, may reside in one of the internal registers, may be stored at an address in memory, or may be held at an I/O port.  To access these different types of operands, the 8086 provided with various addressing modes.

The addressing modes are categorized in to the following types: 1. Immediate Operand Addressing Mode. 2. Register Operand Addressing Mode. 3. Memory Operand Addressing Mode: a. Direct Addressing Mode. b. Register Indirect Addressing Mode. c. Index Addressing Mode. d. Based Addressing Mode. e. Based & Index Addressing Mode. f. Based & Index with Displacement Addressing Mode.

1

Prepared by: Assist. Lect. Omar Haitham Alhabieb

Immediate Operand Addressing Mode  If an operand is part of the instruction instead of the content of a register or a memory location, it represents what is called an immediate operand and is accessed using the immediate addressing mode. Example: Write an instruction that will move the immediate value 1234h into the CX register. Solution: The instruction must use immediate operand addressing for the source operand and register operand addressing for the destination operand: MOV

CX, 1234H

Immediate Operand Addressing Mode Samples:

2

Prepared by: Assist. Lect. Omar Haitham Alhabieb

Register Operand Addressing Mode  In this mode, the operand to be accessed is specified as residing in an internal register of the 8086.  Both source and destination operands are internal registers. Example: Write an instruction that will move the contents of DX register to the CX register. Solution: The instruction must use register operand addressing for the source operand and register operand addressing for the destination operand: MOV

CX, DX

Register Operand Addressing Mode Samples:

3

Prepared by: Assist. Lect. Omar Haitham Alhabieb

Direct Addressing Mode  This mode is similar to immediate addressing in that information is encoded directly into the instruction. However, in this case the instruction opcode is followed by an effective address, instead of the data. Example: Write an instruction that will move the contents of memory location (1230) to the AX register. Solution: The instruction must use memory location for the source operand and register operand addressing for the destination operand: MOV

AX, [1230h]

Direct Addressing Mode Samples:

4

Prepared by: Assist. Lect. Omar Haitham Alhabieb

Register Indirect Addressing Mode  This mode is similar to the direct addressing in that an effective address is combined with the contents of DS to obtain a physical address.  However, it differs in the way of offset is specified such that EA (Effective Address) resides in either a base register or in an index register.  The base register can be either base register (BX) or base pointer register (BP), and the index register can be source index register (SI) or destination index register (DI).

Register Indirect Addressing Mode Samples:

5

Prepared by: Assist. Lect. Omar Haitham Alhabieb

Index Addressing Mode  This mode uses the value of the displacement as a pointer to the starting point of an array of data in memory and the contents of the specified register as an index that selects the specific element in the array to be accessed.

Index Addressing Mode Samples

6

Prepared by: Assist. Lect. Omar Haitham Alhabieb

Based Addressing Mode In this mode, the effective address of operand is obtained by adding a direct or indirect displacement to the contents of either base register (BX) or base pointer register (BP).

Based Addressing Mode Samples:

7

Prepared by: Assist. Lect. Omar Haitham Alhabieb

Based & Index Addressing Mode  Combining the based addressing mode and the indexed addressing mode results in new, more powerful mode known as based-indexed addressing mode.  This mode can be used to access complex data structures such as two dimensional array.

Based & Index Addressing Mode Samples:

8

Prepared by: Assist. Lect. Omar Haitham Alhabieb

Based & Index with Displacement Addressing Mode This mode is similar to Based & Index Addressing Mode with adding a displacement value. Based & Index with Displacement Addressing Mode Samples:

9

Suggest Documents