Skip to content
Snippets Groups Projects
Commit 70f32f0f authored by Peter Hinch's avatar Peter Hinch Committed by Damien George
Browse files

docs: Update asm_thumb2_hints_tips re return type of asm funcs.

parent 3d0e3a3d
No related branches found
No related tags found
No related merge requests found
...@@ -78,11 +78,23 @@ three arguments, which must (if used) be named ``r0``, ``r1`` and ``r2``. When ...@@ -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 code executes the registers will be initialised to those values.
The data types which can be passed in this way are integers and memory 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. addresses. With current firmware all possible 32 bit values may be passed and
Returned integers are restricted in that the top two bits must be identical, returned. If the return value may have the most significant bit set a Python
limiting the range to -2**30 to 2**30 -1. The limitations on number of arguments type hint should be employed to enable MicroPython to determine whether the
and return values can be overcome by means of the ``array`` module which enables value should be interpreted as a signed or unsigned integer: types are
any number of values of any type to be accessed. ``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 Multiple arguments
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment