如何实现逻辑或 ||在 easy68k 的 if() 条件下?

How to implement logical OR || in an if() condition in easy68k?

假设我要比较一个数据寄存器,我必须将它与等于 2 个数字之一进行比较。我该怎么做?

我知道怎么做,只是比较一个数字而不是 2。

CMP #0, D3
BNE ELSE
REST OF THE CODE HERE

当我想将它与 0 或其他数字(例如 7)进行比较时,我该如何进行比较。在 C++ 中,您会说

if(x == 0 || x == 7)
{code here}
else
{code here}

在汇编程序中,没有花括号,只有 goto。所以想一想,如果x == 0你已经知道你需要"then"代码,但是如果x != 0,你必须测试x == 7才能知道是否去"then" 代码或 "else" 代码。

由于 C 能够表达这种结构,我将用它来说明:

您的代码

if(x == 0 || x == 7)
    {code T here}
else
    {code E here}

相当于:

    if (x == 0) goto then;
    if (x == 7) goto then;
else: /* label is not actually needed */
    code E here
    goto after_it_all;
then:
    code T here
after_it_all:
    ;