Basic assembly instruction set

Source: Internet
Author: User
Tags integer division

Assembly Instruction Set

1. General Data Transmission commands

MoV transfers words or bytes.
Movsx first extends the symbol and then transmits it.
Movzx is not extended before transmission.
Push pushes words into the stack.
Pop pops up the word stack.
Pusha pushes ax, CX, dx, BX, SP, BP, Si, di into the stack in sequence.
Popa pops up the stack of DI, Si, BP, SP, BX, dx, CX, and ax in sequence.
Pushad pushes eax, ECx, EDX, EBX, ESP, EBP, ESI, and EDI to the stack in sequence.
Popad pops up the stacks of EDI, ESI, EBP, ESP, EBX, EDX, ECx, and eax in sequence.
Bswap swap the byte order in 32-bit registers
Xchg exchange word or byte. (at least one * operator is a register, and segment register cannot be * operator)
Cmpxchg compare and switch * counts. (The second X counts must be the accumulators Al/ax/eax)
Xadd is exchanged first and then accumulated. (The result is in the first X number)
Xlat byte lookup conversion.
BX points to the starting point of a 256-byte table. Al indicates the index value of the table (0-255, that is, 0-ffh). The result of Al is returned as the table query result. ([bx + Al]-> Al)

2. input and output port transfer command.

In I/O port input. (Syntax: In accumulators, {port number │ DX })
Out I/O port output. (Syntax: out {port number │ DX}, accumulators)
The input and output ports are scheduled in the immediate mode. The value range is 0-255. The value range is 0-65535.

3. Destination Address Transfer command.

Load Lea to a valid address.
Example: lea dx, string; Save the offset address to DX.
LDS transfers the target pointer and loads the pointer content into DS.
For example: lds si, string; Save the segment address: Offset address to DS: SI.
LES transfers the target pointer and loads the pointer content into ES.
For example, les di and string; Save the segment address: Offset address to ESDI.
LFS transfers the target pointer and loads the pointer content into FS.
For example: lfs di, string; Save the segment address: Offset address to FSD.
LGS transfers the target pointer and loads the pointer content into GS.
For example: lgs di, string; Save the segment address: Offset address to GSDI.
The LSS transfers the target pointer and loads the pointer content to the SS.
For example: lss di, string; Save the segment address: Offset address to SSDI.

4. Mark transfer command.

Transmit the LAHF flag register and load the flag into AH.
Send the SAHF flag register and load the AH content into the flag register.
PUSHF marks the inbound stack.
POPF marks the exit of the stack.
PUSHD 32-bit flag into the stack.
POPD 32-bit marks the stack.

Ii. arithmetic operation commands

ADD addition.
Addition of ADC incoming bits.
INC plus 1.
ASCII code adjustment for AAA addition.
Decimal adjustment of DAA addition.
SUB subtraction.
SBB with borrow subtraction.
DEC minus 1.
NEC reverse (minus 0 ).
CMP comparison. (For subtraction of two numbers, only the flag bit is modified and the result is not returned ).
ASCII code adjustment for AAS subtraction.
Decimal adjustment of the DAS subtraction.
MUL unsigned multiplication.
IMUL integer multiplication.
The above two results are returned to AH and AL (byte operation), or DX and AX (word operation ),
AAM multiplication ASCII code adjustment.
DIV unsigned division.
IDIV integer division.
The above two items are returned:
Commercial AL delivery, remainder AH, (byte operation );
Or commodity delivery AX, remainder delivery DX, (word operation ).
ASCII code adjustment for AAD division.
CBW byte conversion into words (extend the byte symbols in AL to AH)
The CWD character is converted to a dual character. (extend the character symbol in AX to DX)
Convert the CWDE character to a dual character. (extend the word symbol in AX to EAX)
CDQ dual-word extension. (extend the characters in EAX to EDX)

Iii. Logic Operation commands

