Addressing Modes of 8086
Addressing Modes of 8086
(contd)
Scaled-index addressing:
MOV EDX,[EAX+4*EBX]
Register Addressing
It is the most common form and is the easiest to apply Microprocessor contains 8-bit, 16-bit, 32-bit registers
Never mix an 8-bit register with a 16-bit register, 16-bit register with a 32-bit register, etc., because this results in an error when assembled
Table 3.1 shows many variations of register move instructions Fig.3.3 shows the operation of the MOV BC,CX instruction
Register Addressing
Example 3.1 shows a sequence of assembled instructions that copy various data between 8-, 16-, and 32-bit registers
Immediate Addressing
The term immediate implies that the data immediately follow the hexadecimal opcode in the memory
Immediate are constant data The MOV immediate instruction transfers a copy of the immediate data into a register or a memory location
Fig.3.4 shows the source data (sometimes preceded by #) overwrite the destination data
The instruction copies the 13456H into register AX
Register Addressing
Example 3.2 shows various immeidate instructions in a short program that placess a 0000H into the 16-bit registers AX, BX, CX
Data segment is used by default with register indirect addressing or any other addressing mode that uses BX, DI, or SI to address memory
If register BP addresses memory, the stack segment is used by default
Indirect addressing allows a program to refer to a tabular data located in the memory system (Fig.3.7 & Example 3.6)
Base-Plus-Index Addressing
It indirectly addresses memory data
In 8086 - 80286, this use a base register (BP or BX, holds the beginning location of a memory array) and an index register (DI or SI, ) to indirectly addresses memory In 80386 and above, this type of addressing allows the combination of any two 32-bit extended registers except #SP
MOV DL, [EAX+EBX]
Figure 3.8 shows the sample instruction of locating data with this scheme
The major use of this type of addressing is to address elements in a memory array
Fig.3.9 shows the use of BX (base) and DI (index) to access an element in an array of data) Study Table 3.6 and Example 3.7 as well
The displacement can be a number added to the register within the [ ], as in MOV AL,[DI+2], or it can be a displacement substracted from the register, as in MOV AL,[SI-1]
It is possible to address array data with register relative addressing such as one does with base-plus-index addressing
See Fig.3.11 and study the example 3.8
Scaled-Index Addressing
This type of addressing is unique to the 80386 - Pentium Pro
It uses two 32-bit registers (a base register and an index register) to access the memory The second register (index) is multiplied by a scaling factor (either 1X, 2X, 4X, or 8X) MOV AX,[EDI+2*ECX] See Example 3.10 and Table 3.9
Data Structures
A data structure is used to specify how information is stored in a memory array; it can be quite useful with application that use arrays
The start of a structure is identified with the STRUC directive and ended with the ENDS See Example 3.11
When data are addressed in a structure, use the structure name and the field name to select a field from the structure (Example 3.12)