Use of "@micropython.asm_xtensa"

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
jcea
Posts: 27
Joined: Fri Mar 18, 2016 5:28 pm

Use of "@micropython.asm_xtensa"

Post by jcea » Tue Apr 04, 2017 11:44 am

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!!

jcea
Posts: 27
Joined: Fri Mar 18, 2016 5:28 pm

Re: Use of "@micropython.asm_xtensa"

Post by jcea » Tue Apr 04, 2017 2:59 pm

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

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Use of "@micropython.asm_xtensa"

Post by Roberthh » Tue Apr 04, 2017 3:14 pm

Another example is here, which accesses the GPIO port diectly:
viewtopic.php?f=16&t=2917&p=17298&hilit=toggle#p17298

Post Reply