8086-command system

The command system is divided into functions according to the

Data transmission class, arithmetic operation class, logical operation and shift class, string operation class, control transfer class, processor control (don't care about this), input and output, interrupt, etc.

data transfer instruction

Realize data transmission between CPU internal registers, between CPU and memory, and between CPU and I/O ports.

1. General Data Transfer Instructions

① General data transfer instruction MOV (8/16 bits)

Format: MOV OP destination, OP source

Require:

OP objects can be registers (except CS), memory

OP sources can be registers, memory and immediate

example:

MOV AL, BL; the content stored in BL is sent to AL

MOV SP, 2AC0H; Immediate value 2AC0H to send SP

MOV [DI], AX; 16 digits in AX are sent to DI and DI+1 unit

MOV SI, ES:[BP]; The content of the two units pointed to by BP in the additional segment is sent to the SI register.

MOV WORD PTR [SI], 6070H; The immediate value 6070H is sent to the SI word unit

What is WORD PTR? A declaration word declaration (16 bits)

There is also a BYTE statement (8 bits)

If there are registers involved in addressing, no declaration is required, if not, the type needs to be declared

Notice:

The two operands (source, destination) of the MOV instruction can use different addressing modes.

The source and destination operands must be of the same type.

It is not allowed to use an immediate value as a destination operand, nor is it allowed to send an immediate value to a segment register.

Transferring data between segment registers and memory cells is not allowed.

CS, IP registers cannot be used as destination operands.

General transfer instructions do not affect flag bits.

②Stack operation instruction

Stack: It is a memory area that works according to the "last in, first out" principle.

Stack register SS--segment address.

Stack pointer SP--always the address of the storage unit where the current top of the stack is located, that is, the address of the storage unit where the latest stacked data is located.

Push operation: PUSH OP

Function: Push the OP word data into the stack, and the result is SP-2->SP (the SP pointer is decremented each time) (only 16 bits can be pushed at a time)

so from high to low

Principle: The high byte is pressed on the high address, and the low byte is pressed on the low address.

example:

PUSSH AX

SP-1 → SP, press AH

SP-1 → SP, press AL

Implementation process:

SP⬅SP-1: [SP]⬅OPH

SP⬅SP-1: [SP⬅OPL

Pop operation: POP OP

Function: pop data from the stack→OP, result SP+2→SP

Implementation process:

OPL⬅[SP]; SP⬅SP+1

OPH⬅[SP]; SP⬅SP+1

Example: POPDX

Pop AL→DL, SP+1→SP

pop AH→DH, SP+1→SP

Notice:

·Stack operations are always performed in terms of words (16 bits).

Push instruction, SP-2, the data is at the top of the stack. Pop instruction is just the opposite.

The operand can be a memory, register or segment register operand (CS cannot be used for POP), and cannot be an immediate value.

PUSH CS POP CS ×

PUSH 1200H × POP 2300H √

·These two instructions are mainly used for context protection and recovery to ensure the normal return of subroutine calls or interrupt programs.

③Data exchange instruction (8/16 bit)

Format: XCHG OP1, OP2

Function: Realize the mutual exchange of OP1 and OP2 content.

Operand: general-purpose register or memory, but not both memory units.

Note: Segment registers and IP cannot be used as operands of swap instructions.

example:

XCHG AX, BX √

XCHG BH, BL √

XCHG AX, 1122H ×

XCHG DS, AX ×

XCHG [SI], BP √

XCHG [SI], [DI] ×

④Escape command (table lookup command, translation command)

Format: XLAT

BX storage base address, AL storage offset

Personal understanding: BX and AL are added, and the content pointed to is put into AL.

2. Target address transfer instruction

The function of this type of instruction is to send the address of the memory where the operand is located into the destination register.

Notice:

1. The OP source must be a memory operand, and the OP destination must be a 16-bit general-purpose register.

2. The address transfer instruction does not affect the status flag bit

① Take effective address EA command:

Format: LEA OP item, OP source

Function: Send the effective address EA of the source operand to the destination operand.

example:

LEA AX, [5678H]; AX⬅5678H

LEA AX, [BP+SI]; BX⬅BP + YES

② Pointer to register and DS instruction

Format: LDS OP item, OP source

Function: Take out the content of four bytes (32 bits) specified by the OP source, the two bytes of the low address → OP, the two bytes of the high address → DS.

example:

LDS DI, [2130H]; content in units 2130H and 2131H → DI; content in units 2132H and 2133H → DS.

③ Pointer to register and ES instruction

Format: LES OP Item, OP Source

Function: The operation of this instruction is basically the same as that of the LDS instruction, the difference is that the two bytes of the high address among the 4 bytes of the OP source → ES

example:

LDS DI, [2130H]; content in units 2130H and 2131H → DI; content in units 2132H and 2133H → ES.

3. Flag register transfer instruction

① Read flag command

② Set flag command

③ Stack operation instructions for flag registers

 

Supongo que te gusta

Origin blog.csdn.net/m0_59069134/article/details/126878579
Recomendado
Clasificación