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 c78662b9d..cfca028dd 100755 --- a/.github/checks/sorted_codeopt.sh +++ b/.github/checks/sorted_codeopt.sh @@ -63,6 +63,7 @@ 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 +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 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/Makefile b/samples/Makefile index 267e253ff..c0b198a9d 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -322,8 +322,7 @@ EXELIST_gamate = \ hello EXELIST_geos-cbm = \ - ascii \ - diodemo + ascii EXELIST_geos-apple = \ ascii @@ -382,6 +381,9 @@ EXELIST_sim6502 = \ EXELIST_sim65c02 = $(EXELIST_sim6502) +EXELIST_rp6502 = \ + notavailable + EXELIST_supervision = \ notavailable @@ -450,6 +452,7 @@ TARGETS := \ atarixl \ atari2600 \ atari5200 \ + atari7800 \ atmos \ bbc \ c128 \ @@ -461,6 +464,8 @@ TARGETS := \ creativision \ cx16 \ gamate \ + geos-apple \ + geos-cbm \ kim1 \ lunix \ lynx \ @@ -470,6 +475,7 @@ TARGETS := \ pce \ pet \ plus4 \ + rp6502 \ sim6502 \ sim65c02 \ supervision \ @@ -477,12 +483,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/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) { 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 diff --git a/src/cc65/codeopt.c b/src/cc65/codeopt.c index e3869d786..988e2d770 100644 --- a/src/cc65/codeopt.c +++ b/src/cc65/codeopt.c @@ -133,6 +133,7 @@ static OptFunc DOptCmp2 = { OptCmp2, "OptCmp2", 85, 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 }; @@ -255,6 +256,7 @@ static OptFunc* OptFuncs[] = { &DOptCmp3, &DOptCmp4, &DOptCmp5, + &DOptCmp6, &DOptCmp7, &DOptCmp8, &DOptCmp9, @@ -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, &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 eb138e78d..41245b58d 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. diff --git a/src/cc65/coptcmp.h b/src/cc65/coptcmp.h index 98e75715b..268e55be2 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.