diff --git a/docs/source/programming.rst b/docs/source/programming.rst index 61d79f7f8..ba5bcc86f 100644 --- a/docs/source/programming.rst +++ b/docs/source/programming.rst @@ -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:* diff --git a/docs/source/syntaxreference.rst b/docs/source/syntaxreference.rst index 95a8e15f9..ffe04c4a3 100644 --- a/docs/source/syntaxreference.rst +++ b/docs/source/syntaxreference.rst @@ -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:: - [ @shared ] [ @zp ] [ = ] + [ @shared ] [ @zp ] [ @requirezp ] [ = ] 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 diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 068d4ef42..679c05fcc 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -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