docs about @zp tag

This commit is contained in:
Irmen de Jong 2019-02-28 00:13:59 +01:00
parent b8ae808b65
commit 5ea2f2d4db
3 changed files with 26 additions and 6 deletions

View File

@ -187,9 +187,13 @@ Values will usually be part of an expression or assignment statement::
byte counter = 42 ; variable of size 8 bits, with initial value 42
.. todo::
There must be a way to tell the compiler which variables you require to be in Zeropage:
``zeropage`` modifier keyword on vardecl perhaps?
*zeropage tag:*
If you add the ``@zp`` tag to the variable declaration, the compiler will prioritize this variable
when selecting variables to put into zero page. If there are enough free locations in the zeropage,
it will then try to fill it with as much other variables as possible (before they will be put in regular memory pages).
Example::
byte @zp zeropageCounter = 42
Variables that represent CPU hardware registers

View File

@ -213,9 +213,11 @@ Variable declarations
Variables should be declared with their exact type and size so the compiler can allocate storage
for them. You must give them an initial value as well. That value can be a simple literal value,
or an expression. The syntax is::
or an expression. You can add a ``@zp`` zeropage-tag, to tell the compiler to prioritize it
when selecting variables to be put into zeropage.
The syntax is::
<datatype> <variable name> [ = <initial value> ]
<datatype> [ @zp ] <variable name> [ = <initial value> ]
Various examples::
@ -228,6 +230,8 @@ Various examples::
byte[5] values = [11, 22, 33, 44, 55]
byte[5] values = 255 ; initialize with five 255 bytes
word @zp zpword = 9999 ; prioritize this when selecting vars for zeropage storage
Data types
@ -510,6 +514,13 @@ And this is a loop over the values of the array ``fibonacci_numbers`` where the
}
You can inline the loop variable declaration in the for statement, including optional zp-tag::
for ubyte @zp fastindex in 10 to 20 {
; do something
}
while loop
^^^^^^^^^^

View File

@ -5,10 +5,15 @@
; @todo see problem in looplabelproblem.p8
; @todo add docs for '@zp' tag in variable datatype declarations (including forloop loopvars)
; @todo gradle fatJar should include the antlr runtime jar
sub start() {
for ubyte @zp fastindex in 10 to 20 {
c64scr.print_ub(fastindex)
c64.CHROUT('\n')
; do something
}
}
}