diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index 7fb5cb991..cefb3d982 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -67,7 +67,7 @@ asmsub STOP2() -> ubyte @A { } asmsub RDTIM16() -> uword @AY { - ; -- like RDTIM() but only returning the lower 16 bits in AY for convenience + ; -- like RDTIM() but only returning the lower 16 bits in AY for convenience. Also avoids ram bank issue for irqs. %asm {{ phx sei diff --git a/compiler/src/prog8/compiler/astprocessing/BeforeAsmAstChanger.kt b/compiler/src/prog8/compiler/astprocessing/BeforeAsmAstChanger.kt index 79dca48b1..e1a986b40 100644 --- a/compiler/src/prog8/compiler/astprocessing/BeforeAsmAstChanger.kt +++ b/compiler/src/prog8/compiler/astprocessing/BeforeAsmAstChanger.kt @@ -229,13 +229,13 @@ internal class BeforeAsmAstChanger(val program: Program, override fun after(arrayIndexedExpression: ArrayIndexedExpression, parent: Node): Iterable { - val containingStatement = getContainingStatement(arrayIndexedExpression) - if(getComplexArrayIndexedExpressions(containingStatement).size > 1) { - errors.err("it's not possible to use more than one complex array indexing expression in a single statement; break it up via a temporary variable for instance", containingStatement.position) - return noModifications - } + if(options.compTarget.name!=VMTarget.NAME) { // don't apply this optimization/check for Vm target + val containingStatement = getContainingStatement(arrayIndexedExpression) + if(getComplexArrayIndexedExpressions(containingStatement).size > 1) { + errors.err("it's not possible to use more than one complex array indexing expression in a single statement; break it up via a temporary variable for instance", containingStatement.position) + return noModifications + } - if(options.compTarget.name!=VMTarget.NAME) { // don't apply this optimization for Vm target val index = arrayIndexedExpression.indexer.indexExpr if (index !is NumericLiteral && index !is IdentifierReference) { // replace complex indexing expression with a temp variable to hold the computed index first diff --git a/docs/source/todo.rst b/docs/source/todo.rst index a12d4ec94..2b661be60 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -15,7 +15,7 @@ For 9.0 major changes - DONE: asmsub params or return values passed in cpu flags (like carry) now must be declared as booleans (previously ubyte was still accepted). - DONE: (on cx16) added diskio.save_raw() to save without the 2 byte prg header -- [much work:] add special (u)word array type (or modifier such as @fast? ) that puts the array into memory as 2 separate byte-arrays 1 for LSB 1 for MSB -> allows for word arrays of length 256 and faster indexing +- [much work:] add special (u)word array type (or modifier such as @fast or @split? ) that puts the array into memory as 2 separate byte-arrays 1 for LSB 1 for MSB -> allows for word arrays of length 256 and faster indexing this is an enormous amout of work, if this type is to be treated equally as existing (u)word , because all expression / lookup / assignment routines need to know about the distinction.... So maybe only allow the bare essentials? (store, get, ++/--/+/-, bitwise operations?) - [much work:] more support for (64tass) SEGMENTS ? diff --git a/examples/test.p8 b/examples/test.p8 index 4f85e4ead..c1ae9a19f 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -5,44 +5,12 @@ main { sub start() { - word ww = -1234 - uword uww = 1234 - float fl = 123.34 - byte bb = -123 - ubyte ub = 123 + ubyte[] array = [ $00, $11, $22, $33, $44, $55, $66, $77, $88, $99, $aa, $bb] - txt.print_w(clamp(ww, -2000, -500)) - txt.spc() - txt.print_w(clamp(ww, -1000, -500)) - txt.spc() - txt.print_w(clamp(ww, -2000, -1500)) - txt.nl() - txt.print_uw(clamp(uww, 500, 2000)) - txt.spc() - txt.print_uw(clamp(uww, 500, 1000)) - txt.spc() - txt.print_uw(clamp(uww, 1500, 2000)) - txt.nl() - - txt.print_b(clamp(bb, -127, -50)) - txt.spc() - txt.print_b(clamp(bb, -100, -50)) - txt.spc() - txt.print_b(clamp(bb, -127, -125)) - txt.nl() - txt.print_ub(clamp(ub, 50, 200)) - txt.spc() - txt.print_ub(clamp(ub, 50, 100)) - txt.spc() - txt.print_ub(clamp(ub, 150, 200)) - txt.nl() - - floats.print_f(floats.clampf(fl, 50.0, 200.0)) - txt.spc() - floats.print_f(floats.clampf(fl, 50.0, 100.0)) - txt.spc() - floats.print_f(floats.clampf(fl, 150.0, 200.0)) - txt.nl() + ubyte x = 2 + ubyte y = 3 + txt.print_uwhex(mkword(array[9], array[8]), true) + txt.print_uwhex(mkword(array[x*y+y], array[y*x+x]), true) } }