From edf56d34f871c05b92abeb2b57a59272629b564e Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Mon, 6 Feb 2023 23:36:19 +0100 Subject: [PATCH 1/3] doc about no conditional compilation, fixes #93 also added a note to MEMTOP about 0 result --- compiler/res/prog8lib/cx16/syslib.p8 | 2 ++ docs/source/building.rst | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index e18ccabeb..a0d072d3c 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -462,6 +462,8 @@ inline asmsub getrambank() -> ubyte @A { asmsub numbanks() -> ubyte @A { ; -- uses MEMTOP's cx16 extension to query the number of available RAM banks. (each is 8 Kb) + ; Note: when 0 is returned, it doesn't mean 'zero banks', instead it means 256 banks (=2Mb banked RAM), + ; as there is no X16 without at least 1 page of banked RAM. %asm {{ phx sec diff --git a/docs/source/building.rst b/docs/source/building.rst index 7225359e0..592349988 100644 --- a/docs/source/building.rst +++ b/docs/source/building.rst @@ -202,7 +202,9 @@ You can create multiple source files yourself to modularize your large programs multiple module files. You can also create "library" modules this way with handy routines, that can be shared among programs. By importing those module files, you can use them in other modules. It is possible to tell the compiler where it should look for these files, by using -the ``srcdirs`` command line option. +the ``srcdirs`` command line option. This can also be a lo-fi way to use different source files +for different compilation targets if you wish. Which is useful as currently the compiler +doesn't have conditional compilation like #ifdef/#endif in C. .. _debugging: From 79d0fb0b52d5a68e535d98badba560c6e1498cd3 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Wed, 8 Feb 2023 00:51:34 +0100 Subject: [PATCH 2/3] cx16.numbanks() now returns a word because the result can be >255 --- compiler/res/prog8lib/cx16/syslib.p8 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index a0d072d3c..94f965a78 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -460,15 +460,23 @@ inline asmsub getrambank() -> ubyte @A { }} } -asmsub numbanks() -> ubyte @A { +asmsub numbanks() -> uword @AY { ; -- uses MEMTOP's cx16 extension to query the number of available RAM banks. (each is 8 Kb) - ; Note: when 0 is returned, it doesn't mean 'zero banks', instead it means 256 banks (=2Mb banked RAM), + ; Note that the number of such banks can be bigger than 255 so a word is returned, but mostly + ; the A register could suffice as the lsb. + ; The maximum number of banks is 256 = 2 Megabytes of banked Ram aka Hiram. (Y=1 and A=0 in this case). + ; MEMTOP itself reports 0 in this case which we change into 256 for convenience. + ; It reporting 0 doesn't mean 'zero banks', instead it means 256 banks (=2Mb banked RAM), ; as there is no X16 without at least 1 page of banked RAM. %asm {{ phx sec jsr c64.MEMTOP - plx + ldy #0 + cmp #0 + bne + + iny ++ plx rts }} } From 7b59bc8d121a6ed71764f0ef3afed51a8a5ab54e Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Wed, 8 Feb 2023 01:37:49 +0100 Subject: [PATCH 3/3] avoid division by zero if host fs hyperload is used which loads instantly --- examples/cx16/diskspeed.p8 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/cx16/diskspeed.p8 b/examples/cx16/diskspeed.p8 index 2bdefcb34..c5d8a2657 100644 --- a/examples/cx16/diskspeed.p8 +++ b/examples/cx16/diskspeed.p8 @@ -10,6 +10,10 @@ main { const ubyte REPEATS = 2 sub print_speed(uword jiffies) { + if jiffies==0 { + txt.print("\n 0 jiffies measured, speed is extremely high\n") + return + } float speed = 65536.0 * REPEATS / (jiffies as float / 60.0) txt.nl() txt.print_uw(jiffies)