Compiling an operation that affects the flag bit

Source: Internet
Author: User
Tags mul what arithmetic

Today, hair lessons, in the dormitory covered with small blankets to do assembly work, encountered a topic is to give a set of instructions, ask each step after the completion of the command, what is the mark bit

What arithmetic will change the flag bit? I checked it on the Internet.

(1) Addition directive: Add, ADC, Inc, Xadd except INC does not affect the CF mark Bit, all affect the condition mark bit.

CF, ZF, SF, of

Does the CF highest bit have rounding

DF If two operand symbols are the same and the result symbol is opposite of=1, otherwise of=0.

(2) Subtraction directives: SUB, SBB, DEC, NEG, CMP, CMPXCHG, cmpxchg8b

The first six types except Dec do not affect the CF mark outside the mark bit. CMPXHG8B only affects ZF.

CF describes an overflow of unsigned number subtraction, and it is indeedminuend the most effective bit to the high borrow.

The of bit indicates an overflow with a signed number

Unsigned operation, if the meiosis > is meiosis, there is borrow cf=1, otherwise cf=0.

In the case of a two-digit symbol, the result is of=1 with the same symbol as the meiosis. otherwise of=0.

(3) Multiplication instruction: MUL, Imul

MUL: If the product is half the height of 0, then both the CF and the of bit are 0, otherwise the CF and the of are 1.

Imul: If the high half is an extension of the lower half of the symbol, both the CF bit and the of bit are 0, otherwise they are 1.

(4) Division instruction: DIV, Idiv
There is no definition for all condition bits.

(5) Logic directive: And, or, not, XOR, TEST

Not is not allowed to use the immediate number, the other 4 instructions unless the source operand is an immediate number, at least one operand must be stored in the register. The other operand can use any of the addressing methods.

not does not affect the flag bit, the remaining 4 kinds of CF, of, 0,af no definition, SF, ZF, pf position depends on the situation。

Location Scan command: BSF forward bit scan, BSR reverse bit scan

The number of source operands can be any one other than the immediate number of addresses, the purpose operand must be a register, affecting the ZF bit.
The weather is getting colder, the warm will be more happy Oh ~ Winter Happy ~

Compiling an operation that affects the flag bit

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.