标志寄存器中保留/未定义位的作用是什么? [英] What is the purpose of the reserved/undefined bit in the flag register?

查看:411
本文介绍了标志寄存器中保留/未定义位的作用是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Z80、8080、8085和8086处理器的标志寄存器中,记录为保留"或未定义"的位1、3、5的用途是什么?

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"?

推荐答案

这些位未使用;也就是说,没有指令将它们显式设置为任何值.设计人员认为5/6标志就足够了,他们只是不使用标志寄存器的其余位.

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.

它们被记录为未定义",因为在执行任何一条指令后无法事先知道它们将具有哪个值-处理器设计更简单,与将它们显式设置为0或1.

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.

现在,严格来说,至少对于Z80,这些标志 do 实际上得到一个可预测的值-毕竟,处理器将始终产生相同的输出并在给定相同的状态下更改为内部状态输入和先前内部状态的组合.例如,有关未记录的Z80指令的文档表示关于CPI的以下内容:

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:

标记3和5的设置如下:取A,减去最后一个(HL),然后 如果设置了H标志(/CP之后/之后),则将其减小1.位1 该值的其中一个是标志5,第3位是标志3.

Flag 3 and 5 are set like this: Take A, subtract the last (HL), and then decrease it with 1 if the H flag was set (/after/ the CP). Bit 1 of this value is flag 5, bit 3 is flag 3.

但是,要点是,这种行为是无意的-只是一个副作用-并且不能保证在以后的处理器迭代中出现.这就是为什么将它们记录为未定义"的原因,例如,它们对您没有用,所以请忽略它们".

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".

请注意,在Z80上,F寄存器的所有位都可以设置为任何状态,但在i8080上,位3和5(对应于未公开的Z80标志)始终读取为零,而位1(对应于Z80的N标志)始终读为1.

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.

这篇关于标志寄存器中保留/未定义位的作用是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