From 0f91ce6441f5a5ba2571d73b5bcea5ebf2ff8ad6 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 4 Aug 2019 19:40:31 +0200 Subject: [PATCH] removed a few more hazardous zp addresses --- .../compiler/target/c64/MachineDefinition.kt | 2 +- examples/test.p8 | 117 +++++++++++++++--- 2 files changed, 99 insertions(+), 20 deletions(-) diff --git a/compiler/src/prog8/compiler/target/c64/MachineDefinition.kt b/compiler/src/prog8/compiler/target/c64/MachineDefinition.kt index cc95f5ae8..9808df11c 100644 --- a/compiler/src/prog8/compiler/target/c64/MachineDefinition.kt +++ b/compiler/src/prog8/compiler/target/c64/MachineDefinition.kt @@ -86,7 +86,7 @@ object MachineDefinition { // add the other free Zp addresses, // these are valid for the C-64 (when no RS232 I/O is performed) but to keep BASIC running fully: - free.addAll(listOf(0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0d, 0x0e, + free.addAll(listOf(0x04, 0x05, 0x06, 0x0a, 0x0e, 0x94, 0x95, 0xa7, 0xa8, 0xa9, 0xaa, 0xb5, 0xb6, 0xf7, 0xf8, 0xf9)) } diff --git a/examples/test.p8 b/examples/test.p8 index 84365a1be..85998d3ec 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,32 +1,111 @@ %import c64utils %import c64flt -%zeropage basicsafe %option enable_floats +%zeropage basicsafe ; @todo dontuse main { - sub start() { - ubyte x=3 - ubyte y=2 - ubyte a=1 - ubyte s=0 - float repr=4.4 - ;memset(c64.Screen, 40, 1) - ;memset(c64.Screen+40, 80, 2) - A=x - A=y - Y=a - A=s + sub start() { + + ubyte ub=200 + byte bb=-100 + uword uw = 2000 + word ww = -1000 + float fl = 99.99 + + c64scr.print("++\n") + ub++ + bb++ + uw++ + ww++ + fl++ + + check_ub(ub, 201) + Y=100 + Y++ + check_ub(Y, 101) + check_fl(fl, 100.99) ; @todo CLOBBERS OTHER VARS + check_b(bb, -99) + check_uw(uw, 2001) + check_w(ww, -999) + + c64scr.print("--\n") + ub-- + bb-- + uw-- + ww-- + fl-- + check_ub(ub, 200) + Y=100 + Y-- + check_ub(Y, 99) + check_fl(fl, 99.99) ; @todo CLOBBERS OTHER VARS + check_b(bb, -100) + check_uw(uw, 2000) + check_w(ww, -1000) + + @($0400+39) = X + ;c64.Screen[39] = X ; @todo compiler error } - sub foo() { + sub check_ub(ubyte value, ubyte expected) { + if value==expected + c64scr.print(" ok ") + else + c64scr.print("err! ") + c64scr.print(" ubyte ") + c64scr.print_ub(value) + c64.CHROUT(',') + c64scr.print_ub(expected) + c64.CHROUT('\n') + } - x: - s: - y: - a: - A=3 + sub check_b(byte value, byte expected) { + if value==expected + c64scr.print(" ok ") + else + c64scr.print("err! ") + c64scr.print(" byte ") + c64scr.print_b(value) + c64.CHROUT(',') + c64scr.print_b(expected) + c64.CHROUT('\n') + } + sub check_uw(uword value, uword expected) { + if value==expected + c64scr.print(" ok ") + else + c64scr.print("err! ") + c64scr.print(" uword ") + c64scr.print_uw(value) + c64.CHROUT(',') + c64scr.print_uw(expected) + c64.CHROUT('\n') + } + + sub check_w(word value, word expected) { + if value==expected + c64scr.print(" ok ") + else + c64scr.print("err! ") + c64scr.print(" word ") + c64scr.print_w(value) + c64.CHROUT(',') + c64scr.print_w(expected) + c64.CHROUT('\n') + } + + sub check_fl(float value, float expected) { + if value==expected + c64scr.print(" ok ") + else + c64scr.print("err! ") + c64scr.print(" float ") + c64flt.print_f(value) + c64.CHROUT(',') + c64flt.print_f(expected) + c64.CHROUT('\n') } }