The role of dedicated registers for CPU resources and memory in one lesson (10/75) per day

Source: Internet
Author: User
Special registers include flag/eflag, segment registers es, Cs, SS, DS, FS, Gs.

Flag/eflag)
The 16-bit CPU flag register has nine binary digits, which are:

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Of DF If TF SF ZF AF PF Cf

The 32-bit CPU flag register has 13 binary digits, which are:

31 ... 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
... ... VM RF   NT Iopl Of DF If TF SF ZF AF PF Cf

The role of these signs isSome features that reflect the processor status and computing results. The flag affects the execution of the command, and the execution of the command also affects the flag.

Operation Result flag
1. Cf carry flag
Indicates whether an operation generates carry or borrow digits. If the highest digit of the calculation result produces a carry or dislocation, the value is 1; otherwise, the value is 0.
This flag is used in scenarios such as addition and subtraction of the number of words (bytes), comparison of the number of unsigned values, shift operation, shift between words (bytes), and commands that specifically change the CF value.

2. pf parity flag (parity flag)
The parity mark PF is used to reflect the parity of the number of "1" in the calculation result. If the number of "1" is an even number, PF is 1; otherwise, it is 0.
You can use pf to perform parity check or generate parity check bits. In the process of data transmission, in order to provide the reliability of transmission, such as using the parity verification method, this flag can be used.

3. af secondary carry flag auxiliary carry flag
In the following cases, the secondary carry flag is 1; otherwise, it is 0:
1) when the word operation occurs, the lower byte is carried to the high byte or the borrow bit.
2) during the byte operation, the lower 4 bits are carried to the upper 4 bits or the borrow bits.

4. ZF zero flag
The zero flag is used to indicate whether the calculation result is 0. If the result is 0, the value is 1. Otherwise, the value is 0. You can use this flag when determining the calculation result.

5. SF sign flag
Symbol mark (SF) is the symbol bit used to reflect the calculation result. It is the same as the highest bit of the calculation result. In a PC system, the number of symbols is represented by a complement code, therefore, SF also reflects the positive and negative numbers of the calculation results. The calculation result is an integer, SF is 0, and negative SF is 1.

6. of overflow flag
Overflow sign of is used to indicate whether the result of the addition or subtraction operation of the number of symbols overflows. If the calculation result exceeds the range that can be expressed by the current number of digits, it becomes overflow. The value of is set to 1, otherwise, the value of is cleared to 0.Overflow and bitwise are two different concepts.

Among the above six flags, PF and AF are rarely used, and ZF of cf sf is commonly used.

2. Status Control flag
Status control flags are used to control CPU operations. They can be changed only through special commands.
1. TF tracking flag
When the trace flag TF is set to 1, the CPU enters the single-step execution mode, that is, each command is executed and a single-step interruption request is generated. This method is mainly usedProgramDebugging.
The command system does not have a special command to change the TF value of the flag, but it can be changed through other methods.

2. If the interrupt is allowed to mark interrupt-enable flag
The interrupt flag if is used to determine whether the CPU responds to requests outside the CPU that can block the interrupt. When the value of IF is 1, the CPU can respond to the blocked interrupt requests outside the CPU. When the value of IF is 0, the CPU does not respond to the blocked interrupt requests outside the CPU.
For unblocked external CPU interruptions and internal CPU interruptions, the CPU will respond regardless of the value of the IF flag.

3. df Direction Flag
The direction sign (DF) is used to determine the direction in which the pointer register is adjusted when the serial operation command is executed.

The third 32-bit register adds a flag.

1. iopl I/O privileged flag input/output privilege level
The I/O privileged flag is represented by two binary bits and also becomes an I/O privileged level field. This field specifies the privileged level required to execute the I/O command. IfThe current privileged level is less than or equal to the iopl value. This I/O command can be executed.Otherwise, a protection exception is thrown.

2. nt nested task flag nested task
The nested task flag NT is used to control the iret execution of the interrupt return command. The specific provisions are as follows:
1) When Nt = 0, use the stored values in the stack to restore eflags, Cs, and EIP, and perform regular interrupted return operations;
2) When Nt = 1, the task is converted to interrupt return.

3. Restart flag of RF restart flag
The restart flag RF is used to control whether debugging faults are accepted. The following rules are imposed:If RF is set to 0, debugging fault is accepted.Otherwise, refuse. After a command is successfully executed, the processing mechanism sets the RF to 0. When a non-debugging fault is received, the processor sets it to 1.

4. VM 8086 mode indicates virtual 8086 Mode
If this flag is 1, it indicates that the processor is inVirtual8086 mode. Otherwise, the processor is in normal protection mode.

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.