diff --git a/codeGenIntermediate/src/prog8/codegen/intermediate/IRCodeGen.kt b/codeGenIntermediate/src/prog8/codegen/intermediate/IRCodeGen.kt index 1b15369c9..19235f17d 100644 --- a/codeGenIntermediate/src/prog8/codegen/intermediate/IRCodeGen.kt +++ b/codeGenIntermediate/src/prog8/codegen/intermediate/IRCodeGen.kt @@ -283,15 +283,10 @@ class IRCodeGen( else -> TODO("missing codegen for $node") } - chunks.forEach { chunk -> - require(chunk.isNotEmpty() || chunk.label != null) { - "chunk should have instructions and/or a label" - } - } + val nonEmptyChunks = chunks.filter { it.isNotEmpty() || it.label != null } + nonEmptyChunks.filterIsInstance().firstOrNull()?.appendSrcPosition(node.position) - chunks.filterIsInstance().firstOrNull()?.appendSrcPosition(node.position) - - return chunks + return nonEmptyChunks } private fun readBinaryData(node: PtIncludeBinary): Collection { diff --git a/docs/source/todo.rst b/docs/source/todo.rst index e1661ef9e..9a89fd16f 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -2,6 +2,9 @@ TODO ==== +- 10 * (uw/10) is correct, (uw/10) * 10 fails with -noopt 10 * (uw/10) needs -noopt to work correctly +- don't print the leading space in print_f() +- uword scanline_buf = memory("scanline", 320, 0) different result when inside a sub or outside a sub??! (imageviewer iff module) - [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 .... - once VAL_1 is merged into the kernal properly, remove all the workarounds in cx16 floats.parse_f() diff --git a/examples/test.p8 b/examples/test.p8 index dd2be98aa..64a8ec1ef 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,25 +1,13 @@ %import textio -%import floats -%import string %zeropage basicsafe %option no_sysinit main { sub start() { - str buffer = "???????????????????????????" - repeat { - txt.print("enter number: ") - void txt.input_chars(buffer) - txt.print("\nprog8's parse_f: ") - float value = floats.parse_f(buffer) - floats.print_f(value) - - ; floats.VAL_1 is defined as: - ; romsub $fe09 = VAL_1(uword string @XY, ubyte length @A) clobbers(A,X,Y) -> float @FAC1 -; txt.print("\nrom val_1: ") -; value = floats.VAL_1(buffer, string.length(buffer)) -; floats.print_f(value) - txt.nl() - } + ubyte uw = 97 + txt.print_ub( 10 * (uw/10) ) ; 90 + txt.nl() + txt.print_ub( (uw/10) * 10 ) ; 90 + txt.nl() } }