From c0a1b1b887af536612987847c9344a1226bf4397 Mon Sep 17 00:00:00 2001 From: Kugel Fuhr <98353208+kugelfuhr@users.noreply.github.com> Date: Tue, 24 Jun 2025 18:02:24 +0200 Subject: [PATCH 1/7] Add an optimization step that removes compare instructions preceeding an RTS. Since nothing is passed back in the flags, these instructions have no effect. Fixes #2025. --- src/cc65/codeopt.c | 3 +++ src/cc65/coptcmp.c | 37 +++++++++++++++++++++++++++++++++++++ src/cc65/coptcmp.h | 5 +++++ 3 files changed, 45 insertions(+) diff --git a/src/cc65/codeopt.c b/src/cc65/codeopt.c index 19acfde74..f57417526 100644 --- a/src/cc65/codeopt.c +++ b/src/cc65/codeopt.c @@ -136,6 +136,7 @@ static OptFunc DOptCmp5 = { OptCmp5, "OptCmp5", 100, 0, static OptFunc DOptCmp7 = { OptCmp7, "OptCmp7", 85, 0, 0, 0, 0, 0 }; static OptFunc DOptCmp8 = { OptCmp8, "OptCmp8", 50, 0, 0, 0, 0, 0 }; static OptFunc DOptCmp9 = { OptCmp9, "OptCmp9", 85, 0, 0, 0, 0, 0 }; +static OptFunc DOptCmp10 = { OptCmp10, "OptCmp10", 33, 0, 0, 0, 0, 0 }; static OptFunc DOptComplAX1 = { OptComplAX1, "OptComplAX1", 65, 0, 0, 0, 0, 0 }; static OptFunc DOptCondBranch1 = { OptCondBranch1, "OptCondBranch1", 80, 0, 0, 0, 0, 0 }; static OptFunc DOptCondBranch2 = { OptCondBranch2, "OptCondBranch2", 40, 0, 0, 0, 0, 0 }; @@ -251,6 +252,7 @@ static OptFunc* OptFuncs[] = { &DOptBranchDist, &DOptBranchDist2, &DOptCmp1, + &DOptCmp10, &DOptCmp2, &DOptCmp3, &DOptCmp4, @@ -729,6 +731,7 @@ static unsigned RunOptGroup3 (CodeSeg* S) C += RunOptFunc (S, &DOptCondBranch3, 1); C += RunOptFunc (S, &DOptCondBranchC, 1); C += RunOptFunc (S, &DOptRTSJumps1, 1); + C += RunOptFunc (S, &DOptCmp10, 1); /* After OptRTSJumps1 */ C += RunOptFunc (S, &DOptBoolCmp, 1); C += RunOptFunc (S, &DOptBoolTrans, 1); C += RunOptFunc (S, &DOptBNegA2, 1); /* After OptCondBranch's */ diff --git a/src/cc65/coptcmp.c b/src/cc65/coptcmp.c index 2970b363b..25499dc3c 100644 --- a/src/cc65/coptcmp.c +++ b/src/cc65/coptcmp.c @@ -741,3 +741,40 @@ unsigned OptCmp9 (CodeSeg* S) /* Return the number of changes made */ return Changes; } + + + +unsigned OptCmp10 (CodeSeg* S) +/* Remove compare instructions before an RTS. This is safe since no C function +** passes back something in the flags. +*/ +{ + unsigned Changes = 0; + unsigned I; + + /* Walk over the entries */ + I = 0; + while (I < CS_GetEntryCount (S)) { + + CodeEntry* N; + + /* Get next entry */ + CodeEntry* E = CS_GetEntry (S, I); + + /* Check for a compare followed by an RTS */ + if ((E->Info & OF_CMP) != 0 && /* Compare insn */ + (N = CS_GetNextEntry (S, I)) != 0 && /* Next entry ... */ + N->OPC == OP65_RTS) { /* ... is RTS */ + + /* Found, remove the compare */ + CS_DelEntry (S, I); + ++Changes; + } + + /* Next entry */ + ++I; + } + + /* Return the number of changes made */ + return Changes; +} diff --git a/src/cc65/coptcmp.h b/src/cc65/coptcmp.h index dd188f7fc..ff58d37df 100644 --- a/src/cc65/coptcmp.h +++ b/src/cc65/coptcmp.h @@ -146,6 +146,11 @@ unsigned OptCmp9 (CodeSeg* S); ** flag instead of the carry flag and remove the asl. */ +unsigned OptCmp10 (CodeSeg* S); +/* Remove compare instructions before an RTS. This is safe since no C function +** passes back something in the flags. +*/ + /* End of coptcmp.h */ From 7a6c60ade423c186d11b89be9fb1d99aa8a33a6b Mon Sep 17 00:00:00 2001 From: Kugel Fuhr <98353208+kugelfuhr@users.noreply.github.com> Date: Tue, 24 Jun 2025 20:21:43 +0200 Subject: [PATCH 2/7] Do also sort variables to satisfy sorted_codeopt.sh. --- src/cc65/codeopt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc65/codeopt.c b/src/cc65/codeopt.c index f57417526..e9cf8914f 100644 --- a/src/cc65/codeopt.c +++ b/src/cc65/codeopt.c @@ -129,6 +129,7 @@ static OptFunc DOptBoolUnary3 = { OptBoolUnary3, "OptBoolUnary3", 40, 0, static OptFunc DOptBranchDist = { OptBranchDist, "OptBranchDist", 0, 0, 0, 0, 0, 0 }; static OptFunc DOptBranchDist2 = { OptBranchDist2, "OptBranchDist2", 0, 0, 0, 0, 0, 0 }; static OptFunc DOptCmp1 = { OptCmp1, "OptCmp1", 42, 0, 0, 0, 0, 0 }; +static OptFunc DOptCmp10 = { OptCmp10, "OptCmp10", 33, 0, 0, 0, 0, 0 }; static OptFunc DOptCmp2 = { OptCmp2, "OptCmp2", 85, 0, 0, 0, 0, 0 }; static OptFunc DOptCmp3 = { OptCmp3, "OptCmp3", 75, 0, 0, 0, 0, 0 }; static OptFunc DOptCmp4 = { OptCmp4, "OptCmp4", 75, 0, 0, 0, 0, 0 }; @@ -136,7 +137,6 @@ static OptFunc DOptCmp5 = { OptCmp5, "OptCmp5", 100, 0, static OptFunc DOptCmp7 = { OptCmp7, "OptCmp7", 85, 0, 0, 0, 0, 0 }; static OptFunc DOptCmp8 = { OptCmp8, "OptCmp8", 50, 0, 0, 0, 0, 0 }; static OptFunc DOptCmp9 = { OptCmp9, "OptCmp9", 85, 0, 0, 0, 0, 0 }; -static OptFunc DOptCmp10 = { OptCmp10, "OptCmp10", 33, 0, 0, 0, 0, 0 }; static OptFunc DOptComplAX1 = { OptComplAX1, "OptComplAX1", 65, 0, 0, 0, 0, 0 }; static OptFunc DOptCondBranch1 = { OptCondBranch1, "OptCondBranch1", 80, 0, 0, 0, 0, 0 }; static OptFunc DOptCondBranch2 = { OptCondBranch2, "OptCondBranch2", 40, 0, 0, 0, 0, 0 }; From 1feeee9ce076bff2aead0ddfa8427a0f9e452d6a Mon Sep 17 00:00:00 2001 From: Kugel Fuhr <98353208+kugelfuhr@users.noreply.github.com> Date: Wed, 25 Jun 2025 09:37:58 +0200 Subject: [PATCH 3/7] Do only check .c and .h files. --- .github/checks/sorted_codeopt.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/checks/sorted_codeopt.sh b/.github/checks/sorted_codeopt.sh index c78662b9d..20145851a 100755 --- a/.github/checks/sorted_codeopt.sh +++ b/.github/checks/sorted_codeopt.sh @@ -63,6 +63,6 @@ function checkarray } -for N in `grep -rl "BEGIN DECL SORTED_CODEOPT.SH" "$CHECK_DIR"`; do - checkarray $N +find "$CHECK_DIR" -name \*.\[ch\] -print | while read N; do + grep -q "BEGIN DECL SORTED_CODEOPT.SH" "$N" && checkarray $N done From 55d9b2dbd0530aa5f355be94126676ff100f2cc9 Mon Sep 17 00:00:00 2001 From: Kugel Fuhr <98353208+kugelfuhr@users.noreply.github.com> Date: Wed, 25 Jun 2025 20:07:36 +0200 Subject: [PATCH 4/7] Rewrite the optimization step from c0a1b1b887af536612987847c9344a1226bf4397 to remove compares not only before RTS but also befoire function calls that don't use the flags but destroy all of them. The latter is currently the case for all functions called. This way the optimization covers a lot more cases than just checking for RTS. --- src/cc65/codeopt.c | 6 ++-- src/cc65/coptcmp.c | 82 +++++++++++++++++++++++++--------------------- src/cc65/coptcmp.h | 10 +++--- 3 files changed, 53 insertions(+), 45 deletions(-) diff --git a/src/cc65/codeopt.c b/src/cc65/codeopt.c index e9cf8914f..f7e3d4a1a 100644 --- a/src/cc65/codeopt.c +++ b/src/cc65/codeopt.c @@ -129,11 +129,11 @@ static OptFunc DOptBoolUnary3 = { OptBoolUnary3, "OptBoolUnary3", 40, 0, static OptFunc DOptBranchDist = { OptBranchDist, "OptBranchDist", 0, 0, 0, 0, 0, 0 }; static OptFunc DOptBranchDist2 = { OptBranchDist2, "OptBranchDist2", 0, 0, 0, 0, 0, 0 }; static OptFunc DOptCmp1 = { OptCmp1, "OptCmp1", 42, 0, 0, 0, 0, 0 }; -static OptFunc DOptCmp10 = { OptCmp10, "OptCmp10", 33, 0, 0, 0, 0, 0 }; static OptFunc DOptCmp2 = { OptCmp2, "OptCmp2", 85, 0, 0, 0, 0, 0 }; static OptFunc DOptCmp3 = { OptCmp3, "OptCmp3", 75, 0, 0, 0, 0, 0 }; static OptFunc DOptCmp4 = { OptCmp4, "OptCmp4", 75, 0, 0, 0, 0, 0 }; static OptFunc DOptCmp5 = { OptCmp5, "OptCmp5", 100, 0, 0, 0, 0, 0 }; +static OptFunc DOptCmp6 = { OptCmp6, "OptCmp6", 33, 0, 0, 0, 0, 0 }; static OptFunc DOptCmp7 = { OptCmp7, "OptCmp7", 85, 0, 0, 0, 0, 0 }; static OptFunc DOptCmp8 = { OptCmp8, "OptCmp8", 50, 0, 0, 0, 0, 0 }; static OptFunc DOptCmp9 = { OptCmp9, "OptCmp9", 85, 0, 0, 0, 0, 0 }; @@ -252,11 +252,11 @@ static OptFunc* OptFuncs[] = { &DOptBranchDist, &DOptBranchDist2, &DOptCmp1, - &DOptCmp10, &DOptCmp2, &DOptCmp3, &DOptCmp4, &DOptCmp5, + &DOptCmp6, &DOptCmp7, &DOptCmp8, &DOptCmp9, @@ -731,7 +731,7 @@ static unsigned RunOptGroup3 (CodeSeg* S) C += RunOptFunc (S, &DOptCondBranch3, 1); C += RunOptFunc (S, &DOptCondBranchC, 1); C += RunOptFunc (S, &DOptRTSJumps1, 1); - C += RunOptFunc (S, &DOptCmp10, 1); /* After OptRTSJumps1 */ + C += RunOptFunc (S, &DOptCmp6, 1); /* After OptRTSJumps1 */ C += RunOptFunc (S, &DOptBoolCmp, 1); C += RunOptFunc (S, &DOptBoolTrans, 1); C += RunOptFunc (S, &DOptBNegA2, 1); /* After OptCondBranch's */ diff --git a/src/cc65/coptcmp.c b/src/cc65/coptcmp.c index 25499dc3c..8f487969e 100644 --- a/src/cc65/coptcmp.c +++ b/src/cc65/coptcmp.c @@ -503,6 +503,51 @@ unsigned OptCmp5 (CodeSeg* S) +unsigned OptCmp6 (CodeSeg* S) +/* Remove compare instructions before an RTS or an subroutine call that doesn't +** use the flags. +*/ +{ + unsigned Changes = 0; + unsigned I; + + /* Walk over the entries */ + I = 0; + while (I < CS_GetEntryCount (S)) { + + CodeEntry* N; + + /* Get next entry */ + CodeEntry* E = CS_GetEntry (S, I); + + /* Check for a compare followed by something else. + ** Note: The test could be improved by checking the flag usage of the + ** function explicitly against the flags set by the compare instruction. + ** For current code generation this makes no difference, however. + */ + if ((E->Info & OF_CMP) != 0 && + (N = CS_GetNextEntry (S, I)) != 0 && + (N->OPC == OP65_RTS || /* Either RTS, or ... */ + (N->OPC == OP65_JSR && /* ... or JSR ... */ + N->JumpTo == 0 && /* ... to external ... */ + (N->Use & PSTATE_ALL) == 0 && /* ... with no flags used ... */ + (N->Chg & PSTATE_ALL) == PSTATE_ALL))) { /* ... but all destroyed */ + + /* Found, remove the compare */ + CS_DelEntry (S, I); + ++Changes; + } + + /* Next entry */ + ++I; + } + + /* Return the number of changes made */ + return Changes; +} + + + unsigned OptCmp7 (CodeSeg* S) /* Search for a sequence ldx/txa/branch and remove the txa if A is not ** used later. @@ -741,40 +786,3 @@ unsigned OptCmp9 (CodeSeg* S) /* Return the number of changes made */ return Changes; } - - - -unsigned OptCmp10 (CodeSeg* S) -/* Remove compare instructions before an RTS. This is safe since no C function -** passes back something in the flags. -*/ -{ - unsigned Changes = 0; - unsigned I; - - /* Walk over the entries */ - I = 0; - while (I < CS_GetEntryCount (S)) { - - CodeEntry* N; - - /* Get next entry */ - CodeEntry* E = CS_GetEntry (S, I); - - /* Check for a compare followed by an RTS */ - if ((E->Info & OF_CMP) != 0 && /* Compare insn */ - (N = CS_GetNextEntry (S, I)) != 0 && /* Next entry ... */ - N->OPC == OP65_RTS) { /* ... is RTS */ - - /* Found, remove the compare */ - CS_DelEntry (S, I); - ++Changes; - } - - /* Next entry */ - ++I; - } - - /* Return the number of changes made */ - return Changes; -} diff --git a/src/cc65/coptcmp.h b/src/cc65/coptcmp.h index ff58d37df..acd146822 100644 --- a/src/cc65/coptcmp.h +++ b/src/cc65/coptcmp.h @@ -123,6 +123,11 @@ unsigned OptCmp5 (CodeSeg* S); ** jne/jeq L2 */ +unsigned OptCmp6 (CodeSeg* S); +/* Remove compare instructions before an RTS or an exit by jumping to some +** other function. +*/ + unsigned OptCmp7 (CodeSeg* S); /* Search for a sequence ldx/txa/branch and remove the txa if A is not ** used later. @@ -146,11 +151,6 @@ unsigned OptCmp9 (CodeSeg* S); ** flag instead of the carry flag and remove the asl. */ -unsigned OptCmp10 (CodeSeg* S); -/* Remove compare instructions before an RTS. This is safe since no C function -** passes back something in the flags. -*/ - /* End of coptcmp.h */ From fa81f14cbf2b7cbfee4dbda68d65666b78d2ca91 Mon Sep 17 00:00:00 2001 From: Kugel Fuhr <98353208+kugelfuhr@users.noreply.github.com> Date: Wed, 25 Jun 2025 20:34:41 +0200 Subject: [PATCH 5/7] Add an explicit "exit 0" to the shell scripts. This worked more or less by coincidence before since shell scripts return the exit code of the last command run if there is no explicit exit statement. --- .github/checks/lastline.sh | 1 + .github/checks/lineendings.sh | 1 + .github/checks/noexec.sh | 1 + .github/checks/sorted.sh | 1 + .github/checks/sorted_codeopt.sh | 1 + .github/checks/sorted_opcodes.sh | 2 +- .github/checks/spaces.sh | 1 + .github/checks/tabs.sh | 1 + 8 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/checks/lastline.sh b/.github/checks/lastline.sh index d243a01e1..6bb6e0dc5 100755 --- a/.github/checks/lastline.sh +++ b/.github/checks/lastline.sh @@ -23,3 +23,4 @@ if [ x"$FILES"x != xx ]; then done exit -1 fi +exit 0 diff --git a/.github/checks/lineendings.sh b/.github/checks/lineendings.sh index 5b445522f..5baac514e 100755 --- a/.github/checks/lineendings.sh +++ b/.github/checks/lineendings.sh @@ -16,3 +16,4 @@ if [ x"$FILES"x != xx ]; then done exit -1 fi +exit 0 diff --git a/.github/checks/noexec.sh b/.github/checks/noexec.sh index c76ae481d..5e53fe869 100755 --- a/.github/checks/noexec.sh +++ b/.github/checks/noexec.sh @@ -16,3 +16,4 @@ if [ x"$FILES"x != xx ]; then done exit -1 fi +exit 0 diff --git a/.github/checks/sorted.sh b/.github/checks/sorted.sh index 4f53b0484..b5451a21f 100755 --- a/.github/checks/sorted.sh +++ b/.github/checks/sorted.sh @@ -36,3 +36,4 @@ function checkarray_quoted_name for N in `grep -rl "BEGIN SORTED.SH" "$CHECK_DIR"`; do checkarray_quoted_name $N done +exit 0 diff --git a/.github/checks/sorted_codeopt.sh b/.github/checks/sorted_codeopt.sh index 20145851a..cfca028dd 100755 --- a/.github/checks/sorted_codeopt.sh +++ b/.github/checks/sorted_codeopt.sh @@ -66,3 +66,4 @@ function checkarray find "$CHECK_DIR" -name \*.\[ch\] -print | while read N; do grep -q "BEGIN DECL SORTED_CODEOPT.SH" "$N" && checkarray $N done +exit 0 diff --git a/.github/checks/sorted_opcodes.sh b/.github/checks/sorted_opcodes.sh index 3e45ea752..34156bde6 100755 --- a/.github/checks/sorted_opcodes.sh +++ b/.github/checks/sorted_opcodes.sh @@ -37,4 +37,4 @@ function checkarray_quoted_name for N in `grep -rl "BEGIN SORTED_OPCODES.SH" "$CHECK_DIR"`; do checkarray_quoted_name $N done - +exit 0 diff --git a/.github/checks/spaces.sh b/.github/checks/spaces.sh index e231f6c2d..f2eea6f3f 100755 --- a/.github/checks/spaces.sh +++ b/.github/checks/spaces.sh @@ -16,3 +16,4 @@ if [ x"$FILES"x != xx ]; then done exit -1 fi +exit 0 diff --git a/.github/checks/tabs.sh b/.github/checks/tabs.sh index 80dac3f2d..ed8d45bac 100755 --- a/.github/checks/tabs.sh +++ b/.github/checks/tabs.sh @@ -16,3 +16,4 @@ if [ x"$FILES"x != xx ]; then done exit -1 fi +exit 0 From 0290b276aeb58c8782f4bdc8c49c6efabc3ee915 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 26 Jun 2025 01:21:28 +0200 Subject: [PATCH 6/7] fix sysuname for all targets, somehow this was forgotten --- libsrc/agat/sysuname.s | 37 ++++++++++++++++++++++++++++ libsrc/apple2/sysuname.s | 6 ++--- libsrc/atari/sysuname.s | 6 ++--- libsrc/atari5200/sysuname.s | 6 ++--- libsrc/atmos/sysuname.s | 16 +++--------- libsrc/c128/sysuname.s | 6 ++--- libsrc/c16/sysuname.s | 6 ++--- libsrc/c64/sysuname.s | 6 ++--- libsrc/cbm510/sysuname.s | 6 ++--- libsrc/cbm610/sysuname.s | 6 ++--- libsrc/creativision/sysuname.s | 6 ++--- libsrc/cx16/sysuname.s | 6 ++--- libsrc/geos-common/system/sysuname.s | 12 ++++----- libsrc/lynx/sysuname.s | 6 ++--- libsrc/nes/sysuname.s | 6 ++--- libsrc/pet/sysuname.s | 6 ++--- libsrc/plus4/sysuname.s | 6 ++--- libsrc/telestrat/sysuname.s | 16 +++--------- libsrc/vic20/sysuname.s | 6 ++--- samples/checkversion.c | 12 +++++++++ 20 files changed, 106 insertions(+), 77 deletions(-) create mode 100644 libsrc/agat/sysuname.s diff --git a/libsrc/agat/sysuname.s b/libsrc/agat/sysuname.s new file mode 100644 index 000000000..b2d2a334f --- /dev/null +++ b/libsrc/agat/sysuname.s @@ -0,0 +1,37 @@ +; +; Ullrich von Bassewitz, 2003-08-12 +; +; unsigned char __fastcall__ _sysuname (struct utsname* buf); +; + + .export __sysuname, utsdata + + .import utscopy + + __sysuname = utscopy + +;-------------------------------------------------------------------------- +; Data. We define a fixed utsname struct here and just copy it. + +.rodata + +utsdata: + ; sysname + .asciiz "cc65" + + ; nodename + .asciiz "" + + ; release + .byte .string (>.version) + .byte '.' + .byte .string (<.version) + .byte $00 + + ; version + .byte '0' ; unused + .byte $00 + + ; machine + .asciiz "Agat" + diff --git a/libsrc/apple2/sysuname.s b/libsrc/apple2/sysuname.s index cd41eac29..52a7ec7e1 100644 --- a/libsrc/apple2/sysuname.s +++ b/libsrc/apple2/sysuname.s @@ -23,13 +23,13 @@ utsdata: .asciiz "" ; release - .byte ((.VERSION >> 8) & $0F) + '0' + .byte .string (>.version) .byte '.' - .byte ((.VERSION >> 4) & $0F) + '0' + .byte .string (<.version) .byte $00 ; version - .byte (.VERSION & $0F) + '0' + .byte '0' ; unused .byte $00 ; machine diff --git a/libsrc/atari/sysuname.s b/libsrc/atari/sysuname.s index 25a891a1b..893ebcfdc 100644 --- a/libsrc/atari/sysuname.s +++ b/libsrc/atari/sysuname.s @@ -23,13 +23,13 @@ utsdata: .asciiz "" ; release - .byte ((.VERSION >> 8) & $0F) + '0' + .byte .string (>.version) .byte '.' - .byte ((.VERSION >> 4) & $0F) + '0' + .byte .string (<.version) .byte $00 ; version - .byte (.VERSION & $0F) + '0' + .byte '0' ; unused .byte $00 ; machine diff --git a/libsrc/atari5200/sysuname.s b/libsrc/atari5200/sysuname.s index 7fd9281a1..5a75edf04 100644 --- a/libsrc/atari5200/sysuname.s +++ b/libsrc/atari5200/sysuname.s @@ -23,13 +23,13 @@ utsdata: .asciiz "" ; release - .byte ((.VERSION >> 8) & $0F) + '0' + .byte .string (>.version) .byte '.' - .byte ((.VERSION >> 4) & $0F) + '0' + .byte .string (<.version) .byte $00 ; version - .byte (.VERSION & $0F) + '0' + .byte '0' ; unused .byte $00 ; machine diff --git a/libsrc/atmos/sysuname.s b/libsrc/atmos/sysuname.s index 546f942ab..7e7bd2341 100644 --- a/libsrc/atmos/sysuname.s +++ b/libsrc/atmos/sysuname.s @@ -23,23 +23,13 @@ utsdata: .asciiz "" ; release - .byte ((.VERSION >> 8) & $0F) + '0' + .byte .string (>.version) .byte '.' - .if ((.VERSION >> 4) & $0F) > 9 - .byte ((.VERSION >> 4) & $0F) / 10 + '0' - .byte ((.VERSION >> 4) & $0F) .MOD 10 + '0' - .else - .byte ((.VERSION >> 4) & $0F) + '0' - .endif + .byte .string (<.version) .byte $00 ; version - .if (.VERSION & $0F) > 9 - .byte (.VERSION & $0F) / 10 + '0' - .byte (.VERSION & $0F) .MOD 10 + '0' - .else - .byte (.VERSION & $0F) + '0' - .endif + .byte '0' ; unused .byte $00 ; machine diff --git a/libsrc/c128/sysuname.s b/libsrc/c128/sysuname.s index 55fe5ba28..b7c7794b5 100644 --- a/libsrc/c128/sysuname.s +++ b/libsrc/c128/sysuname.s @@ -23,13 +23,13 @@ utsdata: .asciiz "" ; release - .byte ((.VERSION >> 8) & $0F) + '0' + .byte .string (>.version) .byte '.' - .byte ((.VERSION >> 4) & $0F) + '0' + .byte .string (<.version) .byte $00 ; version - .byte (.VERSION & $0F) + '0' + .byte '0' ; unused .byte $00 ; machine diff --git a/libsrc/c16/sysuname.s b/libsrc/c16/sysuname.s index c44ab6acc..960509866 100644 --- a/libsrc/c16/sysuname.s +++ b/libsrc/c16/sysuname.s @@ -23,13 +23,13 @@ utsdata: .asciiz "" ; release - .byte ((.VERSION >> 8) & $0F) + '0' + .byte .string (>.version) .byte '.' - .byte ((.VERSION >> 4) & $0F) + '0' + .byte .string (<.version) .byte $00 ; version - .byte (.VERSION & $0F) + '0' + .byte '0' ; unused .byte $00 ; machine diff --git a/libsrc/c64/sysuname.s b/libsrc/c64/sysuname.s index 1903986c9..1f6cfc410 100644 --- a/libsrc/c64/sysuname.s +++ b/libsrc/c64/sysuname.s @@ -23,13 +23,13 @@ utsdata: .asciiz "" ; release - .byte ((.VERSION >> 8) & $0F) + '0' + .byte .string (>.version) .byte '.' - .byte ((.VERSION >> 4) & $0F) + '0' + .byte .string (<.version) .byte $00 ; version - .byte (.VERSION & $0F) + '0' + .byte '0' ; unused .byte $00 ; machine diff --git a/libsrc/cbm510/sysuname.s b/libsrc/cbm510/sysuname.s index 24d4dc03b..579908d19 100644 --- a/libsrc/cbm510/sysuname.s +++ b/libsrc/cbm510/sysuname.s @@ -23,13 +23,13 @@ utsdata: .asciiz "" ; release - .byte ((.VERSION >> 8) & $0F) + '0' + .byte .string (>.version) .byte '.' - .byte ((.VERSION >> 4) & $0F) + '0' + .byte .string (<.version) .byte $00 ; version - .byte (.VERSION & $0F) + '0' + .byte '0' ; unused .byte $00 ; machine diff --git a/libsrc/cbm610/sysuname.s b/libsrc/cbm610/sysuname.s index 984cb93df..dab807a4f 100644 --- a/libsrc/cbm610/sysuname.s +++ b/libsrc/cbm610/sysuname.s @@ -23,13 +23,13 @@ utsdata: .asciiz "" ; release - .byte ((.VERSION >> 8) & $0F) + '0' + .byte .string (>.version) .byte '.' - .byte ((.VERSION >> 4) & $0F) + '0' + .byte .string (<.version) .byte $00 ; version - .byte (.VERSION & $0F) + '0' + .byte '0' ; unused .byte $00 ; machine diff --git a/libsrc/creativision/sysuname.s b/libsrc/creativision/sysuname.s index 725cb2a62..43a0c7659 100644 --- a/libsrc/creativision/sysuname.s +++ b/libsrc/creativision/sysuname.s @@ -23,13 +23,13 @@ utsdata: .asciiz "" ; release - .byte ((.VERSION >> 8) & $0F) + '0' + .byte .string (>.version) .byte '.' - .byte ((.VERSION >> 4) & $0F) + '0' + .byte .string (<.version) .byte $00 ; version - .byte (.VERSION & $0F) + '0' + .byte '0' ; unused .byte $00 ; machine diff --git a/libsrc/cx16/sysuname.s b/libsrc/cx16/sysuname.s index 4aefb7cf5..06f4d7662 100644 --- a/libsrc/cx16/sysuname.s +++ b/libsrc/cx16/sysuname.s @@ -24,13 +24,13 @@ utsdata: .asciiz "" ; release - .byte ((.VERSION >> 8) & $0F) + '0' + .byte .string (>.version) .byte '.' - .byte ((.VERSION >> 4) & $0F) + '0' + .byte .string (<.version) .byte $00 ; version - .byte (.VERSION & $0F) + '0' + .byte '0' ; unused .byte $00 ; machine diff --git a/libsrc/geos-common/system/sysuname.s b/libsrc/geos-common/system/sysuname.s index 8eac05941..954e5be5e 100644 --- a/libsrc/geos-common/system/sysuname.s +++ b/libsrc/geos-common/system/sysuname.s @@ -22,14 +22,14 @@ utsdata: .asciiz "" ; release - .byte ((.VERSION >> 8) & $0F) + '0' - .byte '.' - .byte ((.VERSION >> 4) & $0F) + '0' - .byte $00 + .byte .string (>.version) + .byte '.' + .byte .string (<.version) + .byte $00 ; version - .byte (.VERSION & $0F) + '0' - .byte $00 + .byte '0' ; unused + .byte $00 ; machine .asciiz "GEOS" diff --git a/libsrc/lynx/sysuname.s b/libsrc/lynx/sysuname.s index 879297ea4..3c75fac08 100644 --- a/libsrc/lynx/sysuname.s +++ b/libsrc/lynx/sysuname.s @@ -23,13 +23,13 @@ utsdata: .asciiz "" ; release - .byte ((.VERSION >> 8) & $0F) + '0' + .byte .string (>.version) .byte '.' - .byte ((.VERSION >> 4) & $0F) + '0' + .byte .string (<.version) .byte $00 ; version - .byte (.VERSION & $0F) + '0' + .byte '0' ; unused .byte $00 ; machine diff --git a/libsrc/nes/sysuname.s b/libsrc/nes/sysuname.s index fcab503e1..7e72df358 100644 --- a/libsrc/nes/sysuname.s +++ b/libsrc/nes/sysuname.s @@ -23,13 +23,13 @@ utsdata: .asciiz "" ; release - .byte ((.VERSION >> 8) & $0F) + '0' + .byte .string (>.version) .byte '.' - .byte ((.VERSION >> 4) & $0F) + '0' + .byte .string (<.version) .byte $00 ; version - .byte (.VERSION & $0F) + '0' + .byte '0' ; unused .byte $00 ; machine diff --git a/libsrc/pet/sysuname.s b/libsrc/pet/sysuname.s index 59174d821..ddc7d644f 100644 --- a/libsrc/pet/sysuname.s +++ b/libsrc/pet/sysuname.s @@ -23,13 +23,13 @@ utsdata: .asciiz "" ; release - .byte ((.VERSION >> 8) & $0F) + '0' + .byte .string (>.version) .byte '.' - .byte ((.VERSION >> 4) & $0F) + '0' + .byte .string (<.version) .byte $00 ; version - .byte (.VERSION & $0F) + '0' + .byte '0' ; unused .byte $00 ; machine diff --git a/libsrc/plus4/sysuname.s b/libsrc/plus4/sysuname.s index 332daae0d..e75e6cacc 100644 --- a/libsrc/plus4/sysuname.s +++ b/libsrc/plus4/sysuname.s @@ -23,13 +23,13 @@ utsdata: .asciiz "" ; release - .byte ((.VERSION >> 8) & $0F) + '0' + .byte .string (>.version) .byte '.' - .byte ((.VERSION >> 4) & $0F) + '0' + .byte .string (<.version) .byte $00 ; version - .byte (.VERSION & $0F) + '0' + .byte '0' ; unused .byte $00 ; machine diff --git a/libsrc/telestrat/sysuname.s b/libsrc/telestrat/sysuname.s index 51af1d8fe..09aaff831 100644 --- a/libsrc/telestrat/sysuname.s +++ b/libsrc/telestrat/sysuname.s @@ -23,23 +23,13 @@ utsdata: .asciiz "" ; release - .byte ((.VERSION >> 8) & $0F) + '0' + .byte .string (>.version) .byte '.' - .if ((.VERSION >> 4) & $0F) > 9 - .byte ((.VERSION >> 4) & $0F) / 10 + '0' - .byte ((.VERSION >> 4) & $0F) .MOD 10 + '0' - .else - .byte ((.VERSION >> 4) & $0F) + '0' - .endif + .byte .string (<.version) .byte $00 ; version - .if (.VERSION & $0F) > 9 - .byte (.VERSION & $0F) / 10 + '0' - .byte (.VERSION & $0F) .MOD 10 + '0' - .else - .byte (.VERSION & $0F) + '0' - .endif + .byte '0' ; unused .byte $00 ; machine diff --git a/libsrc/vic20/sysuname.s b/libsrc/vic20/sysuname.s index 18d5db9a9..43ee37896 100644 --- a/libsrc/vic20/sysuname.s +++ b/libsrc/vic20/sysuname.s @@ -23,13 +23,13 @@ utsdata: .asciiz "" ; release - .byte ((.VERSION >> 8) & $0F) + '0' + .byte .string (>.version) .byte '.' - .byte ((.VERSION >> 4) & $0F) + '0' + .byte .string (<.version) .byte $00 ; version - .byte (.VERSION & $0F) + '0' + .byte '0' ; unused .byte $00 ; machine diff --git a/samples/checkversion.c b/samples/checkversion.c index f2a9d4a49..9d88cecd3 100644 --- a/samples/checkversion.c +++ b/samples/checkversion.c @@ -9,6 +9,7 @@ #include #include +#include #if ((__CC65__ >> 8) > 3) || ((__CC65__ & 0x000f) > 0) /* compiler version is 2.19-git or higher */ @@ -29,6 +30,17 @@ int main(void) { +#if !defined(__SIM6502__) && !defined(__SIM65C02__) && !defined(__AGAT__) + struct utsname buf; + uname (&buf); + + printf("utsname.sysname: %s\n", buf.sysname); + printf("utsname.nodename: %s\n", buf.nodename); + printf("utsname.release: %s\n", buf.release); + printf("utsname.version: %s\n", buf.version); + printf("utsname.machine: %s\n", buf.machine); +#endif + printf("__CC65__ defined as %04x\n", __CC65__); printf("compiler version is %u.%u\n", VER_MAJOR, VER_MINOR); if (__CC65__ == VERSION) { From 8bf6bb606c1a0b21fedab6ac4e332dab6df0ed96 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 26 Jun 2025 01:34:32 +0200 Subject: [PATCH 7/7] make sure "make platforms" actually checks all targets --- samples/Makefile | 16 +++++++++++++--- samples/tutorial/Makefile | 3 +++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/samples/Makefile b/samples/Makefile index 0a56af3c1..dc0ea8f9f 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -213,6 +213,9 @@ EXELIST_atari2600 = \ EXELIST_atari5200 = \ notavailable +EXELIST_atari7800 = \ + notavailable + EXELIST_atmos = \ ascii \ checkversion \ @@ -299,9 +302,7 @@ EXELIST_gamate = \ hello EXELIST_geos-cbm = \ - ascii \ - checkversion \ - diodemo + ascii EXELIST_geos-apple = \ ascii @@ -347,6 +348,9 @@ EXELIST_sim6502 = \ EXELIST_sim65c02 = $(EXELIST_sim6502) +EXELIST_rp6502 = \ + notavailable + EXELIST_supervision = \ notavailable @@ -413,6 +417,7 @@ TARGETS := \ atarixl \ atari2600 \ atari5200 \ + atari7800 \ atmos \ bbc \ c128 \ @@ -423,6 +428,8 @@ TARGETS := \ creativision \ cx16 \ gamate \ + geos-apple \ + geos-cbm \ kim1 \ lunix \ lynx \ @@ -431,6 +438,7 @@ TARGETS := \ pce \ pet \ plus4 \ + rp6502 \ sim6502 \ sim65c02 \ supervision \ @@ -438,12 +446,14 @@ TARGETS := \ telestrat \ vic20 + # -------------------------------------------------------------------------- # Rule to make the binaries for every platform define TARGET_recipe @echo making samples for: $(T) +@$(MAKE) --no-print-directory clean SYS:=$(T) @$(MAKE) -j2 SYS:=$(T) @$(MAKE) --no-print-directory clean SYS:=$(T) diff --git a/samples/tutorial/Makefile b/samples/tutorial/Makefile index 7b3286e27..685c8dd69 100644 --- a/samples/tutorial/Makefile +++ b/samples/tutorial/Makefile @@ -43,6 +43,9 @@ EXELIST_atari2600 = \ EXELIST_atari5200 = \ notavailable +EXELIST_atari7800 = \ + notavailable + EXELIST_bbc = \ notavailable