1. Addressing now
The immediate addressing method is used to represent constants. It is mainly used to assign initial values to registers. Note: it can only be used for source operand fields, but not for destination operand fields.
Example 1 mov Al, 5
2. Direct addressing
In the ibm pc, the offset address of the operand is called the valid address ea. In direct addressing mode, the valid address EA is in the instruction. It is stored after the instruction operation code in the code segment, but the operand is generally stored in the data segment. Therefore, you must first find the physical address of the operand, then access the memory to obtain the operand.
If the operand is in the data segment, the physical address is 16d × (DS) Ten ea. In the 1bmp machine, data is allowed to be stored in other segments than the data segment. In this case, specify the segment to span the prefix in the command. When calculating the physical address, use the specified segment register.
Example 4 mov ax, [2000 H]
(DS) = 3000 h, if the value in address 32000h is 3050h, the execution result is; (ax) = 3050 H
The actual mov ax content is 16d * (DS) + 2000 h = 32000 H
In assembly language instructions, you can use a symbolic address to replace a numeric address, for example:
MoV ax, Value
In this case, vaiue is the symbolic address that stores the operand unit. For example
MoV ax, [value]
The two are equivalent. If the value is in an additional segment, you should specify the segment across prefix as follows;
MoV ax, ES: Value
Or mov ax, ES: [value]
The direct addressing method is suitable for processing a single variable. For example, you need to process a variable stored in the memory. You can use the direct addressing method to obtain the variable into a register and then process it.
Ibm pc requires that, in addition to the immediate number, an operand must use the register method. This is also why constants are often sent to registers.
3. Indirect Register address
The valid address of the operand is in the base register BX, BP, or the variable register Si, Di, And the operand is in the memory, as shown in.
A. if the registers specified in the instruction are BX, Si, and Di, the operands are in the Data Segment (DS), so the content of the DS register is used as the segment address, that is, the physical address of the operand is:
Physical address = 16D × (DS) Ten (BX)
Or physical address; 16 D × (DS) Ten (SI)
Or physical address = 16D × (DS) Ten (DI)
B. If the SP register is specified in the instruction, the operand is in the stack segment (SS) and the segment address is in the SS. Therefore, the physical address of the operand is:
Physical address = 16D X (SS) Ten (SP)
MoV ax, [BX]
If (DS) = 2000 h, (BX) = 1000 h, then
Physical address = 16D X (DS) Ten (BX) = 20000 H + 1000 h = 21000 H
If the content in the 21000h address is 50a0h, the execution result is: (ax) = 50a0h
C. The command can also specify a segment that spans the prefix to retrieve data from other segments. For example;
MoV ax, ES: [BX]
This addressing method can be used for table processing. After executing a command, you only need to modify the register content to retrieve the next item in the table.
4. Register relative addressing
The valid address of an operand is the sum of the content of a base address or address change register and the 8-or 16-bit displacement specified in the instruction. That is
| (BX)
Ea = | (BP) + displacement of 8 or 16 bits
| (SI)
| (DI)
Same as register addressing, bx bp Di. If no segment spans the prefix, the physical address is = 16D × (DS) + displacement + *
SP physical address = 16D X (SS) Ten (SP) + displacement + *
For example:
MoV ax, Count [Si] (can also be expressed as mov ax, [coukt ten Si]
Here, count is the 16-bit displacement symbol address.
If (DS) = 3000 h, (SI) = 2000 h COUNT = 3000 h
Then the physical address = 30000 ten 2000 Ten 3000 = 35000 H
5. Address Change Addressing Method
The valid address of an operand is the sum of the content of a base address register and a change register. Both registers are specified by the instruction. If the base address register is BX, the segment register uses Ds. If the base address register is BP, the segment register uses SS. Therefore, the physical address is:
= 16D * DS + (BX) + Si (or DI)
= 16D * ss + (BP) + Si (or DI)
6. Address Change Addressing Method
The valid address of the operand is the content of a base address register and an address change register and the 8-or 16-bit displacement.
And. Similarly, when the base address register is BX, the DS segment register is used; when the base address register is BP, the SS segment register is used. Therefore, the physical address is:
= 16D * DS + bx + Si + displacement (8-bit or 16-bit)
= 16D * ss + bp + Si + displacement (8 or 16 bits)
Planing mov ax, mask [BX] [Si]
(It can also be written as m0v ax, mask [dx ten Si]
Or mov ax. [mask ten BX ten Si])
For example, (DS) = 3000 h, (BX) = 2000 h, (SI) = l000h, mask = 0250 H,
Then the physical address is 16d X (DS) Ten (BX) Ten (SI) Ten masks.
= 30000 ten 2000 Ten 1000 ten 0250
= 33250 H