在 ARM 汇编中执行此操作的最优雅的方法是什么?
If(x0 == x1 && y0 == y1)
{
...
}
假设所有值都已经在寄存器中
equal:
cmp r2, r3
beq are_equal
b not_equal
check:
cmp r0, r1
beq equal
not_equal:
我在想这样的事情,但我必须再盯着它看……
cmp r2,r3
cmpeq r0,r1
bne skip
...
skip:
You could probably GCC generate some elegant code for you by doing this:
register int x0 asm ("r2");
register int x1 asm ("r3");
register int y0 asm ("r0");
register int y1 asm ("r1");
if(x0 == x1 && y0 == y1)
{
...
}
Compile this, then look at the disassembly.