Page 1 of 1

Use of "@micropython.asm_xtensa"

Posted: Tue Apr 04, 2017 11:44 am
by jcea
As documented in the changelog (https://github.com/micropython/micropython/releases) of release 1.8.7, we have a native assembler emitter. https://github.com/micropython/micropyt ... d2db3ff4a3 shows it as "@micropython.asm_xtensa". I don't see any kind of documentation or example.

I am trying to use it with no success:

Code: Select all

>>> @micropython.asm_xtensa
... def a(x):
...     add(a2, a2, a2)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SyntaxError: invalid micropython decorator
Any hint?.

Thanks!!

Re: Use of "@micropython.asm_xtensa"

Posted: Tue Apr 04, 2017 2:59 pm
by jcea
Errr... I inadvertently tried this under Micropython 1.8.6. Sory for wasting your time.

As an example of what can be done:

Code: Select all

>>> @micropython.asm_xtensa
... def a(a2, a3):
...     mov(a4, a2)
...     movi(a2, 0)
...     movi(a5, 1)
...     label(LOOP)
...     add(a2, a2, a4)
...     sub(a3, a3, a5)
...     bnez(a3, LOOP)

>>> a(1, 3)
3
>>> a(2, 3)
6
>>> a(10, 3)
30
>>> a(10,30)
300

Re: Use of "@micropython.asm_xtensa"

Posted: Tue Apr 04, 2017 3:14 pm
by Roberthh
Another example is here, which accesses the GPIO port diectly:
viewtopic.php?f=16&t=2917&p=17298&hilit=toggle#p17298