What is the purpose of the reserved / undefined bit in the flag register?

In the flags register of the Z80, 8080, 8085, and 8086 processors, what is the purpose of bits 1, 3, 5, which are documented as โ€œreservedโ€ or โ€œundefinedโ€?

+4
source share
1 answer

These bits are not used; that is, no instruction explicitly sets them to any value. Designers decided that 5/6 flags were enough, and they just left the remaining bits of the flag register unused.

They are documented as "indeterminate," because it is impossible to know in advance what value they will get after executing any of the instructions - thus, the processor design is simpler, unlike explicitly setting it to 0 or 1.

Now, strictly speaking, and at least for the Z80, these flags really get a predictable value - in the end, the processor will always produce the same output and go to the internal state with the same combination of input and previous internal state. For example, this document on undocumented Z80 instructions refers to the CPI:

Flags 3 and 5 are set as follows: take A, subtract the last (HL), and then reduce it by 1 if the H flag was set (/ after / CP). Bit 1 of this value is flag 5, bit 3 is flag 3.

, , , - - . "", , , " , ".

, Z80 F , i8080 3 5 ( Z80) , 1 ( Z80 N) , .

+8

Source: https://habr.com/ru/post/1680475/


All Articles