From 70f32f0f73b703aeeff4a9c9a1c63526ff4fabd8 Mon Sep 17 00:00:00 2001 From: Peter Hinch Date: Fri, 11 Mar 2016 10:47:00 +0000 Subject: [PATCH] docs: Update asm_thumb2_hints_tips re return type of asm funcs. --- docs/reference/asm_thumb2_hints_tips.rst | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/reference/asm_thumb2_hints_tips.rst b/docs/reference/asm_thumb2_hints_tips.rst index 119bf980ec..f0826e47ef 100644 --- a/docs/reference/asm_thumb2_hints_tips.rst +++ b/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 ~~~~~~~~~~~~~~~~~~