4. addition and subtraction operation commands

Source: Internet
Author: User

1. Add

ADD OPRD1 OPRD2

Operation: (OPRD1) <-(OPRD1) + (OPRD2)

Impact flag:

OF: if the two operands have the same symbol and the result symbol is opposite, overflow OF = 1; otherwise, OF = 0

(For example, if two positive numbers add a negative number, or two negative numbers add a positive number, the addition of the opposite two numbers does not overflow)

CF: indicates the overflow of the unsigned number (carry)

 

2. Addition command ADC for incoming bits

ADC OPRD1, OPRD2

Operation: (OPRD1) <-(OPRD1) + (OPRD2) + CF

Calculate the double-precision addition, first ADD low (ADD, may carry), plus high (ADC, plus possible carry)

That is to say, to add two words, you must use two commands.

For example, OPRD1 = dx ax OPRD2 = BX CX

OPRD1 + OPRD2 implementation:

Add ax, CX

Adc dx, BX

3. Add 1 command Inc

INC OPRD

Operation: (OPRD) <-(OPRD) + 1

It is mainly used to adjust address pointers and counters without affecting CF


4. subtraction command sub

SUB OPRD1, OPRD2

Operation: (OPRD1) <-(OPRD1)-(OPRD2)

CF bits indicate the overflow of the unsigned number Subtraction

If the two numbers have the opposite sign, and the result symbol is the same as that in the lower case, then OF = 1

 

5. SBB

SBB OPRD1, OPRD2

Operation: (oprd1) <-(oprd1)-(oprd2)-cf

Same as ADC, used in scenarios where the number of multi-character segments is reduced

 

6. Minus 1 command Dec

Dec OPRD

Operation: (OPRD) <-(OPRD)-1

 

7. Obtain the completion command neg

Neg OPRD

Operation: (OPRD) <--(OPRD)

If-128 is supplemented during the byte operation, or-32768 is supplemented during the word operation, the operands remain unchanged, but of is set to 1. In other cases, of = 0

When the operand is 0, the result of the complement operation is set to CF = 0. In other cases, cf = 1

 

8. Comparison command CMP

CMP oprd1 oprd2

OPRD1-OPRD2 completed, but the result is not sent back

One of the double operands must be a register.

Impact indicator CF, ZF, SF, of, AF, and PF

Determine whether the two are equal based on ZF.

If the two are unsigned numbers, you can determine the size based on CF.

If the two are signed numbers, you can determine the size based on SF and.

 

This article is from the false news (PWWANG. COM). For more information, see the source.

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.