asm_thumb2_logical_bit.rst 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. Logical & Bitwise instructions
  2. ==============================
  3. Document conventions
  4. --------------------
  5. Notation: ``Rd, Rn`` denote ARM registers R0-R7 except in the case of the
  6. special instructions where R0-R15 may be used. ``Rn<a-b>`` denotes an ARM register
  7. whose contents must lie in range ``a <= contents <= b``. In the case of instructions
  8. with two register arguments, it is permissible for them to be identical. For example
  9. the following will zero R0 (Python ``R0 ^= R0``) regardless of its initial contents.
  10. * eor(r0, r0)
  11. These instructions affect the condition flags except where stated.
  12. Logical instructions
  13. --------------------
  14. * and\_(Rd, Rn) ``Rd &= Rn``
  15. * orr(Rd, Rn) ``Rd |= Rn``
  16. * eor(Rd, Rn) ``Rd ^= Rn``
  17. * mvn(Rd, Rn) ``Rd = Rn ^ 0xffffffff`` i.e. Rd = 1's complement of Rn
  18. * bic(Rd, Rn) ``Rd &= ~Rn`` bit clear Rd using mask in Rn
  19. Note the use of "and\_" instead of "and", because "and" is a reserved keyword in Python.
  20. Shift and rotation instructions
  21. -------------------------------
  22. * lsl(Rd, Rn<0-31>) ``Rd <<= Rn``
  23. * lsr(Rd, Rn<1-32>) ``Rd = (Rd & 0xffffffff) >> Rn`` Logical shift right
  24. * asr(Rd, Rn<1-32>) ``Rd >>= Rn`` arithmetic shift right
  25. * ror(Rd, Rn<1-31>) ``Rd = rotate_right(Rd, Rn)`` Rd is rotated right Rn bits.
  26. A rotation by (for example) three bits works as follows. If Rd initially
  27. contains bits ``b31 b30..b0`` after rotation it will contain ``b2 b1 b0 b31 b30..b3``
  28. Special instructions
  29. --------------------
  30. Condition codes are unaffected by these instructions.
  31. * clz(Rd, Rn) ``Rd = count_leading_zeros(Rn)``
  32. count_leading_zeros(Rn) returns the number of binary zero bits before the first binary one bit in Rn.
  33. * rbit(Rd, Rn) ``Rd = bit_reverse(Rn)``
  34. bit_reverse(Rn) returns the bit-reversed contents of Rn. If Rn contains bits ``b31 b30..b0`` Rd will be set
  35. to ``b0 b1 b2..b31``
  36. Trailing zeros may be counted by performing a bit reverse prior to executing clz.