From 5db2aed1297e7590beb35c43fa5ae40c44e2b686 Mon Sep 17 00:00:00 2001 From: Kugel Fuhr <98353208+kugelfuhr@users.noreply.github.com> Date: Thu, 26 Jun 2025 07:40:04 +0200 Subject: [PATCH 1/3] Allow "sp" as an alias for "c_sp" for backwards compatibility. Using it will work but generates a linker warning. Added a test to check for this warning. --- asminc/zeropage.inc | 6 ++++++ libsrc/runtime/sp-compat.s | 11 +++++++++++ test/asm/listing/ref/sp-compat.ld65err2-ref | 1 + test/asm/listing/sp-compat.s | 7 +++++++ 4 files changed, 25 insertions(+) create mode 100644 libsrc/runtime/sp-compat.s create mode 100644 test/asm/listing/ref/sp-compat.ld65err2-ref create mode 100644 test/asm/listing/sp-compat.s diff --git a/asminc/zeropage.inc b/asminc/zeropage.inc index 5285779ba..2d4b144db 100644 --- a/asminc/zeropage.inc +++ b/asminc/zeropage.inc @@ -13,6 +13,12 @@ .globalzp tmp1, tmp2, tmp3, tmp4 .globalzp regbank + ; The following symbol is supplied for compatibility reasons only, it + ; will get removed in future versions. Using it will cause a linker + ; warning. + .globalzp sp + + ; The size of the register bank regbanksize = 6 diff --git a/libsrc/runtime/sp-compat.s b/libsrc/runtime/sp-compat.s new file mode 100644 index 000000000..797fef47b --- /dev/null +++ b/libsrc/runtime/sp-compat.s @@ -0,0 +1,11 @@ +; +; Kugelfuhr, 2025-06-26 +; +; Add "sp" as an alias for "c_sp" so we don't break old code but emit a +; linker warning if it is used. Added after renaming "sp" to "c_sp". +; + +.include "zeropage.inc" +.export sp := c_sp +.assert 0, ldwarning, "Symbol 'sp' is deprecated - please use 'c_sp' instead" + diff --git a/test/asm/listing/ref/sp-compat.ld65err2-ref b/test/asm/listing/ref/sp-compat.ld65err2-ref new file mode 100644 index 000000000..fe2611088 --- /dev/null +++ b/test/asm/listing/ref/sp-compat.ld65err2-ref @@ -0,0 +1 @@ +ld65: Warning: runtime/sp-compat.s:10: Symbol 'sp' is deprecated - please use 'c_sp' instead diff --git a/test/asm/listing/sp-compat.s b/test/asm/listing/sp-compat.s new file mode 100644 index 000000000..8c22a71d3 --- /dev/null +++ b/test/asm/listing/sp-compat.s @@ -0,0 +1,7 @@ +.include "zeropage.inc" + +.proc _func + ldy #0 + lda (sp),y + rts +.endproc From 399f5aaab7ebab11f8f878641389e59224adad7d Mon Sep 17 00:00:00 2001 From: Kugel Fuhr <98353208+kugelfuhr@users.noreply.github.com> Date: Thu, 26 Jun 2025 08:23:51 +0200 Subject: [PATCH 2/3] Check that there are no library modules that use the old "sp" symbol instead of "c_sp". --- .github/checks/Makefile | 3 +++ .github/checks/checksp.sh | 22 +++++++++++++++++++++ .github/workflows/build-on-pull-request.yml | 3 +++ Makefile | 4 ++++ 4 files changed, 32 insertions(+) create mode 100755 .github/checks/checksp.sh diff --git a/.github/checks/Makefile b/.github/checks/Makefile index ee373d53d..7fc51d8d4 100644 --- a/.github/checks/Makefile +++ b/.github/checks/Makefile @@ -40,4 +40,7 @@ sorted: sorted.sh sorted_codeopt.sh sorted_opcodes.sh @./sorted_codeopt.sh @./sorted_opcodes.sh +checksp: checksp.sh + @./checksp.sh + endif diff --git a/.github/checks/checksp.sh b/.github/checks/checksp.sh new file mode 100755 index 000000000..f70d92e25 --- /dev/null +++ b/.github/checks/checksp.sh @@ -0,0 +1,22 @@ +#! /bin/bash +OD65_EXE=../bin/od65 +CHECK_PATH=../../libwrk + +cd "${CHECK_PATH}" || { + echo "error: Directory ${CHECK_PATH} doesn't seem to exist" >&2 + exit 1 +} + +[ -x "${OD65_EXE}" ] || { + echo "error: This check requires the od65 executable to be built" >&2 + exit 1 +} + +EXITCODE=0 +find . -name \*.o -print | while read OBJ; do + "${OD65_EXE}" --dump-imports "${OBJ}" | grep -q "\"sp\"" && { + echo "error: Usage of symbol 'sp' found in module ${OBJ}" >&2 + EXITCODE=1 + } +done +exit ${EXITCODE} diff --git a/.github/workflows/build-on-pull-request.yml b/.github/workflows/build-on-pull-request.yml index af79733cf..b577e4b03 100644 --- a/.github/workflows/build-on-pull-request.yml +++ b/.github/workflows/build-on-pull-request.yml @@ -39,6 +39,9 @@ jobs: - name: Build the platform libraries. shell: bash run: make -j2 lib QUIET=1 + - name: check test that no modules use sp + shell: bash + run: make -j2 checksp QUIET=1 - name: Run the regression tests. shell: bash run: make -j2 test QUIET=1 diff --git a/Makefile b/Makefile index 13e965c9e..21c1b3208 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,10 @@ checkstyle: sorted: @$(MAKE) -C .github/checks --no-print-directory $@ +# check that no modules use "sp", requires the binaries to be built first +checksp: + @$(MAKE) -C .github/checks --no-print-directory $@ + # runs regression tests, requires libtest target libraries test: @$(MAKE) -C test --no-print-directory $@ From e2a39d076d8b5f337a78c4b7871ca6355b28e1a6 Mon Sep 17 00:00:00 2001 From: Kugel Fuhr <98353208+kugelfuhr@users.noreply.github.com> Date: Thu, 26 Jun 2025 09:00:03 +0200 Subject: [PATCH 3/3] Renamed the assembler test. --- test/asm/listing/{sp-compat.s => 080-sp-compat.s} | 0 .../ref/{sp-compat.ld65err2-ref => 080-sp-compat.ld65err2-ref} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename test/asm/listing/{sp-compat.s => 080-sp-compat.s} (100%) rename test/asm/listing/ref/{sp-compat.ld65err2-ref => 080-sp-compat.ld65err2-ref} (100%) diff --git a/test/asm/listing/sp-compat.s b/test/asm/listing/080-sp-compat.s similarity index 100% rename from test/asm/listing/sp-compat.s rename to test/asm/listing/080-sp-compat.s diff --git a/test/asm/listing/ref/sp-compat.ld65err2-ref b/test/asm/listing/ref/080-sp-compat.ld65err2-ref similarity index 100% rename from test/asm/listing/ref/sp-compat.ld65err2-ref rename to test/asm/listing/ref/080-sp-compat.ld65err2-ref