Addressing Modes
Addressing Modes
1 Register Addressing Modes Register operands are the easiest to understand. Consider the following forms of the mov instruction:
mov mov mov mov mov mov ax, dl, si, sp, dh, ax, bx al dx bp cl ax ;Copies the value from ;Copies the value from ;Copies the value from ;Copies the value from ;Copies the value from ;Yes, this is legal! BX AL DX BP CL into into into into into AX DL SI SP DH
The only restriction is that both operands must be the same size. 2 The Displacement Only (or direct)Addressing Mode The displacement-only addressing mode consists of a 16 bit constant that specifies the address of the target location. The instruction mov al,ds:[8088h] loads the al register with a copy of the byte at memory location 8088h. Likewise, the instruction mov ds: [1234h],dl stores the value in the dl register to memory location 1234h:
3 The Register Indirect Addressing Modes It access memory indirectly through a register using the register indirect addressing modes. There are four forms of this addressing mode on the 8086, best demonstrated by the following instructions:
mov mov mov mov al, al, al, al, [bx] [bp] [si] [di]
The The
and [di] modes use the ds segment by default. addressing mode uses the stack segment (ss) by default.
You can use the segment override prefix symbols if you wish to access data in different segments. The following instructions demonstrate the use of these overrides:
mov mov mov mov al, al, al, al, cs:[bx] ds:[bp] ss:[si] es:[di]
Intel refers to [bx] and [bp] as base addressing modes and bx and bp as base registers (in fact, bpstands for base pointer). Intel refers to the [si] and [di] addressing modes as indexed addressing modes (si stands for source index, di stands for destination index). However, these addressing modes are functionally equivalent.
4 Indexed Addressing Modes The indexed addressing modes use the following syntax:
mov mov mov mov al, al, al, al, disp[bx] disp[bp] disp[si] disp[di]
If bx contains 1000h, then the instruction mov cl,20h[bx] will load cl from memory location ds:1020h. Likewise, if bp contains 2020h, mov dh,1000h[bp] will load dh from location ss:3020. The The
[bx], [si], [bp]
and [di] modes use the ds segment by default. addressing mode uses the stack segment (ss) by default.
You may substitute si or di in the figure above to obtain the [si+disp] and [di+disp] addressing modes. 5 Based Indexed Addressing Modes