In the flag register of Z80, 8080, 8085, and 8086 processors, what is the purpose of bits 1, 3, 5, which are documented as "reserved" or "undefined"?
相关问题
- How can I include a ASM program into my Turbo Basi
- Long latency instruction
- Counting number of allocations into the Write Pend
- How can I tell if jump is absolute or relative?
- Assembly: dynamic memory allocation without malloc
相关文章
- Why does the latency of the sqrtsd instruction cha
- x86 Program Counter abstracted from microarchitect
- How do I access double pointer from C code in ASM&
- Fastest Offset Read for a Small Array
- cpu cacheline and prefetch policy
- Assembly PC Relative Addressing Mode
- Machine code alignment
- Can a lower level cache have higher associativity
These bits are unused; that is, no instruction explicitly sets them to any value. The designers decided that 5/6 flags was enough, and they just left the remaining bits of the flags register unused.
They are documented as being "undefined" because it is not possible to know in advance which value will they have after any of the instructions are executed—the processor design is simpler that way, as opposed to setting them explicitly to 0 or 1.
Now, strictly speaking, and for the Z80 at least, these flags do actually get a predictable value—after all, a processor will always produce the same output and change to internal state given the same combination of input and previous internal state. For example, this document about undocumented Z80 instructions says the following about CPI:
The point, however, is that this behavior is unintentional—just a side effect—and not guaranteed to be present in future iterations of the processors. That's why they are documented as being just "undefined", as in, "they aren't useful to you so just ignore them".
Note that while on Z80 all bits of the
F
register can be set to any state, on i8080 bits 3 and 5 (that correspond to the undocumented Z80 flags) always read to be zero and bit 1 (that corresponds to Z80's N flag) always reads to be one.