1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-01 13:41:34 +00:00

Added some clarification to what inline assembly format specifiers do and don't do.

I just spent way too long debugging an error that happened because I assumed an integer passed to the inline assembler would be treated as one by the inline assembly, so this clarification should hopefully prevent any future cases of that.
This commit is contained in:
ToboterXP 2023-10-24 21:03:45 +02:00 committed by GitHub
parent bb1b5c363e
commit 547a1460e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1774,9 +1774,9 @@ as the arguments for replacing the format specifiers will be translated as
usual.
<itemize>
<item><tt/%b/ - Numerical 8-bit value
<item><tt/%w/ - Numerical 16-bit value
<item><tt/%l/ - Numerical 32-bit value
<item><tt/%b/ - Numerical 8-bit value ($xx)
<item><tt/%w/ - Numerical 16-bit value ($xxxx)
<item><tt/%l/ - Numerical 32-bit value ($xxxxxxxx)
<item><tt/%v/ - Assembler name of a global variable or function
<item><tt/%o/ - Stack offset of a local variable
<item><tt/%g/ - Assembler name of a C label
@ -1784,6 +1784,8 @@ usual.
<item><tt/%%/ - The % sign itself
</itemize><p>
Note: For a numerical value to be treated as an immediate value by the assembler, a # has to be added in front of the format specifier.
Using those format specifiers, you can access C <tt/#defines/, variables, or
similar stuff from the inline assembler. For example, to load the value of
a C <tt/#define/ into the Y index register, one would use