Part 1:instruction
Accumulate small amounts and continue to update. (This will be an extremely long process)
The order of each instruction in the table is sorted according to the degree of importance or common use that the author considers, and is for reference only.
Part 2
The F mentioned in this table refers to the status register, CF refers to the carry flag bit, and so on.
2.1 (Logic) Common instructions such as operation and shift
This part records the most frequently used part of the instructions in assembly language programming.
2.1 (Logic) Common instructions such as operation and shift
This part records the most frequently used part of the instructions in assembly language programming.
instruction | effect | Things to note | Example |
---|---|---|---|
mov dest, src | Transfer commands | and src cannot be memory operands at the same time Can't be used as a dest 3. Segment registers cannot be transmitted to each other 4. The immediate number cannot be fed to the segment register |
mov ax,word ptr[bx+si+2] |
add dest,src | Additive instruction | dest,src cannot be a memory operand or segment register at the same time |
add ax,cx |
adc dest,src | Bring carry addition instruction | dest=dest+src+CF, commonly used in multibyte addition | |
inc dest | Add an order | 1. This operation does not affect the status of CF | inc byte ptr[si] |
sub dest,src | Subtraction instruction | , the requirements of src are the same as add 2. Trigger OF: The different symbols are subtracted and the result symbol is different from the subtracted number. |
sub ax,cx |
sbb dest,src | Take carry subtraction | Commonly used in multibyte subtraction | |
dec dest | One order | It does not affect the state of CF, but several other flags will be affected. | dec ax |
mul dest | Unsigned multiplication | It is byte data, multiply it with AL and put it into AX For word data, multiply with AX, the result is 16 bits lower and the result is put into AX, and the result is 16 bits higher and the result is DX. Can't count immediately |
mul ax |
imul dest | Signed multiplication | The details are exactly the same as mul, and the explanation of the highest bit is different | imul ax |
div dest | Unsigned division | For byte data, divide AX by dest, quotient is placed in AL, and remainder is placed in AH For word data, divide the double word data with the lower 16 bits as AX and the higher 16 bits as DX by dest, the quotient is placed in AX and the remainder is placed in DX |
|
idiv dest | Signed division | Exactly the same as unsigned. The result is invalid when division overflows | idiv ax |
cbw | Extended AL to AX word data | 1. Only used to expand signed numbers, and clear them directly without signs. 2. No operands |
cbw |
cwd | Extended AX word to DX, AX double word data | The requirements are the same as cbw | cwd |
seg | Take the segment address of the label or variable | mov di,seg label | |
lea | Get the offset address | 1. Similar to offset Abbreviation of efficient address |
lea ax,label |
offset | Get the offset address | 1. The function is the same as that of lea 2. Faster than lea |
mov ax,offset label |
org | Set the start address of the program block (offset) | 1. It is the abbreviation of origin 2. If there is no org default program, store instruction code from cs:0 3. The free space between two org instructions is filled with 0 |
org offsetVal |
xlat | Convert table instruction | The first address of the table is stored, and AL stores the offset of the elements in the current table. 2. Does not affect the state of F |
xlat ; no operand required |
2.2 Circular shift instruction
Cyclic shift instructions are very confusing, but they are very important, so you need to remember and review this table from time to time.
instruction | effect | Things to note | Example |
---|---|---|---|
SHL | Logical left-shift instruction | 1. The highest bit enters CF 2. The lowest position is directly filled with 0 |
SHL AH,1 |
SHR | Logical right shift instruction | 1. Enter CF at the lowest level 2. The highest bit is directly filled with 0 |
SHR BX,1 |
SAL | Arithmetic left-shift instruction | There is no difference between behavior and SHL | SAL BL,CL |
SAR | Arithmetic right shift instruction | 1. Enter the lowest position into CF 2. After the highest bit is shifted right, fill the highest bit (that is, fill the highest bit with the highest bit) |
SAR CL,BX |
ROL | Loop left-moving instruction | The highest bit enters CF and fills the lowest bit | Same as above |
ROR | Loop right-moving instruction | The lowest bit enters CF and fills the highest bit | Same as above |
RCL | Left shift instruction with carry loop | 1. The lowest bit is filled by CF 2. Enter CF at the highest position |
Same as above |
RCR | Right-shift instruction with carry loop | 1. The highest bit is filled with CF 2. Enter CF at the lowest level |
Same as above |
2.3 Data string operation instructions
Repeating prefix instructions and data string operation instructions can often achieve twice the result with half the effort. Pay attention to the use of the prefix instructions greatly improves the simplicity of the assembly program.
instruction | effect | Things to note | Example |
---|---|---|---|
lods/lodsw/lodsb | Load data string instruction | 1. Specific operation: read a byte/word/double word from ds:si to AL, AX, EAX, SI increases and decreases the corresponding value according to the value of DF | lodsw ; no operand required |
stos/stosw/stosb | Save data string instruction | /AL content is stored in ES:DI 2. Pointer modification is automatic and implicit |
stos/stosw/stosb; no operand required |
cmps/cmpsb/cmpsw | Data string comparison instruction | cmps requires two operands (the first address of the data string), and the last two do not require operands. The comparison of strings is done by DI and SI | ;NULL |
movs/movsb/movsw | Data string transfer instruction | Notes refer to the usage of cmps, etc. above | ;NULL |
rep/repz/repnz | Repeat prefix command | 1. Execute the operation when the content of cx is not 0 (judgment first) 2. Use CLD and STD to control the increase and decrease of amounts and modify it 3. Used in combination with data string operation instructions to realize memory copying, comparison and other functions |
No operand required |
2.4 Logical operation instructions
This part of the instructions is divided according to my understanding, so it may not be accurate. If you have any comments, please submit them in the comment section.
instruction | effect | Things to note | Example |
---|---|---|---|
cmp dest,src | 1. Comparison instructions | 1. Use dest to subtract src but do not save the result 2. Effect of subtraction results F |
cmp ax,cx |
test dest,src | 1. Give dest and src | Can be used to test whether it is zero, etc., the result will not be saved 2. Influence F |
test ax,ax |
neg dest | Take the supplement command and get the opposite number | Impact F | neg ax |
not dest | Reverse command | 1. Inverse each bit of the operand 2.Does not affect F |
not AX |
2.5 Jump instruction based on size relationship
After using cmp, sub, subb and other instructions, these instructions are usually used to connect to the next step, making the program very concise. It should be noted that different instructions need to be selected according to signed and unsigned numbers for jumping based on size relationships.
Unsigned number | |
---|---|
instruction | effect |
JA label | Jump when greater than |
JAE label | Jump when greater than or equal to |
JB label | Jump when less than |
JBE label | Jump when less than or equal to |
Signed number | |
---|---|
instruction | effect |
JG label | Jump when greater than |
JGE label | Jump when greater than or equal to |
JL label | Jump when less than |
JEL label | Jump when less than or equal to |
Unsigned, signed universal | |
---|---|
JE label | Jump when equal to |
JNE label | It does not mean jump |
2.6 Transfer instructions based on single flag bits
Determine whether to jump based on the status of the flag bits in the flag register F. Usually, these instructions are combined to jump after the operation.
instruction | effect |
---|---|
JC label | Jump when CF=1 |
JNC label | Jump when CF=0 |
JZ label | Jump when ZF=1 |
JNZ label | Jump when ZF=0 |
JO label | Jump when OF=1 |
JNO label | Jump when OF=0 |
JS label | Jump when SF=1 |
JNS label | Jump when SF=0 |
JP label | Jump when SF=1 |
JNP label | Jump when PF=0 |
Part 3:Loading… …
First update: 2020-05-15 15:29
Second update: 2020-05-22 00:14
Third update: 2020-05-24 00:24
Fourth update: 2020-05-24 21:10
Continuously updated... …
This is the article about assembly language: x86 assembly instructions and its precautions. For more related contents of x86 assembly instructions, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!