From ae6eeadf54117a7184f7b9009b6362c4fe0faea9 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Mon, 25 Sep 2023 22:41:58 +0200 Subject: [PATCH] doc about range step value has to be a constant --- docs/source/syntaxreference.rst | 4 +++- docs/source/todo.rst | 1 + examples/cx16/chunkedfile/mcf.p8 | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/source/syntaxreference.rst b/docs/source/syntaxreference.rst index 5ead81555..7431de138 100644 --- a/docs/source/syntaxreference.rst +++ b/docs/source/syntaxreference.rst @@ -450,7 +450,8 @@ from the starting value to (and including) the ending value:: downto [ step ] 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:: 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 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). +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:: diff --git a/docs/source/todo.rst b/docs/source/todo.rst index ce8b7e183..c6d30154f 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -58,6 +58,7 @@ Libraries: 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? 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, diff --git a/examples/cx16/chunkedfile/mcf.p8 b/examples/cx16/chunkedfile/mcf.p8 index 6b198ff5f..bd337d26f 100644 --- a/examples/cx16/chunkedfile/mcf.p8 +++ b/examples/cx16/chunkedfile/mcf.p8 @@ -179,7 +179,7 @@ processchunk_call jsr $ffff ; modified cx16.r3 = address while size { ubyte readsize = 255 - if size < 255 + if msb(size)==0 readsize = lsb(size) cx16.r2 = cx16.macptr(readsize, bonkbuffer, false) ; can't macptr directly to bonk ram cx16.rombank(bonk)