[英]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.