From 0db23a8951ee43e8fdcb4377a58b045af6142983 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 23 May 2021 18:55:06 +0200 Subject: [PATCH 1/7] testcase for issue #263 --- test/val/bug263.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/val/bug263.c diff --git a/test/val/bug263.c b/test/val/bug263.c new file mode 100644 index 000000000..6f3f8f57e --- /dev/null +++ b/test/val/bug263.c @@ -0,0 +1,49 @@ + +/* issue #263 - cc65 miscompiles w/ a static variable and -O */ + +#include +#include + +int failures = 0; + +void __fastcall__ set_vram_update(unsigned char *ptr) +{ + printf("set_vram_update: %04x\n", ptr); + if (ptr != NULL) { + failures++; + } +} + +unsigned char __fastcall__ ppu_wait_nmi(void) +{ + // we need to make sure somehow the akku is not zero before the break + return 0x1234; +} + +unsigned char ctrl, ret, i; + +unsigned char gameloop (void) +{ + ctrl = 0; + ret = 0; + while(1) { + if (ctrl & 1) { + while (--i) { + ppu_wait_nmi(); + } + break; + } + ctrl = 1; + } + // This will pass garbage, not NULL. + set_vram_update(NULL); + return ret; +} + +int main(void) +{ + gameloop(); + printf("failures: %d\n", failures); + return failures; +} + From adda9438d25212740e169443936ba3a79e2b6745 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 24 May 2021 13:53:14 +0200 Subject: [PATCH 2/7] testcase for issue #1357 --- test/misc/Makefile | 6 ++++++ test/misc/bug1357.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 test/misc/bug1357.c diff --git a/test/misc/Makefile b/test/misc/Makefile index b17c69f5c..c8b130ec4 100644 --- a/test/misc/Makefile +++ b/test/misc/Makefile @@ -106,6 +106,12 @@ $(WORKDIR)/bug1263.$1.$2.prg: bug1263.c | $(WORKDIR) $(if $(QUIET),echo misc/bug1263.$1.$2.prg) $(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR) +# should compile, but gives an error +$(WORKDIR)/bug1357.$1.$2.prg: bug1357.c | $(WORKDIR) + @echo "FIXME: " $$@ "currently does not compile." + $(if $(QUIET),echo misc/bug1357.$1.$2.prg) + $(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR) + # this one requires --std=c89, it fails with --std=c99 $(WORKDIR)/bug1265.$1.$2.prg: bug1265.c | $(WORKDIR) $(if $(QUIET),echo misc/bug1265.$1.$2.prg) diff --git a/test/misc/bug1357.c b/test/misc/bug1357.c new file mode 100644 index 000000000..40415f868 --- /dev/null +++ b/test/misc/bug1357.c @@ -0,0 +1,30 @@ + +/* issue #1357 - X Macros don't work with C preprocessor */ + +#define OPCODES(X) \ + X(PUSHNIL) \ + X(PUSHTRUE) \ + X(PUSHFALSE) + +enum { +#define X(op) op, +OPCODES(X) +#undef X + N_OPS +}; + +/* cc65 -E bug1357.c -o bug1357.c.pre + should produce something like this: + +enum { +PUSHNIL, +PUSHTRUE, +PUSHFALSE, + N_OPS +}; +*/ + +int main(void) +{ + return 0; +} From ae3d3a4b5dd499406713e42254dc4b1626fd10dd Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 24 May 2021 13:53:44 +0200 Subject: [PATCH 3/7] make readme a bit more clear (hopefully) --- test/readme.txt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/test/readme.txt b/test/readme.txt index 0523482fd..49ae363cc 100644 --- a/test/readme.txt +++ b/test/readme.txt @@ -1,6 +1,13 @@ This directory contains test code for automatic regression testing of the CC65 -compiler. +compiler and tools. +/asm - contains the assembler regression tests + +/dasm - contains the disassembler regression tests + + +/val, /ref and /err generally contain the tests that are used to verify that the +compiler is working as expected (when the tests behave as described): /val - The bulk of tests are contained here, individual tests should exit with an exit code of EXIT_SUCCESS when they pass, or EXIT_FAILURE on error. @@ -9,6 +16,9 @@ compiler. /err - contains tests that MUST NOT compile + +/todo and /misc generally contain the tests that fail because of known bugs: + /todo - These tests fail due to open compiler issues. The makefile in this directory _expects_ the tests to fail, because of @@ -16,9 +26,6 @@ compiler. moved to /val in the PR fixing the issue, which will make CI pass again. No changes to makefiles are required! -/asm - contains the assembler regression tests - -/dasm - contains the disassembler regression tests /misc - a few tests that need special care of some sort From 022935320c61ac491cf20afe887b30f1534d0117 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 24 May 2021 14:30:10 +0200 Subject: [PATCH 4/7] test for issue #897 --- test/val/bug897.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 test/val/bug897.c diff --git a/test/val/bug897.c b/test/val/bug897.c new file mode 100644 index 000000000..eaf751441 --- /dev/null +++ b/test/val/bug897.c @@ -0,0 +1,52 @@ + +/* issue #897 - __asm__()-referenced code-labels are generated for only branches and jumps */ + +#include +#include + +static unsigned char *srcptr, *dstptr; + +#define COPY_LEN 16 + +void test(void) +{ + asm("lda %v", srcptr); + asm("sta %g+1", s2b_copy_from); + asm("lda %v+1", srcptr); + asm("sta %g+2", s2b_copy_from); + + asm("lda %v", dstptr); + asm("sta %g+1", s2b_copy_to); + asm("lda %v+1", dstptr); + asm("sta %g+2", s2b_copy_to); + + asm("ldy #%b", COPY_LEN-1); +s2b_copy_from: + asm("lda $FFFF,y"); +s2b_copy_to: + asm("sta $FFFF,y"); + asm("dey"); + asm("bpl %g", s2b_copy_from); +} + +unsigned char src[16] = "0123456789abcdef"; +unsigned char dest[16]; + +int failures = 0; + +unsigned char i; + +int main(void) +{ + srcptr = src; + dstptr = dest; + test(); + for (i = 0; i < COPY_LEN; i++) { + printf("%d %02x %02x\n", i, src[i], dest[i]); + if (src[i] != dest[i]) { + failures++; + } + } + printf("failures: %d\n", failures); + return failures; +} From 65c640d2cf1059e97e518feb3a3a348a70a95636 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 24 May 2021 15:15:07 +0200 Subject: [PATCH 5/7] added missing atari5200 target --- samples/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/samples/Makefile b/samples/Makefile index f1e7a1e0b..7e5c1934d 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -190,6 +190,9 @@ EXELIST_atarixl = $(EXELIST_atari) EXELIST_atari2600 = \ atari2600hello +EXELIST_atari5200 = \ + notavailable + EXELIST_atmos = \ ascii \ hello \ From 30830e1348f516626aab482b311e741428f411bc Mon Sep 17 00:00:00 2001 From: Polluks Date: Sun, 23 May 2021 10:19:00 +0200 Subject: [PATCH 6/7] Added missing Creativision functions --- doc/funcref.sgml | 112 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/doc/funcref.sgml b/doc/funcref.sgml index 2cb8bbf44..792a51741 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -298,6 +298,16 @@ function. +

