doc about range step value has to be a constant

This commit is contained in:
Irmen de Jong 2023-09-25 22:41:58 +02:00
parent 5268b05060
commit ae6eeadf54
3 changed files with 5 additions and 2 deletions

View File

@ -450,7 +450,8 @@ from the starting value to (and including) the ending value::
<start> downto <end> [ step <step> ] <start> downto <end> [ step <step> ]
You an provide a step value if you need something else than the default increment which is one (or, You an provide a step value if you need something else than the default increment which is one (or,
in case of downto, a decrement of one). Because a step of minus one is so common you can just use in case of downto, a decrement of one). Unlike the start and end values, the step value must be a constant.
Because a step of minus one is so common you can just use
the downto variant to avoid having to specify the step as well:: the downto variant to avoid having to specify the step as well::
0 to 7 ; range of values 0, 1, 2, 3, 4, 5, 6, 7 0 to 7 ; range of values 0, 1, 2, 3, 4, 5, 6, 7
@ -729,6 +730,7 @@ for loop
The loop variable must be a byte or word variable, and it must be defined separately first. The loop variable must be a byte or word variable, and it must be defined separately first.
The expression that you loop over can be anything that supports iteration (such as ranges like ``0 to 100``, The expression that you loop over can be anything that supports iteration (such as ranges like ``0 to 100``,
array variables and strings) *except* floating-point arrays (because a floating-point loop variable is not supported). array variables and strings) *except* floating-point arrays (because a floating-point loop variable is not supported).
Remember that a step value in a range must be a constant value.
You can use a single statement, or a statement block like in the example below:: You can use a single statement, or a statement block like in the example below::

View File

@ -58,6 +58,7 @@ Libraries:
Optimizations: Optimizations:
- treat every scalar variable decl with initialization value, as const by default, unless the variable gets assigned to somewhere (or has its address taken, or is @shared)
- VariableAllocator: can we think of a smarter strategy for allocating variables into zeropage, rather than first-come-first-served? - VariableAllocator: can we think of a smarter strategy for allocating variables into zeropage, rather than first-come-first-served?
for instance, vars used inside loops first, then loopvars, then uwords used as pointers, then the rest for instance, vars used inside loops first, then loopvars, then uwords used as pointers, then the rest
- various optimizers skip stuff if compTarget.name==VMTarget.NAME. Once 6502-codegen is done from IR code, - various optimizers skip stuff if compTarget.name==VMTarget.NAME. Once 6502-codegen is done from IR code,

View File

@ -179,7 +179,7 @@ processchunk_call jsr $ffff ; modified
cx16.r3 = address cx16.r3 = address
while size { while size {
ubyte readsize = 255 ubyte readsize = 255
if size < 255 if msb(size)==0
readsize = lsb(size) readsize = lsb(size)
cx16.r2 = cx16.macptr(readsize, bonkbuffer, false) ; can't macptr directly to bonk ram cx16.r2 = cx16.macptr(readsize, bonkbuffer, false) ; can't macptr directly to bonk ram
cx16.rombank(bonk) cx16.rombank(bonk)