From 51da666210db583b18aea8d325a83ba102cae056 Mon Sep 17 00:00:00 2001 From: Gorilla Sapiens Date: Wed, 11 Jun 2025 02:21:39 +0000 Subject: [PATCH 01/10] fixes #2608 --- src/cc65/pragma.c | 7 +------ test/val/bug2151.c | 5 +++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index ee71b42d8..b7384e2f1 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -433,12 +433,7 @@ static void ApplySegNamePragma (pragma_t Token, int PushPop, const char* Name, u SetSegAddrSize (Name, AddrSize); } - /* BSS variables are output at the end of the compilation. Don't - ** bother to change their segment, now. - */ - if (Seg != SEG_BSS) { - g_segname (Seg); - } + g_segname (Seg); } diff --git a/test/val/bug2151.c b/test/val/bug2151.c index 25f145506..1277961ef 100644 --- a/test/val/bug2151.c +++ b/test/val/bug2151.c @@ -47,10 +47,11 @@ _Pragma _Pragma ( #pragma bss-name("BSS") { extern int y; -#pragma bss-name("BSS2") +#pragma bss-name("BSS") // used to be BSS2, but fix for #2608 means + // that now causes ld65 to fail, so we use BSS instead static #pragma zpsym ("y") - int x; // TODO: currently in "BSS", but supposed to be in "BSS2"? + int x; x = 0; if (memcmp(str, "aBC", 3)) From ccdc5b9fea5840ee233e371ec26f5146e4606a19 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Wed, 11 Jun 2025 20:50:04 +0200 Subject: [PATCH 02/10] massaged repro case from #2608 into a test --- test/todo/bug2608.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 test/todo/bug2608.c diff --git a/test/todo/bug2608.c b/test/todo/bug2608.c new file mode 100644 index 000000000..c0685d28c --- /dev/null +++ b/test/todo/bug2608.c @@ -0,0 +1,40 @@ + +/* bug #2608: "zp_bss" is placed in BSS and NOT placed in ZEROPAGE as expected. */ + +#include +#include + +int err = 0; + +int is_zeropage(void *p) +{ + if (/*(p >= ((void*)0)) &&*/ + (p <= ((void*)0xff))) { + return 1; + } + return 0; +} + +void foo(void) { +#pragma bss-name(push,"ZEROPAGE") +#pragma data-name(push,"ZEROPAGE") + static int zp_data = 5; + static char zp_bss; +#pragma bss-name(pop) +#pragma data-name(pop) + printf("zp_data at 0x%04x (%szp)\n", &zp_data, is_zeropage(&zp_data) ? "" : "NOT "); + printf("zp_bss at 0x%04x (%szp)\n", &zp_bss, is_zeropage(&zp_bss) ? "" : "NOT "); + if (!is_zeropage(&zp_data)) { + err++; + } + if (!is_zeropage(&zp_bss)) { + err++; + } +} + +int main(void) +{ + foo(); + printf("errors: %d\n", err); + return err; +} From 3b79c92f394cf84e21d4e29dbbca8340c83c0adf Mon Sep 17 00:00:00 2001 From: Bob Andrews Date: Wed, 11 Jun 2025 21:06:58 +0200 Subject: [PATCH 03/10] Update pragma.c just retrigger the checks From 880322a5ae936c868398bd4233866b2fcbb5f436 Mon Sep 17 00:00:00 2001 From: Gorilla Sapiens Date: Thu, 12 Jun 2025 06:06:52 +0000 Subject: [PATCH 04/10] renamed test as requested. --- test/{todo => val}/bug2608.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{todo => val}/bug2608.c (100%) diff --git a/test/todo/bug2608.c b/test/val/bug2608.c similarity index 100% rename from test/todo/bug2608.c rename to test/val/bug2608.c From ace81bd36a5c6df0880a2722a1fe34112ce1e1e7 Mon Sep 17 00:00:00 2001 From: Kugel Fuhr <98353208+kugelfuhr@users.noreply.github.com> Date: Thu, 12 Jun 2025 14:42:38 +0200 Subject: [PATCH 05/10] Add macros to check for CPU type and supported instruction set. --- doc/cc65.sgml | 90 +++++++++++++++++++++++++++++++++++++++++++++++++ src/cc65/main.c | 84 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 172 insertions(+), 2 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 6793603d5..55b84ed5c 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -1154,6 +1154,96 @@ The compiler defines several macros at startup: +