标志寄存器
The Flag register is basically a special type of register or we can also say that they are Special Purpose Register. And based upon the value of result after any type of arithmetic and logical operation the value of flag bits become either set (1) or reset (0). In 8085 microprocessor, flag register basically consists of 8 bits and from these 8 bit, only 5 of them are useful.
标志寄存器基本上是一种特殊类型的寄存器,或者我们也可以说它们是特殊用途寄存器。 根据任何算术和逻辑运算后的结果值,标志位的值将变为设置(1)或复位(0)。 在8085微处理器中,标志寄存器基本上由8位组成,从这8位中,只有5位是有用的。
These 5 flags are:
这五个标志是:
1)标志旗 (1) Sign Flag)
Represented by the symbol S. After any type of arithmetic operation or logical operation if the value of D7 becomes 1 it basically shows that the number is negative and the sign flag is now set, if the value of D7 becomes is 0, it basically shows that the number is positive and the sign flag is now reset.
用符号S表示。在任何类型的算术运算或逻辑运算之后,如果D7的值变为1,则基本上表示数字为负,并且现在设置了符号标志;如果D7的值变为0,则基本上表示该数字为正,并且现在重置符号标志。
Example:
例:
MVI A 40 (load the value40H in register A)
MVI B 30 (load the value 30H in register B)
SUB B (A = A – B)
These set of instructions willbasically reset the sign flag to 0 as 40 – 30 is always apositive number.
这些指令集将基本上将符号标志重置为0,因为40 – 30始终是正数。
2)零标记(Z) (2) Zero Flag (Z))
After any type of arithmetical or logical operation if the output becomes 0 (00)H, then zero flag is said to be set with value 1, if not it becomes reset with the value 0.
在进行任何类型的算术或逻辑运算后,如果输出变为0(00)H,则将零标志设置为值1,否则将其重置为值0。
Example:
例:
MVI A 40 (load the value of40H in register A)
SUB A
These set of instructions will basically set the zero flag to the value 1 as 40H – 40H is always gives result as 00H.
这些指令集基本上会将零标志设置为值1,因为40H – 40H始终给出结果为00H。
3)辅助龋标志(AC) (3) Auxiliary Cary Flag (AC))
This type of flag is basically used in the BCD number system(0-9). If after any type of arithmetic or logical operation D3 generates any carry and passes on to D4 this flag becomes set with value 1, otherwise, it will become reset with value 0. This is the only flag register which is not used or accessed by the programmer.
此类标志基本上用在BCD编号系统(0-9)中。 如果在进行任何类型的算术或逻辑运算后,D3产生任何进位并传递到D4,则该标志设置为值1,否则将被复位为值0。这是唯一的标志寄存器,其不被使用或访问。程序员。
Example:
例:
MOV A 2C (load the value 2CH in register A)
MOV B 38 (load the value 38H in register B)
ADD B (A = A + B)
These set of instructions will set the auxiliary carry flag and set the value to 1, as on adding 2C and 38, addition of these lower order will generate a carry.
这组指令将设置辅助进位标志并将其值设置为1,因为加2C和38时,这些低位的加法将产生进位。
4)奇偶校验标志(P) (4) Parity Flag (P))
After any type of arithmetic or logical operation if the result is even parity, means it has even number of 1 bit, the parity register becomes set with value 1, otherwise, it becomes reset with value 0.
经过任何类型的算术或逻辑运算后,如果结果为偶校验,则表示其偶数为1位,奇偶校验寄存器将设置为值1,否则,将复位为值0。
Example:
例:
MVI A 06 (load 06H value in register A)
This instruction will set the value of parity flag to 1 as the BCD code of 06H is 00000110, which contains even number of ones here the no of 1s is 2.
该指令会将奇偶校验标志的值设置为1,因为06H的BCD码为00000110,其中包含偶数个,此处1的编号为2。
5)进位标志(CY) (5) Carry Flag (CY))
Carry is generated only when while performing n bit operations if it will lead to a result which has more than n bits, then this flag becomes set with value 1, otherwise it becomes reset with value 0.
进位仅在执行n位操作时产生,如果会导致结果的位数超过n位,则该标志将设置为值1,否则将重置为值0。
Example:
例:
MVI A 40 (load 40H value in register A)
MVI B 60 (load 60H value in register B)
SUB B (A = A – B)
These set of instructions will set the carry flag with value 1 as 40 – 60 generates answer with borrow.
这些指令集将值1的进位标志设置为40 – 60,借位生成答案。
翻译自: https://www.includehelp.com/embedded-system/flag-registers-of-8085-microprocessor.aspx
标志寄存器