假设我有一个要比较的数据寄存器,并且我必须将它与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}发布于 2019-03-23 11:11:59
在汇编程序中,没有带括号的块,只有goto。所以想一想,如果你已经知道你需要"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:
;https://stackoverflow.com/questions/55310057
复制相似问题