Home  >  Article  >  What are the addressing modes of memory operands?

What are the addressing modes of memory operands?

青灯夜游
青灯夜游Original
2020-07-28 14:24:4916320browse

The addressing modes of memory operands are: direct addressing, register indirect addressing, register relative addressing, base index index addressing, and base index index relative addressing.

What are the addressing modes of memory operands?

Addressing mode of memory operands

TIPS:

♥The object operated by the instruction is in the memory, and its expression is [ ]

♥ The instruction gives the offset address of the operation object in a certain logical segment of the memory: [offset address]

♥The segment base address of the logical segment is given by default or reset

♥The word length of the memory operand itself is not determined , whose word length depends on another register operand, or the word length is specified in other ways

1. Direct addressing

The instruction directly gives the offset address of the operand

eg: MOV AX,[1200H]; Store the content of the data segment 1200H in AL, 1201H The content is stored in AH

In direct addressing mode, the operand defaults to the data segment, but segment reset is allowed, that is, the logical segment is given by the instruction

eg: MOV AX,ES:[1200H]; Store the content of the additional segment 1200H in AL, and the content of 1201H in AH.

Personal understanding :

Adding [ ] means that you need to find the address somewhere other than the register. At this time, you should first consider which segment of the memory, and then directly find the address given in this segment. Location. Generally speaking, the default is the data segment.

2. Register indirect addressing

The operand is stored in the memory, and the offset of the data in the memory is The shift address is the content of the general register in square brackets [ ].

Four general-purpose registers are commonly used (these four registers are also called indirect address registers, namely BX, BP, SI, and DI), which can be used to store the offset address of data. (Indirect address registers are divided into base address registers BX, BP and index registers SI, DI)

General format of indirect addressing:

eg: MOV BX,1200H; This is immediate addressing, that is, the operand is sent directly to BX. At this time, BX=1200H

MOV AX,[BX]; Here is [BX] =[1200H], so it is converted into direct addressing, but with the addition of BX as an intermediate agent. At this time, the content of the unit with the offset address of 1200H in the code segment is assigned to AL, and the content of the unit 1201H is assigned to AH

Indirect addressing is to indirectly give the offset address of the operand through the register

The segment address of the operand (which segment the operand is in) depends on Which indirect address register to choose (can be reset by segment)

BX, SI, and DI are in the data segment by default; BP is in the stack segment by default

Personal understanding:

We can find the corresponding segment through the selected indirect address register, and then find the physical location through the offset of the segment. When addressing indirectly, we can find the physical location of the source operand.

Physical location=segment base address*16 offset address.

3. Register relative addressing

The offset address of the operand is the content of the register plus one Displacement amount

eg: MOV AX,2000H ; Immediate addressing, assign 2000H to AX

MOV DS,AX ; DS is obtained from AX Segment head address

MOV BX,1200H; Immediate addressing, assign 1200H to BX

MOV AL,[BX]5; Relative addressing, the segment base address is 2000H, offset The content of the shift amount of 1200H 5 is assigned to AL

Relative addressing is mainly used for one-dimensional array operations

The displacement is often used as a table The header address and the value of the indirect address register are used as the relative address in the table (there will be constants between uses, which will be inconvenient)

Personal understanding:

Relative addressing adds a displacement constant on the basis of indirect addressing. Therefore, the way to determine whether it is indirect addressing or relative addressing is: see if there are constants before and after the indirect address register. If there are constants, it is relative addressing

4. Base address indexed addressing

The offset address of the operand is :

The contents of a base address register (BX, BP) and the contents of an index register (SI, DI)

BX defaults to the data segment and BP defaults to the stack segment

The segment address of the operand is determined by the selected base address register

Same as relative addressing, mainly used for one-dimensional array operations

eg: MOV SI,1100H; Immediate addressing, assign 1100H to SI

MOV BX,SI; Assign 1100H to BX

MOV AX,[SI BX] ;The physical address of the source operand = data segment base address*16 1100H 1100H

Personal understanding:

Base address indexed addressing is to first find the first address of the segment where the base register is located, and then add the offset of the base register and the offset of the index register. Its characteristics are that [BX][BP] must be one of the two, [SI][DI] must be one of the two

5. Base address Indexed relative addressing

The offset address of the operand is :

Base address register Index register displacement amount

The segment address of the operand is determined by the selected base address register

The base address index relative addressing mode is mainly used for the operation of two-dimensional arrays

eg: MOV DI,1100H ; Immediate addressing, assign 1100H to DI

MOV BP,DI ; Assign 1100H to BP

MOV AL,[BP][DI]5; BP indicates that the operand is in the stack segment, and its physical address = stack segment segment base address*16 1100H 1100H 5

Personal understanding:

Base index relative addressing only adds a constant offset to the base index, and the physical address of the source operand can be grasped from this.

For more related knowledge, please visit: PHP Chinese website!

The above is the detailed content of What are the addressing modes of memory operands?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn