8086/8088 assembly instruction Summary

Source: Internet
Author: User
Tags mul sub command

1. Data Transmission instructions;

Ii. Arithmetic commands;

Iii. logical commands;

Iv. string processing commands;

5. control transfer instructions;

6. processor control commands.

(For details, see the full text)

I. Data Transmission instructions
1. General Data Transmission commands
MOV (Move) Transfer
PUSH (Push onto the stack) to stack
POP (Pop from the stack)
XCHG (Exchange) Exchange
. MOV command
Format: mov dst, SRC
Operation: (DST) <-(SRC)
. PUSH to stack command
Format: PUSH SRC
Operation: (SP) <-(SP)-2
(SP) + 1, (SP) <-(SRC)
. POP output stack command
Format: POP DST
Operation: (DST) <-(SP + 1), (SP ))
(SP) <-(SP) + 2
. XCHG switch command
Format: XCHG OPR1, OPR2
Operation: (OPR1) <--> (OPR2)

2. Dedicated transfer commands of the Accumulators
In (input) Input
Out (output) Output
Xlat (translate) for code
This set of commands is limited to transmitting information using the accumulators ax or Al.
. In input command
Long format: in Al, port (bytes)
In ax, port (word)
Operation: (Al) <-(port) (byte)
(Ax) <-(Port + 1, Port) (word)
Short format: in Al, dx (bytes)
In ax, DX)
Operation: Al <-(dx) (bytes)
Ax <-(dx) + 1, dx) (word)
. Out output command
Long format: out port, Al (bytes)
Out port, ax (word)
Operation: (port) <-(Al) (bytes)
(Port + 1, Port) <-(ax) (word)
Short format: Out dx, Al (bytes)
Out dx, ax (word)
Operation: (dx) <-(Al) (bytes)
(Dx) + 1, (dx) <-Ax (word)
On a IBM-PC machine, an external device can have a maximum of 65536 I/O Ports, the port (that is, the peripheral port address) is 0000 ~ Ffffh. The first 256 ports (0 ~ FFH) can be directly specified in the command, which is the port in the long format. At this time, the machine command is expressed in two bytes, and the second byte is the port number. therefore, you can specify the port number in the long format, but only the first 256 ports are allowed. when the port number is greater than or equal to 256, only the short format can be used. In this case, you must first put the port number in the DX register (the port number can be from 0000 to 0 ffffh ), then use the in or out command to transmit information.
. Xlat code change command
Format: xlat OPR
Or: XLAT
Operation: (AL) <-(BX) + (AL ))

3. Send register instruction to a valid address
LEA (Load Balancing tive address) valid address send register
LDS (Load DS with Pointer) Pointer send register and DS
LES (Load ES with Pointer) Pointer to send registers and ES
. LEA valid address sending register
Format: lea reg, SRC
Operation: (REG) <-SRC
The Command sends the valid address of the source operand to the specified register.
. LDS pointer to send registers and DS commands
Format: lds reg, SRC
Operation: (REG) <-(SRC)
(DS) <-(SRC + 2)
Sends the four successive bytes specified by the source operand to the registers and DS registers specified by the instruction. This instruction usually specifies the SI register.
. LES pointer to send registers and ES commands
Format: les reg, SRC
Operation: (REG) <-(SRC)
(ES) <-(SRC + 2)
Sends the four successive bytes specified by the source operand to the registers and ES registers specified by the instruction. This instruction usually specifies the DI register.

4. Mark register transfer command
LAHF (Load AH with flags) flag to send AH
SAHF (store AH into flags) AH send sign register
PUSHF (push the flags) flag to stack
POPF (pop the flags) indicates the exit of the stack
. LAHF flag to send AH
Format: LAHF
Operation: (AH) <-(low byte of PWS)
. Sahf ah flag register
Format: SAHF
Operation performed: (low byte of PWS) <-(AH)
. PUSHF flag Stack entry
Format: PUSHF
Operation: (SP) <-(SP)-2
(SP) + 1, (SP) <-(PSW)
. POPF flag Outbound Stack
Format: POPF
Operation: (PWS) <-(SP) + 1, (SP ))
(SP) <-(SP + 2)

Ii. Arithmetic commands
1. Addition command
ADD (add) Addition
ADC (add with carry) Incoming Addition
INC (increment) plus 1
. ADD addition command
Format: add dst, SRC
Operation: (DST) <-(SRC) + (DST)
. ADC incoming bit addition command
Format: adc dst, SRC
Operation: (DST) <-(SRC) + (DST) + CF
. ADD plus 1 command
Format: INC OPR
Operation: (OPR) <-(OPR) + 1

2. subtraction commands
SUB (subtract) Subtraction
SBB (subtract with borrow) with bitwise Subtraction
DEC (Decrement) minus 1
NEG (Negate)
CMP (Compare) Comparison
. SUB subtraction command
Format: sub dst, SRC
Operation: (DST) <-(DST)-(SRC)
. SBB with borrow subtraction command
Format: sbb dst, SRC
Operation: (DST) <-(DST)-(SRC)-CF
. Dec minus 1 command
Format: Dec OPR
Operation: (OPR) <-(OPR)-1
. Neg complement command
Format: neg OPR
Operation: (OPR) <-(OPR)
. CMP comparison command
Format: CMP opr1, opr2
Operation: (opr1)-(opr2)
This command performs the subtraction operation like the sub command, but does not save the result. It only sets the condition flag based on the result.

3. Multiplication command
Mul (unsigned multiple) unsigned Multiplication
Imul (signed multiple) multiplication with signed numbers
. Mul unsigned number multiplication command
Format: Mul SRC
Operation:
Byte operands: (ax) <-(Al) * (SRC)
Operand: (dx, ax) <-(ax) * (SRC)
. Imul signed number multiplication command
Format: imul SRC
The operation is the same as Mul, but it must be a number of symbols, while Mul is an unsigned number.

4. Division commands
Div (unsigned divide) unsigned number Division
Idiv (signed divide) number Division

CBW (convert byte to word) byte conversion to word
CWD (contert word to double word) Word conversion to double word
. Div unsigned number division command
Format: div SRC
Operation:
Byte OPERATOR: (Al) <-(ax)/(SRC)
(AH) <-(ax)/(SRC) Remainder
Word operation: (ax) <-(dx, ax)/(SRC) Operator
(Ax) <-(dx, ax)/(SRC) Remainder
. Idiv signed number division command
Format: div SRC
Operation: it is the same as Div, but the operand must be a signed number. The operator and remainder are both signed numbers, and the remainder symbol is the same as the divisor symbol.
. CBW byte conversion to word instruction
Format: CBW
Operation: The content symbol of Al is extended to ah. that is, if the maximum valid bit of (Al) is 0, (AH) = 00. For example, if the maximum valid bit of (Al) is 1, (AH) = 0ffh
. CWD word conversion to dual-word command
Format: CWD
Operation: The content symbol of ax is extended to DX. That is, if the maximum valid bit of (ax) is 0, (dx) = 0; otherwise (dx) = 0ffffh.
These two commands do not affect the condition code.

Iii. Logic commands
1. Logic Operation commands
And (and) logic and
Or (OR) logic or
Not (not) logical non-
XOR (exclusive or) exclusive or
Test (test) test
. And logic and commands
Format: and DST, SRC
Operation performed: (DST) <-(DST) ^ (SRC)
. Or logic or command
Format: or DST, SRC
Operation: (DST) <-(DST) V (SRC)
. Not logical non-directive
Format: Not OPR
Operation: (OPR) <-(OPR)
. XOR exception or command
Format: xor dst, SRC
Operation performed: (DST) <-(DST) V (SRC)
. Test test command
Format: Test opr1, opr2
Operation: (DST) ^ (SRC)
The result of the two operands is not saved, and the condition code is set only based on the features.

2. Shift command
SHL (shift logical left) logic left shift
Sal (shift arithmetic left) arithmetic left shift
SHR (shift logical right) logic shifts right
SAR (shift arithmetic right) arithmetic right shift
Rol (rotate left) loop shifts left
Ror (rotate right) loop shifts right
RCL (rotate left through carry) Bring-in loop shifts left
RCR (rotate right through carry) Bring-in loop shifts right
Format: SHL opr, CNT (others are similar)
OPR can be any addressing method except the immediate number. The shift count is determined by CNT, and CNT can be 1 or Cl.
The cyclic shift command can change the positions of all bits in the operands. The shift command is often used to multiply by 2 and divide by 2. here, the arithmetic shift command applies to the number of signed operations, Sal is used to multiply 2, SAR is used to divide by 2, while the logic shift command is used to calculate the number of unsigned, SHL is used to multiply 2, and SHR is used to divide by 2.

Iv. string processing commands
1. movs, STOs, and lods commands that work with rep
. Rep repeat the string operation until (CX) = 0 is on
Format: rep String Primitive
Here, String Primitive can be movs, lods, or STOs commands.
Operation:
1) if (CX) = 0, exit rep; otherwise, execute.
2) (CX) <-(CX)-1
3) execute the string operation.
4) Repeat 1 )~ 3)
. Movs string transmission command
Format: three formats are available.
Movs DST, SRC
Movsb (bytes)
Movsw (word)
The second and third formats clearly indicate whether to transmit bytes or words. The first format indicates whether to operate in characters or bytes in the operands. For example:
Movs es: byte ptr [DI], DS: [SI]
Operation:
1) (DI) <-(SI ))
2) byte operations:
(SI) <-(SI) + (or-) 1, (DI) <-(DI) + (or-) 1
+ Is used when the direction sign is DF = 0, and-is used when the direction sign is DF = 1-
3) word operations:
(SI) <-(SI) + (or-) 2, (DI) <-(DI) + (or-) 2
+ Is used when the direction sign is DF = 0, and-is used when the direction sign is DF = 1-
This command does not affect the condition code.
. CLD (Clear direction flag) This command causes DF to be 0, and the address can be automatically increased when the serial operation command is executed;
. STD (Set direction flag) This command causes DF = 1. When executing the string operation command, the address can be automatically reduced.
. STOS storing string commands
Format: STOS DST
STOSB (bytes)
STOSW (word)
Operation:
Byte operations: (DI) <-(AL), (DI) <-(DI) +-1
Word operation: (DI) <-(AX), (DI) <-(DI) +-2
This command stores the content of AL or AX in a unit of an additional segment specified by (DI), and modifies DI content according to the value of DF and data type, when it is associated with REP, the content of AL or AX can be stored in a buffer with a length of (CX.
. LODS get instruction from string
Format: LODS SRC
LODSB
LODSW
Operation:
Byte operations: (AL) <-(SI), (SI) <-(SI) +-1
Word operation: (AX) <-(SI), (SI) <-(SI) +-2
This command sends the content of a unit in the Data Segment specified by (SI) to AL or AX, and modifies SI content according to the direction mark and data type. the command allows you to specify a non-data segment's storage zone by using a segment across the prefix. this command does not affect the condition code.
Generally, this command is not used with REP. This command can be used when a string of characters in the buffer zone needs to be obtained for testing.

2. CMPS and SCAS commands that work with REPE/REPZ and REPNZ/REPNE
. REPE/REPZ repeat string operations when equal/0
Format: REPE (or REPZ) String Primitive
Here, String Primitive can be a CMPS or SCAS command.
Operation:
1) exit when (CX) = 0 or ZF = 0 (that is, the result of a comparison is different from the two operands). Otherwise, execute
2) (CX) <-(CX)-1
3) execute the subsequent string commands
4) Repeat 1 )~ 3)
. REPNE/REPNZ repeated string operations when not equal/Not zero
Format: REPNE (or REPNZ) String Primitive
Here, String Primitive can be a CMPS or SCAS command.
Operation:
Except for exit conditions (CX = 0) or ZF = 1, other operations are identical to REPE.
. CMPS string comparison command
Format: cmp src, DST
CMPSB
CMPSW
Operation:
1) (SI)-(DI ))
2) byte operations: (SI) <-(SI) +-1, (DI) <-(DI) +-1
Word operation: (SI) <-(SI) +-2, (DI) <-(DI) +-2
Commands subtract a word (or byte) from the data segment pointed to by (SI) from a word (or byte) in the additional segment pointed to by (DI), but do not save the result, set the condition Code only based on the result. Other features of the command are the same as those of the movs command.
. SCAs string scan command
Format: SCAs DST
Scasb
Scasw
Operation:
Byte operations: (Al)-(DI), (DI) <-(DI) +-1
Word operation: (Al)-(DI), (DI) <-(DI) +-2
This command compares the content of Al (or ax) with a byte (or word) specified by (DI) in the append segment. It does not save the result and only sets the condition code based on the result. other features of the command are the same as those specified by movs.

V. Transfer control instructions
1. Unconditional Transfer Instruction
. JMP (JMP) jump command
1) Direct Short transfer within a segment
Format: JMP short OPR
Operation: (IP) <-(IP) + 8-bit displacement
2) Direct near transfer within the segment
Format: JMP near PTR OPR
Operation: (IP) <-(IP) + 16-bit displacement
3) indirect transfer within the segment
Format: JMP word PTR OPR
Operation: (IP) <-(EA)
4) Inter-segment direct (remote) Transfer
Format: JMP far PTR OPR
Operation: (IP) <-OPR's intra-segment offset address
(CS) <-segment address of the OPR
5) Indirect inter-segment Transfer
Format: JMP DWORD PTR OPR
Operation: (IP) <-(EA)
(CS) <-(EA + 2)
2. conditional transfer instruction
1) Transfer Based on the setting of a single condition flag
. If the result of JZ (or je) (jump if zero, or equal) is zero (or equal), the transfer
Format: je (or JZ) OPR
Test Conditions: ZF = 1
. Jnz (or JNE) (jump if not zero, or not equal) results are not zero (or not equal), the transfer
Format: jnz (or JNE) OPR
Test condition: ZF = 0
. Js (jump if sign) results in negative transfer
Format: JS OPR
Test Conditions: Sf = 1
. JNS (jump if not sign) results in regular transfer
Format: JNS OPR
Test condition: SF = 0
. JO (Jump if overflow) overflow is transferred
Format: JO OPR
Test Conditions: OF = 1
. JNO (Jump if not overflow) is transferred without overflow
Format: JNO OPR
Test Conditions: OF = 0
. JP (or JPE) (Jump if parity, or parity even) if the parity is 1, the transfer
Format: JP OPR
Test Conditions: PF = 1
. If the parity of JNP (or JPO) (Jump if not parity, or parity odd) is 0
Format: JNP (or JPO) OPR
Test condition: PF = 0
. JB (or JNAE, JC) (Jump if below, or not abve or equal, or carry) is lower than, or not higher than or equal to, or transfer if the carry bit is 1
Format: JB (or JNAE, JC) OPR
Test Conditions: CF = 1
. JNB (or JAE, JNC) (Jump if not below, or abve or equal, or not carry) is not lower than, or higher than or equal to, or transfer if the carry bit is 0
Format: JNB (or JAE, JNC) OPR
Test Conditions: CF = 0
2) compare two unsigned numbers and transfer them based on the comparison results
. JB (or JNAE, JC)
Format: Same as above
. JNB (or JAE, JNC)
Format: Same as above
. JBE (or JNA) (Jump if below or equal, or not above) is less than or equal to, or not higher than the transfer
Format: JBE (or JNA) OPR
Test condition: CFVZF = 1
. JNBE (or JA) (Jump if not below or equal, or above) is not lower than or equal to, or higher than the transfer
Format: JNBE (or JA) OPR
Test condition: CFVZF = 0
3) compare two signed numbers and transfer them based on the comparison results.
. JL (or LNGE) (Jump if less, or not greater or equal) is smaller than or equal
Format: JL (or JNGE) OPR
Test Conditions: SF V OF = 1
. JNL (or JGE) (Jump if not less, or greater or equal) is not smaller than, or greater than or equal to transfer
Format: JNL (or JGE) OPR
Test Conditions: SF V OF = 0
. JLE (or JNG) (Jump if less or equal, or not greater) is smaller than or equal to, or not greater
Format: JLE (or JNG) OPR
Test conditions: (SF V OF) VZF = 1
. JNLE (or JG) (Jump if not less or equal, or greater) is not smaller than or equal to or greater
Format: JNLE (or JG) OPR
Test conditions: (SF V OF) VZF = 0
4) if the CX value is 0, the transfer command
. JCXZ (Jump if CX register is zero) if the content of the CX register is zero, transfer
Format: JCXZ OPR
Test conditions: (CX) = 0
Note: The transfer condition is 8-bit short jump!

3. Cyclic commands
. LOOP command
Format: LOOP OPR
Test conditions: (CX) <> 0
. LOOPZ/LOOPE loop command when zero or equal
Format: LOOPZ (or LOOPE) OPR
Test conditions: (CX) <> 0 and ZF = 1
. LOOPNZ/LOOPNE loop command when not zero or not equal
Format: LOOPNZ (or LOOPNE) OPR
Test conditions: (CX) <> 0 and ZF = 0
The steps for these three commands are:
1) (CX) <-(CX)-1
2) check whether the test conditions are met. If yes, the (IP) <-(IP) + D8 symbol is expanded.

4. subroutine
. CALL command
. RET return command
5. interrupted
. Int command
Format: int type
Or int
Operation: (SP) <-(SP)-2
(SP) + 1, (SP) <-(psw)
(SP) <-(SP)-2
(SP) + 1, (SP) <-(CS)
(SP) <-(SP)-2
(SP) + 1, (SP) <-(IP)
(IP) <-(type * 4)
(CS) <-(type * 4 + 2)
. Into is interrupted if overflow occurs.
Operation: If of = 1:
(SP) <-(SP)-2
(SP) + 1, (SP) <-(psw)
(SP) <-(SP)-2
(SP) + 1, (SP) <-(CS)
(SP) <-(SP)-2
(SP) + 1, (SP) <-(IP)
(IP) <-(10 h)
(CS) <-(12 h)
. Iret returned instruction from interruption
Format: iret
Operation: (IP) <-(SP) + 1, (SP ))
(SP) <-(SP) + 2
(CS) <-(SP) + 1, (SP ))
(SP) <-(SP) + 2
(PSW) <-(SP) + 1, (SP ))
(SP) <-(SP) + 2

6. processor control commands
1. Mark Processing Command
. CLC carry position 0 command (Clear carry) CF <-0
. CMC carry bit reverse command (Complement carry) CF <-Cf
. STC carry position 1 command (Set carry) CF <-1
. CLD direction Flag Set 0 command (Clear direction) DF <-0
. STD direction Flag Set 1 command (Set direction) DF <-1
. CLI interrupt Flag Set 0 command (Clear interrupt) IF <-0
. STI interrupt Flag Set 1 command (Set interrupt) IF <-0
2. Other processor control commands
NOP (No Opreation) No operation
HLT (Halt) stopped
WAIT Wait
ESC (Escape) code exchange
LOCK (Lock) block
These commands can control the processor status, which does not affect the condition codes.
. NOP no operation command
This command does not execute any operation, and its machine code occupies one byte. During program debugging, this command often occupies a certain storage unit, so that it can be replaced by other commands during formal operation.
. HLT Stop command
This command can suspend the machine and shut down the processor to wait for an external interruption. After the interruption ends, you can continue to execute the following program.
. WAIT command
This command puts the processor in a idling state. It can also be used to WAIT for external interruptions, but the WAIT command is still returned after the interruption ends.
. ESC code change command
Format: ESC mem
Mem indicates a storage unit, and the ESC Command sends the content of the storage unit Data Bus. of course, the ESC command does not allow immediate count and register addressing. when using Coprocessor to execute some operations, this command can be directed to the instruction or operand from the memory. A coprocessor (such as 8087) is a hardware that can be selected to increase the speed.
. LOCK blocking command
This command is a prefix that can be combined with other commands to maintain the bus lock signal until the execution of the commands associated with it is complete. when the CPU and Other Processors work together, this command can avoid damaging useful information.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.