| Reg-32 |
Reg-16 |
High |
Low |
Name |
| EAX |
AX |
AH |
AL |
Accumulator |
| EBX |
BX |
BH |
BL |
Base |
| ECX |
CX |
CH |
CL |
Counter |
| EDX |
DX |
DH |
DL |
Data |
| Reg-32 |
Reg-16 |
Name |
| ESI |
SI |
Source Index |
| EDI |
DI |
Destination Index |
| EBP |
BP |
Stack Frame Base Pointer |
| ESP |
SP |
Stack Pointer |
| Reg |
Name |
| CS |
Code Segment |
| DS |
Data Segment |
| ES |
Extra Segment |
| FS |
Extra Segment |
| GS |
Extra Segment |
| SS |
Stack Segment |
| Reg |
High |
Low |
Name |
| AX |
AH |
AL |
Accumulator |
| BX |
BH |
BL |
Base |
| CX |
CH |
CL |
Counter |
| DX |
DH |
DL |
Data |
| Reg |
Name |
| SI |
Source Index |
| DI |
Destination Index |
| BP |
Stack Frame Base Pointer |
| SP |
Stack Pointer |
| Reg |
Name |
| CS |
Code Segment |
| DS |
Data Segment |
| ES |
Extra Segment |
| SS |
Stack Segment |
| Addressing modes |
Example Instruction |
When used |
| Register |
Add EAX, EBX |
When a value is in a register |
| Immediate |
Add EDX, #3 |
For constants |
| Based |
Add EDX, Array(EAX+4) |
Accessing array elements |
| Indexed | Add EDX, Array(EAX*2) |
Accessing array elements |
| Based-Indexed |
Add EAX, (ESP + EDX) |
Useful in array addressing: |
| Direct |
Add EAX, (1001) |
Useful in accessing static data |
| Example | Source | Result |
| mov ax, 1234h | Immediate Constant | Copy an immediate (constant) value to a register. You cannot move immediate values to segment registers. |
| mov ax, Variable | Absolute Address | Copy the contents of a variable at an absolute address to a register. You can copy from memory to segment registers. |
| mov ax, bx | Rigester Direct | Copy the contents of one register to another. You can copy between any two registers except segment registers. |
| mov ax, [bx] | Register Indirect | Copy from the near address pointed to by the BX register to AX. In 16-bit programs, as you can see in the above formula you can only use base (BX or BP) or index (SI orDI) registers to address memory. |
| mov ax, [bx+2] | Base Relative | Copy from an indirect address plus an offset. The memory address is the sum of the register plus the immediate value. |
| mov ax, [si+bx] | Based-Indexed | Address calculations can use either base register (BX or BP) plus an index register (SI or DI). You cannot combine two base registers or two index registers |
| mov ax, [si+bx+2] | Based-Indexed Relative | Copy from memory using a base, index and offset value. |
| Mode |
Description |
Assembler Syntax |
| Absolute Offset |
offset |
exp |
| Register Indirect |
abase |
reg |
| Register Indirect with Offset |
abase+offset |
expression(reg) |
| Register Indirect with Index |
abase+(index*scale) |
(reg)[reg*scale] |
| Register Indirect with Index and Displacment |
abase+(index*scale)+displacment |
exp (reg)[reg*scale] |
| Index with Displacment |
(index*scale)+displacment |
exp[reg*scale] |
| IP with Displacment |
IP+displacment+8 |
exp(IP) |
