"Assembly language" learning note 8--Basic assembly instructions

Source: Internet
Author: User

1. Basic assembly Instructions

1. Delivery Instructions: MOV

Format: MOV opd,ops

Action: Transfer the value of OPS to OPD

Precautions:

1.OPD cannot be CS

2. Not allowed to transfer between two storage units

3.MOV affects all flag bits

4.OPD, the data type of OPS should be consistent

When 5.OPD is CS, OPS cannot be an immediate number

  2. The stack command: PUSH

Format: PUSH OPD

Operation: 1. Sp←sp-1 2. OPD the high byte of the stack 3.sp←sp-1 4. Put in a low byte

Precautions:

1.OPD must be a 16-bit word

2.OPD cannot be an immediate number

3. Address after each stack-2

4. First modify the stack top pointer, then perform the stack operation

5. Allow only word to stack

  3. Out of stack command: POP

Format: POP OPD

Action: 1. Point the SP to the byte cell content stack to OPD low byte 2.sp←sp+1 3. The SP points to the byte cell content to OPD low byte 4.sp←sp+1

Precautions:

1.OPD must be a 16-bit word

2.OPD cannot be an immediate number

3. Address +2 after each stack

4. Perform the stack operation first, then modify the stack top pointer

5. Only the word stack is allowed

In-Stack and out-stack are often used in programs to preserve, restore breakpoints, and protect and restore the scene.

  4. Exchange instruction: XCHG

Format: XCHG AX,BX

Action: Swap the value of the AX,BX

5 . Effective address delivery: LEA

Format: LEA opd,ops

Precautions:

1.OPS must be a memory operand

2.OPD is not allowed for immediate count, segment register

  6. Add directive:

    1. Addition instruction: Add

Format: ADD opd,ops

Action: OPD = Opd+ops

Precautions:

1. Do not allow two storage units to be added

2.OPD, OPS are not allowed to be segment register

3. Affect all Markers

    2. Carry addition instruction: ADC

Format: ADC opd,ops

Action: OPD = OPD+OPS+CF CF for carry flag

Note the same as add, which is used for multi-byte/word operations, so that the carry that is generated when the low byte/Word is added to the highest byte.

    3. Add 1 instruction: INC

Format: INC OPD

Action: OPD = opd+1

Precautions:

1.OPD is not allowed as an immediate number and is not allowed as a segment register.

2. Does not affect the carry Mark CF

  7. Reduction of Directives :

    1. Subtraction instruction: SUB

Format: SUB opd,ops

Action: OPD = Opd-ops

Note is consistent with add

    2. With borrow subtraction command: SBB

Format: SBB opd,ops

Action: OPD = OPD-OPS-CF

Considerations are consistent with the ADC

    3. Minus 1 Instructions: DEC and Inc agree

  8. Request for compensation: NEG

1. You take the reverse, plus 1 at the end.

2. To complement an operand, the equivalent of 0 minus the operand

3. Continuously complements an operand two times, its value is unchanged

4. In addition to 0 (cf=0), cf=1

5. Complement the positive complement to its negative complement and vice versa

9. Comparison instructions: CMP

"Assembly language" learning note 8--Basic 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.