8086CPU-instruction operation addressing mode

command format

Instructions: Commands that instruct a computer to perform specific actions

Instruction system: It is a collection of all commands that the computer can execute. It depends on the hardware design of the computer. The instruction system varies from machine to machine, and there is no universality. (Portability)

Instruction format: opcode [operand], [operand] Correspondence: what kind of operation is performed Destination operand (data formed after instruction processing) Source operand (data before instruction processing)

The operand characterization method in the instruction: characterizes the data itself participating in the operation -> the address where the immediate data represents the data storage: registers and memory

operand type

Immediate operands:

Indicates the data itself that participates in the operation, which can be 8 or 16 bits

example:

MOV AX, 1234H; 1234H data is sent to AX

MOV BL, 22H; 22H data transfer to BL

The immediate value cannot be used as the target operand, it can be an impossible number or a signed number, and its value should be within the acceptable range.

Register operands:

Indicates that the number participating in the operation is stored in the register given by the instruction, which can be 16 bits or 8 bits. (Must correspond to the length)

example:

MOV AX, BX

MOV DL, CH

Memory operands:

Indicates that the number currently participating in the operation is stored in one or two units of the memory.

example:

MOV AX, [1200H] Transfer the data of unit 1200H to AL and AX, which is 16-bit data

MOV AL, [1200H] Transfer the data of unit 1200H to AL, which is 8-bit data

Instruction word length and instruction execution speed:

The instruction word length is determined by the length of the opcode, the address length of the operand, and the number of operands.

8088/8086cpu adopt variable word length instruction format.

The word length of an instruction affects the execution speed of the instruction.

The instruction execution time varies for different operands.

(slow) memory -> immediate data -> registers (fast)

addressing mode

The addressing mode of the instruction is the way to find the address of the instruction operand

address immediately

example:

MOV AX, 36H; immediate value 364H is sent to AX

The immediate value is in the code segment.

Note: Immediate addressing mode can only be used for source operands, mainly for register assignment

Immediate addressing mode does not execute bus cycle, execute speed block.

register addressing

The operand is placed in the register, the name of a register is directly given by the instruction, and the contents of the register are used as the operand.

Registers can be 16-bit AX, BX, CS.....or 8-bit AH, AL, BH... registers

example:

MOV AX, CX

DECEMBER

Notice:

The instruction operation of the register addressing mode is executed inside the CPU, does not need to execute the bus cycle, and the execution speed is fast.

The register addressing mode is applicable to both the source operand and the destination operand of the instruction, and can be used for both the source operand and the destination operand.

Direct addressing (directly give the offset address)

The operand is in the memory, and the effective address EA of the storage unit where the operand is located is directly given in the instruction, that is, the offset address within the segment, indicating the number of bytes from the first address of the segment where the storage unit where the operand is located. The effective address is an unsigned 16-bit binary number.

example:

MOV AH, [2100H] Send the content of unit 2100H in the DS segment to AH

MOV AX, [2100H] The content of unit 2100H in the DS segment is sent to AL; the content of unit 2100H is sent to AH.

MOV [1000H], AH; Send AH to the unit whose offset address is 1000H.

Low address saves status, high address saves high position

Notice:

The segment address of the storage unit where the operand of the direct addressing mode is located is generally in the data segment register DS.

If the operand is in another segment, the segment register name corresponding to the segment beyond the prefix needs to be used in the instruction.

Adding an ES in front indicates that the physical address is found through ES instead of the default DS

register indirect addressing

The operand is in the memory, and the content of the register in the instruction is used as the effective address EA (offset address) of the storage unit where the operand is located. The register is limited to BX, BP, SI, DI.

When using BX, SI, DI, the segment address of the storage unit where the operand is located is stored in the data segment register DS

When using BP, the segment address of the storage unit where the operand is located is stored in the stack segment register SS.

Notice:

Only SI, DI, BX, BP can be used as indirect address registers

If the storage unit where the operand is located is no longer in the data segment DS, it is necessary to use the segment override prefix in the instruction to indicate the segment name of the segment where it is located

base addressing

The operand is in the memory, and the sum of the contents of the register (BX or BP) in the instruction and the displacement specified by the instruction is used as the effective address EA (offset address) of the storage unit where the operand is located

When using BX, the segment address is the content of DS;

When using BP, the segment address is the content of SS.

indexed addressing

Same as base addressing, but using index registers.

base plus index addressing

The operand is in the memory. The instruction adds the offset (8 bits or 16 bits) to the sum of the contents of the base register BX, BP and the index register SI, DI to obtain the effective address EA of the storage unit where the operand is located.

Only one base register can be used, and only one index register can be used.

When using BX, the segment register is DS

When using BP, the segment register is SS

Example: MOV AX, [BP + SI];

Physical address=SSx16+BP+SI

string addressing

It is used for string operation instructions. It is stipulated that the content of the index register SI is the intra-segment offset address of the source data string, and the content of the index register DI is the intra-segment offset address of the target data string.

I/O port addressing (independent addressing)

Finding the port address of the input and output device can be divided into direct port addressing and indirect port addressing.

Direct port addressing: The port address of the I/O device is directly given by the command, which stipulates that the port address is 8 bits and can address 256 ports.

Indirect port addressing: The port address of the I/O device is given by DX. Since DX is 16 bits, indirect port addressing can address up to 64K ports.

example:

IN AL, 20H; Read the contents of the peripheral with address 20H into AL.

OUT DX, AL; The content in AL is output to the peripheral with the content of DX as the address.

implicit addressing:

The address of one or two operands implied by the instruction, that is, the operand is in the default address.

example:

AAA; Perform decimal addition adjustment on the contents of AL, and put the adjusted result into AH and AL. The implicit operands of this instruction are AH and AL.

Guess you like

Origin blog.csdn.net/m0_59069134/article/details/126853036