Merge pull request #2742 from kugelfuhr/kugelfuhr/sp-backwards-compat

Allow "sp" as an alias for "c_sp" to avoid breaking old code
This commit is contained in:
Bob Andrews
2025-06-26 15:43:54 +02:00
committed by GitHub
8 changed files with 57 additions and 0 deletions

View File

@@ -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

22
.github/checks/checksp.sh vendored Executable file
View File

@@ -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}

View File

@@ -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

View File

@@ -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 $@

View File

@@ -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

View File

@@ -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"

View File

@@ -0,0 +1,7 @@
.include "zeropage.inc"
.proc _func
ldy #0
lda (sp),y
rts
.endproc

View File

@@ -0,0 +1 @@
ld65: Warning: runtime/sp-compat.s:10: Symbol 'sp' is deprecated - please use 'c_sp' instead