Skip to content

Commit

Permalink
more caution notices about symbols in inlined asm
Browse files Browse the repository at this point in the history
  • Loading branch information
irmen committed Jul 22, 2023
1 parent 0e781d1 commit 3bbc00c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions docs/source/syntaxreference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ Directives
assembly into a prog8 block that already defines symbols itself.
The compiler first looks for the file relative to the same directory as the module containing this statement is in,
if the file can't be found there it is searched relative to the current directory.

.. caution::
Avoid using single-letter symbols in included assembly code, as they could be confused with CPU registers.
Also, note that all prog8 symbols are prefixed in assembly code, see :ref:`symbol-prefixing`.

Here is a small example program to show how to use labels to reference the included contents from prog8 code::

%import textio
Expand Down Expand Up @@ -221,8 +226,11 @@ Directives

If you use the correct scoping rules you can access symbols from the prog8 program from inside
the assembly code. Sometimes you'll have to declare a variable in prog8 with `@shared` if it
is only used in such assembly code. For symbols just consisting of 3 letters, prog8 will
add a special prefix to them, read more about this in :ref:`symbol-prefixing`.
is only used in such assembly code.

.. caution::
Avoid using single-letter symbols in included assembly code, as they could be confused with CPU registers.
Also, note that all prog8 symbols are prefixed in assembly code, see :ref:`symbol-prefixing`.


Identifiers
Expand Down

0 comments on commit 3bbc00c

Please sign in to comment.