Skip to content

Commit 70f32f0

Browse files
peterhinchdpgeorge
authored andcommitted
docs: Update asm_thumb2_hints_tips re return type of asm funcs.
1 parent 3d0e3a3 commit 70f32f0

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

docs/reference/asm_thumb2_hints_tips.rst

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,23 @@ three arguments, which must (if used) be named ``r0``, ``r1`` and ``r2``. When
7878
the code executes the registers will be initialised to those values.
7979

8080
The data types which can be passed in this way are integers and memory
81-
addresses. With current firmware all possible 32 bit values may be passed.
82-
Returned integers are restricted in that the top two bits must be identical,
83-
limiting the range to -2**30 to 2**30 -1. The limitations on number of arguments
84-
and return values can be overcome by means of the ``array`` module which enables
85-
any number of values of any type to be accessed.
81+
addresses. With current firmware all possible 32 bit values may be passed and
82+
returned. If the return value may have the most significant bit set a Python
83+
type hint should be employed to enable MicroPython to determine whether the
84+
value should be interpreted as a signed or unsigned integer: types are
85+
``int`` or ``uint``.
86+
87+
::
88+
89+
@micropython.asm_thumb
90+
def uadd(r0, r1) -> uint:
91+
add(r0, r0, r1)
92+
93+
``hex(uadd(0x40000000,0x40000000))`` will return 0x80000000, demonstrating the
94+
passing and return of integers where bits 30 and 31 differ.
95+
96+
The limitations on the number of arguments and return values can be overcome by means
97+
of the ``array`` module which enables any number of values of any type to be accessed.
8698

8799
Multiple arguments
88100
~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)