asm_thumb2_arith.rst 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. Arithmetic instructions
  2. =======================
  3. Document conventions
  4. --------------------
  5. Notation: ``Rd, Rm, Rn`` denote ARM registers R0-R7. ``immN`` denotes an immediate
  6. value having a width of N bits e.g. ``imm8``, ``imm3``. ``carry`` denotes
  7. the carry condition flag, ``not(carry)`` denotes its complement. In the case of instructions
  8. with more than one register argument, it is permissible for some to be identical. For example
  9. the following will add the contents of R0 to itself, placing the result in R0:
  10. * add(r0, r0, r0)
  11. Arithmetic instructions affect the condition flags except where stated.
  12. Addition
  13. --------
  14. * add(Rdn, imm8) ``Rdn = Rdn + imm8``
  15. * add(Rd, Rn, imm3) ``Rd = Rn + imm3``
  16. * add(Rd, Rn, Rm) ``Rd = Rn +Rm``
  17. * adc(Rd, Rn) ``Rd = Rd + Rn + carry``
  18. Subtraction
  19. -----------
  20. * sub(Rdn, imm8) ``Rdn = Rdn - imm8``
  21. * sub(Rd, Rn, imm3) ``Rd = Rn - imm3``
  22. * sub(Rd, Rn, Rm) ``Rd = Rn - Rm``
  23. * sbc(Rd, Rn) ``Rd = Rd - Rn - not(carry)``
  24. Negation
  25. --------
  26. * neg(Rd, Rn) ``Rd = -Rn``
  27. Multiplication and division
  28. ---------------------------
  29. * mul(Rd, Rn) ``Rd = Rd * Rn``
  30. This produces a 32 bit result with overflow lost. The result may be treated as
  31. signed or unsigned according to the definition of the operands.
  32. * sdiv(Rd, Rn, Rm) ``Rd = Rn / Rm``
  33. * udiv(Rd, Rn, Rm) ``Rd = Rn / Rm``
  34. These functions perform signed and unsigned division respectively. Condition flags
  35. are not affected.