The meaning of the various flag bits

Source: Internet
Author: User

First, the result of the operation of the flag 1, carry Mark CF (Carry flag)

The carry flag CF is mainly used to reflect whether the operation produces rounding or borrow. If the highest bit of the result of the operation produces a carry or borrow, its value is 1, otherwise its value is 0.

The use of this flag bit is: the addition and subtraction of the number of characters (bytes), the size of the unsigned number comparison operation, the shift operation, the word (byte) between the shift, specifically change the CF value of the instructions.

2, Parity Mark PF (Parity flag)

The parity Mark PF is used to reflect the parity of the number of "1" in the result of the operation. If the number of "1" is even, the value of PF is 1, otherwise its value is 0.

The PF can be used for parity checking, or for generating parity bits. In the process of data transmission, in order to provide the reliability of the transmission, if the use of parity method, you can use the flag bit.

3. Auxiliary carry sign AF (auxiliary Carry flag)

The value of the secondary carry Flag AF is set to 1 if the following occurs, otherwise its value is 0:

(1), in the word operation, the occurrence of low-byte high-byte rounding or borrow;
(2), when the byte operation, occurs when the low 4-bit to high 4-bit carry or borrow.

For the above 6 operation result flag bits, in the general programming case, the use frequency of the flag bit CF, ZF, SF and of is higher, while the use frequency of the flag bit PF and AF is low.

4, 0 Mark ZF (Zero flag)

The 0 symbol ZF is used to reflect whether the result of the operation is 0. If the result of the operation is 0, its value is 1, otherwise its value is 0. This flag bit can be used when judging whether the result of the operation is 0 o'clock.

5. Symbol SF (sign flag)

The symbolic symbol SF is used to reflect the symbolic bit of the result of the operation, which is the same as the highest bit of the result. In the microcomputer system, the signed number uses the complement notation, so the SF also reflects the positive and negative sign of the result of the operation. When the result of the operation is positive, the SF value is 0, otherwise its value is 1.

6. Overflow mark of (Overflow flag)

The overflow flag of is used to reflect whether the signed number plus minus operation results in overflow. If the result of the operation exceeds the range that can be represented by the current number of operations, it is called overflow, and the value of of is set to 1, otherwise the value of of is cleared to 0.

"Overflow" and "carry" are two different meanings of the concept, do not confuse. If you're not sure, check out the relevant chapters in the principles of computer composition course.

Second, the status control mark bit

The status control flag bits are used to control CPU operation, and they have to be changed by special instructions.

1. Tracking Mark TF (TRAP flag)

When the trace flag TF is set to 1 o'clock, the CPU goes into single step execution, that is, each execution of an instruction, resulting in a single step interrupt request. This method is mainly used for program debugging.

There is no specific instruction in the instruction system to change the value of the flag bit TF, but the programmer can use other methods to change its value.

2. Interrupt Allow flag if (interrupt-enable flag)

The interrupt allow flag if is used to determine whether the CPU responds to an interrupt request made by a masked interrupt outside the CPU. However, regardless of the value of the flag, the CPU must respond to an interrupt request from an unshielded interrupt outside the CPU, as well as an interrupt request that is generated internally by the CPU. Specific provisions are as follows:

(1), when if=1, the CPU can respond to the interrupt request of a masked interrupt outside the CPU;

(2) When if=0, the CPU does not respond to interrupt requests made by a masked interrupt outside the CPU.

The instruction system of the CPU also has special instructions to change the value of the flag bit if.

3. Direction Mark DF (Direction flag)

The direction flag DF is used to determine the direction in which the pointer register adjusts when the string operation instruction executes. The specific provisions are given in section 5th 2.11--string manipulation instructions. In the instruction system of microcomputer, a special instruction is provided to change the value of the flag bit DF.

Three, 32-bit flag register increased flag bit 1, I/O privilege flag iopl (I/O Privilege level)

The I/O privilege flag is represented by a two-bit bits, also known as an I/O privilege level field. This field specifies the privilege level that requires the execution of I/O directives. If the current privilege level is less than or equal to the value of IOPL, then the I/O instruction executes, or a protection exception occurs.

2. Nested task flag NT (Nested Task)

Nested task Flags NT is used to control the execution of interrupt return instruction Iret. Specific provisions are as follows:

(1), when nt=0, restore EFlags, CS, and EIP with the values stored in the stack, perform the normal interrupt return operation;

(2), when the nt=1, through the task conversion to achieve interrupt return.

3. Restart flag RF (Restart flag)

Restart flag The RF is used to control whether the debug failure is accepted. Rule: When Rf=0, said "accept" debug failure, otherwise refused. After a successful execution of an instruction, the processor set the RF to 0, and when it accepts a non-debug fault, the processor will set it to 1.

4, virtual 8086-way flag VM (virtual 8086 mode)

If the value of this flag is 1, the processor is in the virtual 8086 mode of operation, otherwise, the processor is in a general protection mode of operation.

The meaning of the various flag bits

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.