From 3d799ae7fe6f7f3010bd38573470711c47330ebf Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sat, 1 Jun 2024 15:03:01 +0200 Subject: [PATCH] todo --- docs/source/todo.rst | 4 +++- examples/test.p8 | 46 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 428fcb638..90bb59fbc 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -3,7 +3,9 @@ TODO https://github.com/irmen/prog8/issues/136 (string.find register order issue) -... +optimize signed byte/word division by powers of 2, it's now using divmod routine. (also % ?) + see inplacemodificationByteVariableWithLiteralval() and inplacemodificationSomeWordWithLiteralval() + Future Things and Ideas diff --git a/examples/test.p8 b/examples/test.p8 index 6cd45f85c..af9b00870 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,8 +1,52 @@ +%import textio %zeropage basicsafe %option no_sysinit main { sub start() { - cx16.scnsiz(20,8) + signed() + unsigned() + } + + sub signed() { + byte @shared bvalue = -100 + word @shared wvalue = -20000 + + bvalue /= 2 ; TODO should be a simple bit shift? + wvalue /= 2 ; TODO should be a simple bit shift? + + txt.print_b(bvalue) + txt.nl() + txt.print_w(wvalue) + txt.nl() + + bvalue *= 2 + wvalue *= 2 + + txt.print_b(bvalue) + txt.nl() + txt.print_w(wvalue) + txt.nl() + } + + sub unsigned() { + ubyte @shared ubvalue = 100 + uword @shared uwvalue = 20000 + + ubvalue /= 2 + uwvalue /= 2 + + txt.print_ub(ubvalue) + txt.nl() + txt.print_uw(uwvalue) + txt.nl() + + ubvalue *= 2 + uwvalue *= 2 + + txt.print_ub(ubvalue) + txt.nl() + txt.print_uw(uwvalue) + txt.nl() } }