AND operation.
OR operation.
XOR exclusive or operation.
NOT inverse.
TEST. (two operations are performed and computed. Only the flag bit is modified and the result is not returned ).
SHL logic shifts left.
SAL arithmetic shifts left. (= SHL)
The SHR logic is shifted to the right.
SAR arithmetic shift right (= SHR)
ROL loop shifts left.
ROR loop shifts right.
RCL shifts left through carry loop.
RCR shifts right through carry loop.
In the preceding eight shift commands, the number of shifts can reach 255.
When one shift, you can directly use * as the Code, such as shl ax, 1.
If one shift is performed, the CL registers the number of shifts.
For example, mov cl, 04
Shl ax, CL

Iv. String commands

DS: SI source string segment register: Source string address change.
Es I target string segment register: the address of the target string.
CX repeat count counter.
AL/AX scan value.
D sign 0 indicates repeated * SI and DI should be auto increment; 1 indicates auto increment.
The Z mark is used to control the end of scanning or comparison.
MOVS string transmission.
(MOVSB transfer character. MOVSW transfer word. MOVSD transfer dual word .)
CMPS string comparison.
(CMPSB comparison character. CMPSW comparison word .)
SCAS string scan.
Compare the content of AL or AX with the target string, and the comparison result is reflected in the flag.
LODS Mount string.
Add the elements (words or bytes) in the source string to AL or AX one by one.
(LODSB transfer character. LODSW transfer character. LODSD transfer dual character .)
STOS save string.
Is the LODS inverse process.
REP is repeated when CX/ECX0 is used.
REPE/REPZ is repeated when ZF = 1 or the comparison result is equal and CX/ECX0.
REPNE/REPNZ is repeated when ZF = 0 or comparison results are not equal and CX/ECX0.
Repc is repeated when cf = 1 and CX/ecx0.
Repnc repeats when cf = 0 and CX/ecx0.

V. Program transfer instructions

1> unconditional transfer instruction (long transfer)

JMP unconditional transfer instruction
Call process call
RET/retf process returns.

2> conditional transfer instruction (short transfer,-128 to + 127)

(If and only when (sf xor of) = 1, OP1 Ja/jnbe is not less than or not equal to transfer.
Jae/JNB is greater than or equal to transfer.
JB/jnae is smaller than transfer.
Jbe/JNA is less than or equal to transfer.
Test the result of the unsigned integer operation (Mark C and Z ).
JG/jnle is greater than transfer.
Jge/JNL is greater than or equal to transfer.
Jl/jnge is smaller than transfer.
Jle/jng is less than or equal to transfer.
Test the result of the signed integer operation (S, O, and Z ).
Je/JZ is equal to transfer.
Transfer when JNE/jnz is not equal.
When JC has a bid, it is transferred.
When JNC is not carried.
Transfer when jno does not overflow.
Transfer when the parity of jnp/JPO is odd.
Transfer when the JNS symbol bit is "0.
Jo overflow transfer.
If the parity of jp/jpe is an even number, it is transferred.
Transfer when the JS symbol bit is "1.

3> cyclic control commands (short transfer)

Loop cx is a non-zero LOOP.
LOOPE/loopz cx is not zero and the Mark Z = 1 is a loop.
LOOPNE/loopnz cx is not zero and the Mark Z is 0.
Jcxz cx is transferred at zero time.
Jecxz ecx is transferred when it is zero.

4> interrupt command

INT interrupt command
INTO overflow interrupt
IRET interrupt return

5> processor control commands

The HLT processor is paused until an interruption or reset signal occurs.
When the chip lead TEST is high, the CPU enters the waiting state.
ESC to external processor.
LOCK to block the bus.
NOP null.
STC sets the carry flag.
CLC flags.
The CMC carry mark is reversed.
STD indicates the position in the direction.
CLD flags in the clear direction.
STI allows interruption.
CLI clear interrupt allowed bits.

Vi. pseudoinstructions

DW definition (2 bytes ).
PROC definition process.
The ENDP process ends.
SEGMENT definition SEGMENT.
ASSUME creates block register addressing.
The ENDS segment ENDS.
END program ends.

 

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.