0

Z80 汇编语言的一件事困扰着我。符号标志总是代表A寄存器值的符号吗?我的意思是,当我运行“INC B”时,结果返回到 B,那么符号标志是取自 A 或 B 寄存器的值吗?提前致谢

4

4 回答 4

1

此页面: http: //icarus.ticalc.org/articles/z80_faq.html似乎表明符号标志代表任何计算的结果,而不仅仅是 A 寄存器上的那些。

于 2011-02-19T14:38:13.260 回答
1

Z80 下所有寄存器(A,B,C,D,E,H,L)都是独立的,所以任何算术或二进制操作都会影响到 F 寄存器中的标志。

检查 Z80 数据表第 160 页以了解inc r受影响的标志。

于 2011-02-19T18:06:00.407 回答
0

符号标志并不总是代表 A。溢出(inc on 255)、按位运算(移位等)和逻辑运算符会影响所有标志。

然而,Zilog 以不同的方式设置每个寄存器,因此某些操作会影响具有特定寄存器而不是另一个寄存器的标志。一个常见的优化是“XOR A”,它设置符号标志并有效地将 A 与零进行比较。我很确定它只适用于 reg A。

前面提到的 Icarus 文档解释了这些标志,并且曾经有另一个更小的文本文档来解释这些标志。但上次我看到那是 10 多年前,我不知道它会在哪里。

于 2011-10-26T19:02:27.490 回答
0

Z80 中的标志总是指最后一次修改它们的操作。这种行为可能有用,也可能不太有用。只是给你几个具体的例子:

ld l,0           ; L is non-zero, but loading does not affect flags,
                 ; so their state is undefined at this stage
xor a            ; this resets A to 0; affected flags are NC, Z
ld h,a           ; we still have NC, Z
inc hl           ; HL is now equal to 1, but inc/dec of register pairs does
                 ; not affect any flags at all
dec a            ; A is now 255 (i.e. -1). we have NZ (expectedly),
                 ; however flag C is still off (intuitively unexpectedly),
                 ; because DEC of individual registers does not affect state of flag C
add a,1          ; at the same time, addition modifies both Z and C,
                 ; so after this A=0 again and we have flags Z and C both on

一般来说,这意味着有时您可以构造更复杂的条件来跟踪标志 C 的状态,同时执行修改标志 Z 而不修改标志 C 的其他操作。这也意味着您必须记住每个操作,它标记它修改。

我所知道的包含所有这些信息的最佳在线表格位于http://clrhome.org/table/

于 2018-03-05T09:54:39.003 回答