2

Is there a way to perform a bitwise NAND operation on the bits in two registers in ARM7, either with the existing AND, OR and EOR operations or other instructions?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
user3001845
  • 465
  • 2
  • 7
  • 13

2 Answers2

8

and then mvn (move not).

From GCC explorer

int nand(int a, int b) {
    return ~(a & b);
}

nand(int, int):
    and r0, r0, r1
    mvn r0, r0
    bx  lr
auselen
  • 27,577
  • 7
  • 73
  • 114
1

Sure; AND the two registers and then EOR the result with all 1's (for the negation).

Scott Hunter
  • 48,888
  • 12
  • 60
  • 101
  • 1
    Note that `eor r0, #-1` is not encodeable; you'd need the all-ones constant in a register. That's what makes `mvn` a better choice. – Peter Cordes Nov 08 '20 at 02:59