Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the x86 assembly instructions in assembly language

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article will explain in detail what x86 assembly instructions are in the assembly language. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Part 1:instruction

A Mickle makes a Mickle and is constantly updated. (it will be an extremely long process.)

The order of the instructions in the table is sorted according to the degree of importance or commonly used by the author, for reference only.

Part 2

The F referred to in this table refers to the status register, CF refers to the carry flag bit, and so on.

2.1 (logic) operations, shifts and other common instructions

This part records the most frequently used instructions in assembly language programming.

2.1 (logic) operations, shifts and other common instructions

This part records the most frequently used instructions in assembly language programming.

Instruction action considerations example mov dest, src transfer instructions 1.dest and src cannot be memory operands at the same time

2.CS cannot be used as a dest

3. Segment registers cannot be transmitted to each other

4. Immediate number cannot be fed into segment register mov ax,word PTR [BX + si+2] add dest,src addition instruction dest,src cannot be either a memory Operand or a segment register at the same time

Add ax,cxadc dest,src with carry addition instruction dest=dest+src+CF, often used for multibyte addition

Inc dest plus an instruction 1. This operation does not affect the state of the CF inc byte PTR [si] sub dest,src subtraction directive 1. The requirements of the add subtraction instruction are the same as those of add.

two。 Trigger OF: the sign is subtracted and the symbol of the result is different from the subtraction. Sub ax,cxsbb dest,src with carry subtraction is often used in multibyte subtraction.

The dec dest minus one instruction does not affect the state of CF, but several other flag bits are affected. Dec axmul dest unsigned multiplication means that 1.dest is byte data, then multiplies it with AL, and the result is put into AX.

2.dest is word data, which is multiplied by AX. The result is put into AX at low 16 bits and DX at high 16 bits.

3.dest cannot be an immediate number mul aximul dest signed multiplication details are exactly the same as mul, the interpretation of the highest bit is different imul axdiv dest unsigned division 1.dest to byte data, AX divided by dest, quotient in AL, the remainder in AH

2.dest is word data, double-word data with low 16-bit AX and high 16-bit DX is divided by dest, quotient is put in AX, and the rest is put in DX

Idiv dest signed division is exactly the same as unsigned division. The result of division overflow is invalid. Idiv axcbw extends AL to ax data 1. It is only used to expand signed numbers, and zero can be cleared directly without sign.

two。 Cbwcwd extension AX word without Operand for DX,AX double-word data requires the same cwdseg label or variable segment address as cbw

Mov di,seg labellea takes offset address 1. Similar to the effect of offset

The acronym lea ax,labeloffset of 2.load efficient address takes the offset address 1. The function is the same as lea.

two。 Faster than lea mov ax,offset labelorg sets the start address of the program segment (offset) 1. It's an abbreviation for origin.

two。 If there is no org default program, the instruction code is stored from cs:0.

3. The free space between the two org instructions fills the first address of the org offsetValxlat translation table instruction 1.BX storage table with 0, and AL stores the offset of the elements in the current table.

two。 Does not affect the state xlat of F; does not require Operand 2.2 cyclic shift instruction

Cyclic shift instructions are very confusing, but they are very important, so you need to keep this table in mind and consult this table from time to time.

Instruction action precautions example SHL logic left instruction 1. The highest bit enters the CF.

two。 The lowest bit directly fills the SHL AH,1SHR logic right instruction 1. The lowest bit enters the CF

two。 The highest bit directly fills the SHR BX,1SAL arithmetic left instruction behavior with 0 and there is no difference between SHL and SAL BL,CLSAR arithmetic right instruction 1. The lowest bit goes into the CF

two。 After the highest bit is moved to the right, fill the highest bit (that is, fill the highest bit with the highest bit) SAR CL,BXROL cycle left shift instruction to enter the CF and fill the lowest bit with the above ROR cycle right shift instruction to enter the CF and fill the highest bit with RCL with carry cycle left shift instruction 1. The lowest bit is filled by CF

two。 The highest bit enters CF as above RCR with carry cycle right shift instruction 1. The highest bit is filled by CF

two。 The lowest bit enters the CF as well as the 2.3 data string operation instructions above.

The combination of repeated prefix instructions and data string operation instructions can often get twice the result with half the effort, so note that the use of the assembler greatly improves the simplicity of the assembler.

Instruction action note example lods/lodsw/lodsb loads data string instruction 1. Specific operation: read a byte / word / double word from ds:si to AL,AX,EAX, and SI increases or subtracts the corresponding numerical lodsw according to the value of DF; there is no need for operands stos/stosw/stosb to store the contents of the data string instruction 1.AX/AL into ES:DI

two。 Pointer modification is automatic and implicit stos/stosw/stosb; no Operand cmps/cmpsb/cmpsw data string comparison instruction cmps requires two operands (the first address of the data string), the last two do not need operands, string comparison is completed by DI and SI; NULLmovs/movsb/movsw data string transmission instructions refer to the above usage of cmps and so on; NULLrep/repz/repnz repeat prefix instruction 1. Perform an operation when the content of the cx is not 0 (judge first)

two。 Using CLD,STD to control the modification of increment and decrease

3. Combined with data string operation instructions, memory copy, comparison and other functions do not require Operand 2.4 logic operation instructions.

This part of the instruction is divided according to my understanding, so it may not be accurate. If you have any comments, you are welcome to put forward them in the comments area.

Instruction function considerations example cmp dest,src1. Compare instruction 1. Subtract src from dest, but do not save the result

two。 The result of subtraction affects Fcmp ax,cxtest dest,src1. Comparing dest with src can be used to test whether it is zero or not, and the result is not saved.

two。 Affect the Ftest ax,axneg dest complement instruction, get the opposite number, affect the Fneg axnot dest reverse instruction 1. Reverse each bit of the Operand

two。 It does not affect the size-based jump instruction of Fnot AX2.5.

After using instructions such as cmp,sub,subb, we usually use the following instructions to connect in order to carry on the next step of operation, which makes the program very concise. It should be noted that different instructions are selected to jump based on the size relationship according to the signed and unsigned numbers.

Unsigned number

The number of jump symbols when the instruction action JA label is greater than the jump JAE label is greater than or equal to the jump JB label is less than the jump JBE label is less than or equal to

Instruction action JG label greater than jump JGE label greater than or equal to jump JL label less than jump JEL label less than or equal to jump unsigned, signed universal

Jump when JE label equals JNE label is not equal to jump 2.6 transfer instruction based on single flag bit

Whether to jump or not is determined according to the status of the flag bit in the flag register F, which is usually combined with these instructions after the operation.

Instruction action JC labelCF=1 jump JNC labelCF=0 jump JZ labelZF=1 jump JNZ labelZF=0 jump JO labelOF=1 jump JNO labelOF=0 jump JS labelSF=1 jump JNS labelSF=0 jump JP labelSF=1 jump JNP labelPF=0 jump about this article about "what are the x86 assembly instructions in assembly language?" I hope the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good Please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report