mirror of
https://github.com/irmen/prog8.git
synced 2025-01-11 13:29:45 +00:00
docs for @requirezp
This commit is contained in:
parent
a3b5c2ad71
commit
87220c6697
@ -199,13 +199,19 @@ Values will usually be part of an expression or assignment statement::
|
||||
byte counter = 42 ; variable of size 8 bits, with initial value 42
|
||||
|
||||
|
||||
*zeropage tag:*
|
||||
*putting a variable in zeropage:*
|
||||
If you add the ``@zp`` tag to the variable declaration, the compiler will prioritize this variable
|
||||
when selecting variables to put into zero page (but no guarantees). If there are enough free locations in the zeropage,
|
||||
it will try to fill it with as much other variables as possible (before they will be put in regular memory pages).
|
||||
Use ``@requirezp`` tag to *force* the variable into zeropage, but if there is no more free space the compilation will fail.
|
||||
It's possible to put strings, arrays and floats into zeropage too, however because Zp space is really scarce
|
||||
this is not advised as they will eat up the available space very quickly. It's best to only put byte or word
|
||||
variables in Zeropage.
|
||||
|
||||
Example::
|
||||
|
||||
byte @zp zeropageCounter = 42
|
||||
byte @zp smallcounter = 42
|
||||
uword @requirezp zppointer = $4000
|
||||
|
||||
|
||||
*shared tag:*
|
||||
|
@ -268,11 +268,13 @@ or an expression. If you don't provide an intial value yourself, zero will be us
|
||||
You can add a ``@zp`` zeropage-tag, to tell the compiler to prioritize it
|
||||
when selecting variables to be put into zeropage (but no guarantees). If the ZP is full,
|
||||
the variable will be allocated in normal memory elsewhere.
|
||||
Use the ``@requirezp`` tag to force the variable in zeropage, but if the ZP is full,
|
||||
the compilation will fail.
|
||||
You can add a ``@shared`` shared-tag, to tell the compiler that the variable is shared
|
||||
with some assembly code and that it should not be optimized away if not used elsewhere.
|
||||
The syntax is::
|
||||
|
||||
<datatype> [ @shared ] [ @zp ] <variable name> [ = <initial value> ]
|
||||
<datatype> [ @shared ] [ @zp ] [ @requirezp ] <variable name> [ = <initial value> ]
|
||||
|
||||
Various examples::
|
||||
|
||||
@ -287,7 +289,8 @@ Various examples::
|
||||
byte[5] values ; array of 5 bytes, initially set to zero
|
||||
byte[5] values = 255 ; initialize with five 255 bytes
|
||||
|
||||
word @zp zpword = 9999 ; prioritize this when selecting vars for zeropage storage
|
||||
word @zp zpword = 9999 ; prioritize this when selecting vars for zeropage storage
|
||||
uword @requirezp zpaddr = $3000 ; we require this variable in Zeropage
|
||||
word @shared asmvar ; variable is used in assembly code but not elsewhere
|
||||
|
||||
|
||||
|
@ -3,9 +3,7 @@ TODO
|
||||
|
||||
For next compiler release (7.7)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
- check all examples if they still run correctly (c64 + cx16)
|
||||
- document that arrays and strings can also be placed in zeropage (but almost never should, due to size!)
|
||||
- document @requirezp
|
||||
...
|
||||
|
||||
|
||||
Need help with
|
||||
|
Loading…
x
Reference in New Issue
Block a user