From 686483f51aa229d76400d42ae62cbf08993a0797 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Wed, 10 Nov 2021 00:17:56 +0100 Subject: [PATCH] fixed division of signed byte number by 2. (!) --- .../cpu6502/codegen/ExpressionsAsmGen.kt | 2 +- examples/cx16/sincos.p8 | 3 -- examples/test.p8 | 39 ++++--------------- 3 files changed, 8 insertions(+), 36 deletions(-) diff --git a/codeGeneration/src/prog8/compiler/target/cpu6502/codegen/ExpressionsAsmGen.kt b/codeGeneration/src/prog8/compiler/target/cpu6502/codegen/ExpressionsAsmGen.kt index f7a240c65..bb995282b 100644 --- a/codeGeneration/src/prog8/compiler/target/cpu6502/codegen/ExpressionsAsmGen.kt +++ b/codeGeneration/src/prog8/compiler/target/cpu6502/codegen/ExpressionsAsmGen.kt @@ -528,7 +528,7 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge translateExpressionInternal(expr.left) when(leftDt) { DataType.UBYTE -> asmgen.out(" lsr P8ESTACK_LO+1,x") - DataType.BYTE -> asmgen.out(" asl P8ESTACK_LO+1,x | ror P8ESTACK_LO+1,x") + DataType.BYTE -> asmgen.out(" lda P8ESTACK_LO+1,x | asl a | ror P8ESTACK_LO+1,x") DataType.UWORD -> asmgen.out(" lsr P8ESTACK_HI+1,x | ror P8ESTACK_LO+1,x") DataType.WORD -> asmgen.out(" lda P8ESTACK_HI+1,x | asl a | ror P8ESTACK_HI+1,x | ror P8ESTACK_LO+1,x") else -> throw AssemblyError("wrong dt") diff --git a/examples/cx16/sincos.p8 b/examples/cx16/sincos.p8 index 7bef8d169..5cc3d38c5 100644 --- a/examples/cx16/sincos.p8 +++ b/examples/cx16/sincos.p8 @@ -77,8 +77,6 @@ main { ubyte r ; circles with "degrees" from 0 to 255 - -; TODO FIX WHEN USING NO-OPT! (CORRECT WHEN USING OPTIMIZATION..) for r in 0 to 255 { pixelxw = (sin8(r)/2 + 80) as uword pixelyb = (cos8(r)/2 + height/2) as ubyte @@ -92,7 +90,6 @@ main { } ; circles with half-degrees from 0 to 179 (=full degrees 0..358 with steps of 2 degrees) -; TODO FIX WHEN USING NO-OPT! (CORRECT WHEN USING OPTIMIZATION..) for r in 0 to 179 { pixelxw = (sinr8(r) as word /2 + 220) as uword pixelyb = (cosr8(r)/2 + height/2) as ubyte diff --git a/examples/test.p8 b/examples/test.p8 index 2d10fd38c..9458b4adb 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -4,39 +4,15 @@ main { - sub start() { + sub start() { + ubyte unused ; TODO FIX : why is this not removed as an unused variable? + ubyte @shared unused2 - ubyte ub=99 - byte bb=-99 - uword uw=9999 - word ww=-9999 - float ff - ff = 1.234 - ff += (ub as float) ; operator doesn't matter - floats.print_f(ff) - txt.nl() + ubyte bb + uword ww + ww = not bb or not ww ; TODO WHY DOES THIS USE STACK EVAL + } - ff = 1.234 - ff += (bb as float) ; operator doesn't matter - floats.print_f(ff) - txt.nl() - - ff = 1.234 - ff += (uw as float) ; operator doesn't matter - floats.print_f(ff) - txt.nl() - - ff = 1.234 - ff += (ww as float) ; operator doesn't matter - floats.print_f(ff) - txt.nl() - -; ubyte unused ; TODO FIX : why is this not removed as an unused variable? -; ubyte @shared unused2 -; -; ubyte bb -; uword ww -; ww = not bb or not ww ; TODO WHY DOES THIS USE STACK EVAL ; if not iteration_in_progress or not num_bytes ; return @@ -83,5 +59,4 @@ main { ; txt.nl() ; floats.print_f(fa[1]) - } }