Sign register (learning Assembly)

Source: Internet
Author: User
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
  NT Iopl Of DF If TF SF ZF   AF   PF   Cf
Wei
Enable
Use
Embed
Set
Mark
Zhi
I/O
Permission
Flag
Ranking 2
Overflow
Output
Mark
Zhi
Fang
Direction
Mark
Zhi
Medium
Disconnected
Allow
Xu
Mark
Zhi
Single
Step
Mark
Zhi
Character
No.
Mark
Zhi
Zero
Mark
Zhi
Wei
Enable
Use
Auxiliary
Help
Mark
Zhi
Wei
Enable
Use
Odd
Even
Mark
Zhi
Wei
Enable
Use
Into
Bit
Mark
Zhi
1. There is a special register in the registers inside the CPU (for different processors, the number and structure may be different) which has the following three functions. (1) It is used to store certain execution results of related commands; (2) it is used to provide Behavior Basis for CPU execution of related commands; (3) it is used to control CPU-related work methods. This kind of special register is called the mark register in 8086cpu. the Mark register (FLAG) in this chapter enables us to learn the last register. 2. the flag register is used by bit. That is to say, each bit of the Flag register has a special meaning and records specific information. 3. the 1, 3, 5, 12, 13, 14, and 15 bits of the flag are not used in the 8086cpu and do not have any meaning; digits 0, 2, 4, 6, 7, 8, 9, 10, and 11 have special meanings. 4. The 6th bits of flat are ZF and zero flags. It records whether the result is 0 after the related command is executed. if the result is 0, ZF = 1; if the result is not 0, ZF = 0. for example, if the result of the command mov ax, 1 sub ax, and 1 is 0, ZF = 1 mov ax, 2 sub ax, and 1 is not 0, in the ZF = 0 5.8086cpu instruction set, most operation commands (logical or arithmetic operations) affect the mark register, while most transfer commands do not affect the mark register. 6. The 2nd-bit flag is PF, And the parity flag is used. It records whether the number of 1 in all bit bits in the result is an even number after the command is executed. If the number of 1 is an even number, pF = 1, and vice versa. pF = 0. for example, after executing command: mov Al, 1 add Al, 10, the result is 20171011b, where 3 (ODD) 1, pF = 0; MoV Al, 1 or Al, 2. After execution, the result is 100000011b. If there are 2 (even) 1, pF = 1; sub Al, after Al is executed, the result is then 100000000b, where 0 (even) 1, then pF = 1 7. the 7th-bit flag is SF, a symbolic flag. It records whether the result is negative after the related command is executed. If it is negative, Sf = 1; if it is not negative, Sf = 0; 8. A data in a computer can be regarded as a signed number or an unsigned number. 9. The SF mark is a record of the computing result of the number of symbols on the CPU. It records positive and negative data. 10. When the CPU word executes the Add command, it will inevitably affect the value of the SF flag. 11. The 0th-bit flag is CF, And the carry flag is used. Generally, during the unsigned operation, the highest valid bit of the operation result is recorded to a higher carry value, or from a higher borrow value. For example, the command: mov Al, 98 h add Al, Al; after execution: (Al) = 30 h, cf = 1 Cf records the carry values from the highest valid bit to add Al, Al. After execution: (Al) = 60 h, cf = 0 CF records the carry-in values mov Al, 97 h sub, Al, 98 h from the highest valid bit rows. After the execution, (Al) = FFH, cf = 1 Cf records the sub Al, Al from the highest bit to the higher bit. After the command is executed: (Al) = 0, cf = 0 CF records 12 bits from the highest bit to a higher bit. when performing a signed operation, if it exceeds the range expressed by the machine, it is called overflow. 13. The 11th bits of the flag are of, indicating the overflow flag. Generally, the of Operation records whether the result of the signed number operation has exceeded. If overflow occurs, of = 1; otherwise, of = 0. 14. Note the difference between CF and of: Cf is a sign that makes sense for the calculation of the number of symbols, while of is a sign that makes sense for the calculation of the number of symbols. 15. The ADC is a bit addition command that uses the carry value recorded on the CF bit. Command Format: ADC operation object 1, operation object 2 function: Operation object 1 = operation object 1 + operation object 2 + CF such as command ADC ax, the function implemented by BX is: (ax) = (ax) + (BX) + CF 16. the carry value used by the ADC is affected by the previous command. You can use the ADC to add any big data (through the loop), but note that the inside of the loop does not affect cf. 17. SBB is a command with a subtraction of digits. It uses the format of the debit value command recorded on CF bits: SBB operation object 1, operation object 2 function: operation object 1 = operation object 1-operation object 2-cf such as command ADC ax, BX implements the following functions: (ax) = (ax)-(BX)-CF 18. CMP is a comparison command. Its function is equivalent to a subtraction command. It only does not save the result, but affects the bit of flag. Other commands can identify these flags to learn the comparison result. Command Format: CMP operation object 1, operation object 2 function: calculation operation object 1-operation object 2, but does not save the results, only sets the flag register based on the results. For example, run the command CPP ax and ax to perform the (ax)-(ax) operation. The result is 0, but it is not stored in ax. This affects the flag. After the command is executed: ZF = 1, pF = 1, Sf = 0, cf = 0, of = 0. 19. if the actual result is negative due to overflow, the true logical result must be positive. 20. the 10th-bit flah is DF, and the Direction Flag is used. in the string processing command, after controlling the enzyme promotion operation, Si and di increase or decrease online. DF = 0 after each operation Si, DI increasing df = 1 after each operation Si, di decreasing format: movsb function: Execute the movsb command is equivalent to performing the following operations (1) (ES) * 16 + (DI) = (DS) * 16) + (SI) (2) if df = 0 then: (SI) = (SI) + 1 (DI) = (DI) + 1 If df = 1 then: (SI) = (SI)-1 (DI) = (DI)-1 For example, send data using string transmission commands. Assume Cs: codedata segment dB 'Welcome to masn! 'Db 16 DUP (0) Data endscode segment S: mov ax, data mov ds, ax mov Si, 0; DS: Si points to data: 0 mov es, ax mov Di, 16; es: Di points to data: 0010 mov CX, 16; (CX) = 16, rep loop 16 CLD; Set df = 0, forward transfer rep movsb mov ax, 4c00h int 21 code endsend s 21. pushf is used to push the value of the Mark register to the stack, while popf pushes data from the stack to the mark register. 22. pushf and popf provide a method for directly accessing the flag register.
Related Article

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.