3

在 ARM 汇编中执行此操作的最优雅的方法是什么?

If(x0 == x1 && y0 == y1)
  {
    ...
  }

假设所有值都已经在寄存器中

equal:
  cmp r2, r3
  beq are_equal
  b not_equal
check: 
  cmp r0, r1
  beq equal
not_equal:
4

2 回答 2

4

我在想这样的事情,但我必须再盯着它看……

cmp r2,r3
cmpeq r0,r1
bne skip
...
skip:
于 2013-06-11T14:42:22.623 回答
0

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.

于 2013-06-11T14:38:55.813 回答