Assembly ARM汇编:如何设置多个用于执行指令的比较?

Assembly ARM汇编:如何设置多个用于执行指令的比较?,assembly,arm,Assembly,Arm,我尝试在不使用跳转指令的情况下将此代码更改为ARM: if a == 0 || b == 1 then c:=10 else c:=20; if d == 0 && e == 1 then f:=30 else c:=40; 我这样做是为了第一个循环。但我不能肯定这一点。这是真的吗 CMP r0, #0 ; compare if a=0 CMP r1, #1 ; compare if b=0 MOVEQ r3, #10 MOVNE r3, #20 第二个怎么

我尝试在不使用跳转指令的情况下将此代码更改为ARM:

if a == 0 || b == 1 then c:=10  else c:=20;

if d == 0 && e == 1 then f:=30  else c:=40;
我这样做是为了第一个循环。但我不能肯定这一点。这是真的吗

CMP r0, #0    ; compare if a=0
CMP r1, #1    ; compare if b=0
MOVEQ r3, #10
MOVNE r3, #20
第二个怎么做

if a == 0 || b == 1 then c:=10  else c:=20;
这里要做的是比较条件的一部分。如果该部分为真,则整个条件为真,因为只要
x
y
中至少有一个为真,则
x或
y
为真。如果第一部分为false,则计算第二部分。因此,这将成为:

CMP r0, #0      ; compare a with 0
CMPNE r1, #1    ; compare b with 1 if a!=0
MOVEQ r3, #10   ; a is 0, and/or b is 1 -> set c = 10
MOVNE r3, #20   ; a is not 0, and b is not 1 -> set c = 20

这里您需要计算条件的一部分,然后仅当第一部分为真时才计算第二部分。如果两部分均为真,则整个条件为真,否则为假:

CMP r0, #0      ; compare d with 0
CMPEQ r1, #1    ; compare e with 1 if d==0
MOVEQ r3, #30   ; d is 0, and e is 1 -> set f = 30
MOVNE r3, #40   ; d isn't 0, and/or e isn't 1 -> set f = 40
或者类似的例子出现在David Seal的ARM“建筑手册”中。
CMP r0, #0      ; compare d with 0
CMPEQ r1, #1    ; compare e with 1 if d==0
MOVEQ r3, #30   ; d is 0, and e is 1 -> set f = 30
MOVNE r3, #40   ; d isn't 0, and/or e isn't 1 -> set f = 40