+ + + + + + + + +

@@ -1659,6 +1669,41 @@ used in presence of a prototype. +bios_playsound

+ + + +/ + +BASIC has a fixed tempo of 18. +The function is only available as fastcall function, so it may only be +used in presence of a prototype. + +, + + +static const unsigned char notes[] = { + 0x77, 0x4F, 0x37, + 0x4B, 0x05, 0xBB, + 0x4F, 0x27, 0x83, + 0x93, 0x9B, 0x93, + 0x17, 0x4F, 0x96, + 0xAB, 0x17, 0x4F, + 0x0E +}; +bios_playsound (notes, sizeof notes); + + + + + bgcolor

@@ -5769,6 +5814,73 @@ be used in presence of a prototype. +psg_delay

+ + + +/ + +The function is only available as fastcall function, so it may only be +used in presence of a prototype. + +, + + + + + +psg_outb

+ + + +/ + +The function is only available as fastcall function, so it may only be +used in presence of a prototype. + +, + + +psg_outb (0x80); // Latch frequency +psg_outb (0x07); // Frequency byte 2 +psg_outb (0x90); // Channel 0 full volume + + + + + +psg_silence

+ + + +/ + + +, + + + + + qsort

From 010eea12a2fe03d6fd41aca307076aed8d1299c0 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Tue, 25 May 2021 13:38:06 +0200 Subject: [PATCH 7/7] move test for issue #1211 into misc --- test/misc/Makefile | 6 ++++++ test/{err => misc}/bug1211-ice-move-refs-2.c | 0 2 files changed, 6 insertions(+) rename test/{err => misc}/bug1211-ice-move-refs-2.c (100%) diff --git a/test/misc/Makefile b/test/misc/Makefile index c8b130ec4..e6c58c5a4 100644 --- a/test/misc/Makefile +++ b/test/misc/Makefile @@ -112,6 +112,12 @@ $(WORKDIR)/bug1357.$1.$2.prg: bug1357.c | $(WORKDIR) $(if $(QUIET),echo misc/bug1357.$1.$2.prg) $(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR) +# should compile, but compiler exits with internal error +$(WORKDIR)/bug1211-ice-move-refs-2.$1.$2.prg: bug1211-ice-move-refs-2.c | $(WORKDIR) + @echo "FIXME: " $$@ "currently does not compile." + $(if $(QUIET),echo misc/bug1211-ice-move-refs-2.$1.$2.prg) + $(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR) + # this one requires --std=c89, it fails with --std=c99 $(WORKDIR)/bug1265.$1.$2.prg: bug1265.c | $(WORKDIR) $(if $(QUIET),echo misc/bug1265.$1.$2.prg) diff --git a/test/err/bug1211-ice-move-refs-2.c b/test/misc/bug1211-ice-move-refs-2.c similarity index 100% rename from test/err/bug1211-ice-move-refs-2.c rename to test/misc/bug1211-ice-move-refs-2.c