Introduction to assembly instructions

Source: Internet
Author: User

Memory Operations

NOP (no action) running this directive will not have any effect on registers, memory, and stacks.

push presses the operand onto the stack.

The pushad instruction presses the contents of all common registers into the stack in a certain order

POP out stack: It takes the first letter or the first value from the top of the stack and then stores it in the specified destination address memory unit.

Popad the directive is exactly the opposite of Pushad, which takes values from the stack and places them in the appropriate registers.

mov This instruction assigns a second operand to the first operand, for example: MOV EAX, EBX; EBX value is assigned to EAX.

The LEA takes the address instruction, similar to the MOV instruction, but the first operand is a universal register, and the second operand is a certificate of deposit.

XCHG Swap registers/memory units and registers the instruction exchanges the value of two operands, for example: XCHG eax,ecxeax value will be stored in ECX.

Math Instruction

INC and Dec The two instructions are to perform the increase and decrease of the operation, if the INC directive, add 1, if the DEC directive, then minus 1.

ADD The add instruction has two operands, and the added result is stored in the first operand. ADD eax,1 is equivalent to Inc EAX.

The ADC carries a carry addition, in this case, a value of two operands and a rounding flag, and the result is stored in the first operand.

SUB This directive is the opposite of add-it holds the value of the first operand minus the second operand to the first operand.

SBB The directive is the opposite of the ADC, which calculates the difference between the two operands and subtracts the carry flag, and the result is stored in the first operand.

MUL The multiplication of unsigned number, there are two kinds of multiplication, the first species is MUL, this is the unsigned number multiplication, only one operand, the other operand is eax, and the result is stored in edx:eax.

Imul The multiplication of signed numbers, the Imul instruction usage is similar to MUL. Imul ecx The instruction will have a signed number ecx multiplied by eax, and the result is stored in edx:eax.

DIV Division instruction. The divisor and the operator result quotient are placed in the EAX and the remainder is placed in edx.

CDQ originally EAX has a value, positive or negative can, CDQ this 32-bit expansion into 64 bits. Into the form of Edx:eax, where the value in EdX is the highest bit in eax, or it can be said to be a sign bit. A long time ago, the instruction set stipulated that the divisor must be half the length of the divisor. Idiv signed division Divisor is 32 bits, then dividend of course need 64 bits, then use edx to expand the eax sign bit, so as not to change the value of eax, and expand to 64 bits.

Logical operations

and, or, XOR, not with, or, XOR, or

comparison and conditional jumps

CMP The directive is a comparison of two operands, which is equivalent to a sub instruction, but the subtracted structure is not saved to the first operand. Just change the 0 flag bit according to the result of subtraction, when two operands are equal, 0 flag position 1. CMP EAX, Ecx,eax and ECX, their own values do not change, but based on the results of their subtraction to determine whether the 0 flag bit z is 1.

TEST Logic comparison, the directive in a certain program and CMP instruction similar, two numeric values and operation, the results are not saved, but will change the corresponding flag (for example, SF,ZF,PF flag), the program can decide whether to jump to the corresponding branch. Here are a few examples: TEST eax,eax. Would you say that if eax compared with himself? With this command, you can determine whether EAX equals 0.

JMP – Jump JE, JZ – The result is zero then jump JNE, JN Z – The result is nonzero to jump

JS – The result is negative then jump JNS – The result is not negative then jump to JP, JPE – The number of 1 in the result is even , jump

JNP, Jnpe – The number of results is 1 is odd then jump JO – Results overflow then jump jno – Results without overflow jump JB, Jnae – Less than jump (unsigned number)

JNB, JAE – greater than or equal to jump (unsigned number) Jbe, JNA – less than or equal to jump (unsigned number) Jnbe, JA – greater than jump (unsigned number)

JL, Jnge – less then jump (signed number) JNL, Jge – greater than or equal to jump (signed number) Jle, JNG – less than or equal to jump (signed number)

Jnle, JG – Greater then jump (signed number)

Transfer instructions

Call is transferred to the specified subroutine, and the operand is the destination address. Press the current EIP into the stack and transfer it, equivalent to the push EIP, JMP [].

RET Returns the calling program, which is equivalent to the pop EIP.

Introduction to assembly instructions

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.