• micropython inline assembler

    From yeti@yeti@tilde.institute to tilde.python on Mon Feb 27 20:01:14 2023
    Is MiroPython's inline assembler expected to work on microcontrollers
    only? I don't get any example run on micropython-1.19 on Debian/pi1.

    PEBCAK?

    An example from the online doc:

    | $ cat quad.py
    | @micropython.asm_thumb
    | def quad(r0):
    | b(START)
    | label(DOUBLE)
    | add(r0, r0, r0)
    | bx(lr)
    | label(START)
    | bl(DOUBLE)
    | bl(DOUBLE)
    |
    | print(quad(10))
    | $ /opt/micropython/bin/micropython-standard quad.py
    | Traceback (most recent call last):
    | File "quad.py", line 1, in <module>
    | SyntaxError: invalid micropython decorator
    --
    Take Back Control! -- Mesh The Planet!
    Do you GNUS too? -- yeti@tickle-me--but-please-only-over-nntp--club
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.python on Thu Mar 2 19:39:13 2023
    * Inline Assembler for the Unix Port

    Invalid micropython decorator on Unix port #4675 \\ https://github.com/micropython/micropython/issues/4675

    TL;DR: It boils down to building the desired variant with an additional
    define:

    #+begin_example
    make CFLAGS_EXTRA='-DMICROPY_EMIT_INLINE_THUMB=1' VARIANT=...
    #+end_example

    Testing with an example from the docs...

    #+begin_example
    $ cat quad.py
    @micropython.asm_thumb
    def quad(r0):
    b(START)
    label(DOUBLE)
    add(r0, r0, r0)
    bx(lr)
    label(START)
    bl(DOUBLE)
    bl(DOUBLE)

    print(quad(10))
    $ micropython-standard quad.py
    Traceback (most recent call last):
    File "quad.py", line 1, in <module>
    SyntaxError: invalid micropython decorator
    $ micropython-standard+thumb quad.py
    40
    #+end_example

    * Happy(?) End.
    --
    Take Back Control! -- Mesh The Planet!
    Do you GNUS too? -- yeti@tickle-me--but-please-only-over-nntp--club
    --- Synchronet 3.19a-Linux NewsLink 1.113