繁体   English   中英

如何实现逻辑OR || 在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}

在汇编器中,没有支撑块,只有gotos。 因此,请考虑一下,如果x == 0您已经知道需要“ then”代码,但是如果x != 0 ,则必须测试x == 7以查找是否要使用“ then”代码或“其他”代码。

由于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:
    ;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM