Browse Source

docs: Update asm_thumb2_hints_tips re return type of asm funcs.

pull/1854/merge
Peter Hinch 9 years ago
committed by Damien George
parent
commit
70f32f0f73
  1. 22
      docs/reference/asm_thumb2_hints_tips.rst

22
docs/reference/asm_thumb2_hints_tips.rst

@ -78,11 +78,23 @@ three arguments, which must (if used) be named ``r0``, ``r1`` and ``r2``. When
the code executes the registers will be initialised to those values.
The data types which can be passed in this way are integers and memory
addresses. With current firmware all possible 32 bit values may be passed.
Returned integers are restricted in that the top two bits must be identical,
limiting the range to -2**30 to 2**30 -1. The limitations on number of arguments
and return values can be overcome by means of the ``array`` module which enables
any number of values of any type to be accessed.
addresses. With current firmware all possible 32 bit values may be passed and
returned. If the return value may have the most significant bit set a Python
type hint should be employed to enable MicroPython to determine whether the
value should be interpreted as a signed or unsigned integer: types are
``int`` or ``uint``.
::
@micropython.asm_thumb
def uadd(r0, r1) -> uint:
add(r0, r0, r1)
``hex(uadd(0x40000000,0x40000000))`` will return 0x80000000, demonstrating the
passing and return of integers where bits 30 and 31 differ.
The limitations on the number of arguments and return values can be overcome by means
of the ``array`` module which enables any number of values of any type to be accessed.
Multiple arguments
~~~~~~~~~~~~~~~~~~

Loading…
Cancel
Save