[英]How to implement logical OR || in an if() condition in easy68k?
Suppose I have a to compare a data register and i have to compare it to equalling one of 2 numbers. 假设我必须比较一个数据寄存器,并且必须将其与等于2个数字之一进行比较。 how would i go about that? 我该怎么办?
I know how to do it for just comparing with one number not 2. 我知道如何只比较一个数字而不是2。
CMP #0, D3
BNE ELSE
REST OF THE CODE HERE
How do i compare for when I want to compare it with either 0 or some other number like 7. In c++ you would say 当我想将其与0或其他一些数字(例如7)进行比较时,如何比较?在c ++中,您会说
if(x == 0 || x == 7)
{code here}
else
{code here}
In assembler, there are no braced blocks, only gotos. 在汇编器中,没有支撑块,只有gotos。 So think about it, if x == 0
you already know you need the "then" code, but if x != 0
, you have to test x == 7
to find out whether to go to the "then" code or the "else" code. 因此,请考虑一下,如果x == 0
您已经知道需要“ then”代码,但是如果x != 0
,则必须测试x == 7
以查找是否要使用“ then”代码或“其他”代码。
Since C is capable of expressing this structure, I'll use that to illustrate: 由于C能够表达这种结构,因此我将用它来说明:
Your code 您的密码
if(x == 0 || x == 7)
{code T here}
else
{code E here}
is equivalent to: 等效于:
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.