mirror of
https://github.com/irmen/prog8.git
synced 2025-02-08 16:30:28 +00:00
docs about @zp tag
This commit is contained in:
parent
b8ae808b65
commit
5ea2f2d4db
@ -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
|
byte counter = 42 ; variable of size 8 bits, with initial value 42
|
||||||
|
|
||||||
|
|
||||||
.. todo::
|
*zeropage tag:*
|
||||||
There must be a way to tell the compiler which variables you require to be in Zeropage:
|
If you add the ``@zp`` tag to the variable declaration, the compiler will prioritize this variable
|
||||||
``zeropage`` modifier keyword on vardecl perhaps?
|
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
|
Variables that represent CPU hardware registers
|
||||||
|
@ -213,9 +213,11 @@ Variable declarations
|
|||||||
|
|
||||||
Variables should be declared with their exact type and size so the compiler can allocate storage
|
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,
|
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::
|
Various examples::
|
||||||
|
|
||||||
@ -228,6 +230,8 @@ Various examples::
|
|||||||
byte[5] values = [11, 22, 33, 44, 55]
|
byte[5] values = [11, 22, 33, 44, 55]
|
||||||
byte[5] values = 255 ; initialize with five 255 bytes
|
byte[5] values = 255 ; initialize with five 255 bytes
|
||||||
|
|
||||||
|
word @zp zpword = 9999 ; prioritize this when selecting vars for zeropage storage
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Data types
|
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
|
while loop
|
||||||
^^^^^^^^^^
|
^^^^^^^^^^
|
||||||
|
|
||||||
|
@ -5,10 +5,15 @@
|
|||||||
|
|
||||||
; @todo see problem in looplabelproblem.p8
|
; @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
|
; @todo gradle fatJar should include the antlr runtime jar
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
|
||||||
|
for ubyte @zp fastindex in 10 to 20 {
|
||||||
|
c64scr.print_ub(fastindex)
|
||||||
|
c64.CHROUT('\n')
|
||||||
|
; do something
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user