|
| 1 | +This chapter documents the language features accepted by the `adafruit_pioasm` |
| 2 | +assembler. The dialect is intended to be a compatible subset of the one in the |
| 3 | +pico-sdk's ``pioasm`` program (which does not produce CircuitPython-compatible |
| 4 | +output). |
| 5 | + |
| 6 | +For full details, refer to the relevant chapter in the RP2040 or RP2350 datasheet. |
| 7 | + |
| 8 | +In this informal grammar, ``<angle brackets>`` represent some text, usually a single |
| 9 | +word or number. ``{curly brackets}`` represent an element that is optional. |
| 10 | +``|`` represents alternatives. ``...`` indicates further arguments that are |
| 11 | +explained in the official datasheet. |
| 12 | + |
| 13 | +Lines |
| 14 | +~~~~~ |
| 15 | + |
| 16 | +First, any portion of the line starting with the comment character ``;`` is removed. |
| 17 | +Then, extra whitespace is removed and the line is parsed. |
| 18 | + |
| 19 | +Each line may be: |
| 20 | + * blank |
| 21 | + * a directive |
| 22 | + * a label |
| 23 | + * an instruction, possibly with side-set and delay information |
| 24 | + |
| 25 | +Directives |
| 26 | +---------- |
| 27 | + |
| 28 | + * ``.program <identifier>``: Accepts a program name, which should be a valid Python identifier |
| 29 | + * ``.pio_version <number>``: The numeric version of the PIO peripheral to target. Version 0, the default, is in the RP2040. Version 1 is in RP2350 |
| 30 | + * ``.origin <number>``: The required load address of the program. If specified and not ``-1``, this will be stored in ``pio_kwargs["offset"]`` |
| 31 | + * ``.wrap``, ``.wrap_target``: This pair of directives set the range of instructions for implicit looping, by placing values in ``pio_kwargs`` |
| 32 | + * ``.side_set <number> {opt}``: Controls the side-set behavior and sets ``pio_kwargs["sideset_enable"]`` and ``pio_kwargs["sideset_pin_count"]`` |
| 33 | + * ``.fifo <identifier>``: Sets the FIFO mode. As a CircuitPython extension, ``auto`` (the default) automatically chooses among ``txrx``, ``tx``, and ``rx`` modes |
| 34 | + * ``.mov_status ...``: Controls what information the ``mov status`` instruction accesses, by placing values in ``pio_kwargs`` |
| 35 | + * ``.out <count> {{left|right}} {{auto}}``: Settings that control how the ``out`` instruction works, including shift direction and whether auto pull is enabled, by placing values in ``pio_kwargs`` |
| 36 | + * ``.in <count> {{left|right}} {{auto}}``: Settings that control how the ``in`` instruction works, including shift direction and whether auto push is enabled, by placing values in ``pio_kwargs`` |
| 37 | + * ``.set <count>``: Settings that control how the ``set`` instruction works, including shift direction and whether auto push is enabled, by placing values in ``pio_kwargs`` |
| 38 | + |
| 39 | +Labels |
| 40 | +------ |
| 41 | + |
| 42 | + * ``<identifier>:`` creates a label which may be referred to by a ``jmp`` instruction. |
| 43 | + |
| 44 | +Instructions |
| 45 | +------------ |
| 46 | + |
| 47 | + * ``nop`` |
| 48 | + * ``jmp <number|name>`` |
| 49 | + * ``wait ...`` |
| 50 | + * ``in ...`` |
| 51 | + * ``out ...`` |
| 52 | + * ``push ...`` |
| 53 | + * ``pull ...`` |
| 54 | + * ``mov ...`` |
| 55 | + * ``irq ...`` |
| 56 | + * ``set ...`` |
| 57 | + |
| 58 | +Side-set and delay |
| 59 | +------------------ |
| 60 | +The next part of each line can contain "side-set" and "delay" information, in order. |
| 61 | + |
| 62 | + * ``side <number>``: Set the side-set pins to ``number`` |
| 63 | + * ``[<number>]``: Add ``number`` extra delay cycles to this instruction |
| 64 | + |
| 65 | +The range of these numbers depends on the count of side-set pins and whether side-set is |
| 66 | +optional. If side-set is not optional, a missing ``side <number>`` is treated the same as |
| 67 | +``side 0``. |
| 68 | + |
| 69 | +Unsupported Features |
| 70 | +-------------------- |
| 71 | + |
| 72 | +In places where a numeric value is needed, only a valid Python numeric literal |
| 73 | +is accepted. Arithmetic is not supported. |
| 74 | + |
| 75 | +Whitespace is not accepted in certain places, for instance within an instruction delay. |
| 76 | +It must be written ``[7]`` not ``[ 7 ]``. |
| 77 | + |
| 78 | +Extra |
| 79 | +CircuitPython extensions |
| 80 | +------------------------ |
| 81 | + |
| 82 | +* ``.fifo auto``: By default, CircuitPython joins the TX and RX fifos if a PIO program only receives or transmits. The ``.fifo auto`` directive makes this explicit. |
0 commit comments