如何在 Z80 Assembly 中进行“大于”跳转,而不是“大于或等于”?

Dyl*_*erd 3 assembly z80

我正在尝试学习 Z80 组装 - 如果这是非常明显的,请原谅我 - 但我对整个组装相当陌生。

在进行比较之后,我已经熟悉了跳跃的工作原理cp以及它们如何等同于我所知道的东西,即NZ相当于“!=”,C与“<”相关,等等。尽管据我所知,“>”并不那么容易。

NCC与,相反NC- 据我了解 - 在我的场景中与 ">= 相关。我的假设是我可以在相同的跳转条件下组合NCNZ来删除“=”,但它似乎不起作用。

我该怎么做才能使我的跳跃条件大于a比较量,而又不允许它们等于零?

Tom*_*mmy 5

CP执行减法并适当设置标志。它不存储减法的结果。

\n

因此,要比较 A 是否大于操作数,您需要查找严格为正数的减法结果,即等于 1 或更大。

\n

没有直接的途径,你必须将其作为复合 \xe2\x80\x94NC来消除所有小于 0 的结果,让你大于或等于,然后NZ消除相等的可能性。但您可能想要翻转这些以获得更简单的代码。例如

\n
      CP <whatever>\n      JR C, testFailed   ; A was less than the operand.\n      JR Z, testFailed   ; A was exactly equal to the operand.\n\ntestSucceeded:\n      ; A was not less than the operand, and was not\n      ; equal to the operand. Therefore it must have\n      ; been greater than the operand.\n      ...\n\ntestFailed:\n      ...\n
Run Code Online (Sandbox Code Playgroud)\n