From 5fc15a7a60f16c239c01663be52c48fb20ad1e4f Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 23 Jun 2025 17:09:06 +0200 Subject: [PATCH] test #2674 --- asminc/zeropage.inc | 2 +- doc/atari.sgml | 2 +- doc/ca65.sgml | 6 +- doc/cc65-intern.sgml | 12 +- doc/customizing.sgml | 4 +- doc/sim65.sgml | 2 +- libsrc/agat/crt0.s | 8 +- libsrc/apple2/callmain.s | 2 +- libsrc/apple2/crt0.s | 6 +- libsrc/apple2/exec.s | 4 +- libsrc/apple2/filename.s | 14 +- libsrc/apple2/mli_file_info_direct.s | 4 +- libsrc/apple2/mou/a2.stdmou.s | 4 +- libsrc/apple2/open.s | 4 +- libsrc/apple2/syschdir.s | 4 +- libsrc/apple2/sysmkdir.s | 4 +- libsrc/apple2/sysremove.s | 4 +- libsrc/apple2/sysrename.s | 8 +- libsrc/atari/crt0.s | 8 +- libsrc/atari/diopncls.s | 8 +- libsrc/atari/fdtable.s | 4 +- libsrc/atari/mcbpm.s | 14 +- libsrc/atari/mou/atrjoy.s | 4 +- libsrc/atari/mou/atrst.s | 4 +- libsrc/atari/mou/atrtt.s | 4 +- libsrc/atari/sysrename.s | 22 ++-- libsrc/atari/ucase_fn.s | 12 +- libsrc/atari2600/crt0.s | 4 +- libsrc/atari5200/crt0.s | 4 +- libsrc/atari7800/crt0.s | 4 +- libsrc/atari7800/mono_setcursor.s | 2 +- libsrc/atari7800/setcursor.s | 2 +- libsrc/atmos/crt0.s | 8 +- libsrc/c128/crt0.s | 8 +- libsrc/c128/mou/c128-1351.s | 4 +- libsrc/c128/mou/c128-inkwell.s | 4 +- libsrc/c128/mou/c128-joy.s | 4 +- libsrc/c128/mou/c128-pot.s | 4 +- libsrc/c16/crt0.s | 8 +- libsrc/c64/crt0.s | 8 +- libsrc/c64/mou/c64-1351.s | 4 +- libsrc/c64/mou/c64-inkwell.s | 4 +- libsrc/c64/mou/c64-joy.s | 4 +- libsrc/c64/mou/c64-pot.s | 4 +- libsrc/cbm/dir.s | 8 +- libsrc/cbm/open.s | 2 +- libsrc/cbm/write.s | 2 +- libsrc/cbm510/crt0.s | 12 +- libsrc/cbm510/mou/cbm510-inkwl.s | 4 +- libsrc/cbm510/mou/cbm510-joy.s | 4 +- libsrc/cbm610/crt0.s | 12 +- libsrc/common/_fopen.s | 10 +- libsrc/common/_heap.s | 6 +- libsrc/common/_idiv32by16r16.s | 8 +- libsrc/common/_printf.s | 14 +- libsrc/common/_udiv32by16r16.s | 8 +- libsrc/common/fprintf.s | 8 +- libsrc/common/fread.s | 14 +- libsrc/common/fscanf.s | 8 +- libsrc/common/interrupt.s | 4 +- libsrc/common/itoa.s | 10 +- libsrc/common/longjmp.s | 6 +- libsrc/common/lz4.s | 2 +- libsrc/common/memcpy.s | 6 +- libsrc/common/memset.s | 6 +- libsrc/common/printf.s | 6 +- libsrc/common/realloc.s | 2 +- libsrc/common/scanf.s | 6 +- libsrc/common/setjmp.s | 6 +- libsrc/common/snprintf.s | 8 +- libsrc/common/sprintf.s | 8 +- libsrc/common/sscanf.s | 8 +- libsrc/common/vfprintf.s | 10 +- libsrc/common/vfscanf.s | 8 +- libsrc/common/vprintf.s | 14 +- libsrc/common/vscanf.s | 12 +- libsrc/common/vsnprintf.s | 14 +- libsrc/common/vsscanf.s | 10 +- libsrc/conio/cprintf.s | 6 +- libsrc/conio/cscanf.s | 4 +- libsrc/conio/vcprintf.s | 10 +- libsrc/creativision/crt0.s | 4 +- libsrc/cx16/crt0.s | 4 +- libsrc/cx16/mou/cx16-std.s | 4 +- libsrc/dbg/dbgdump.s | 12 +- libsrc/dbg/dbgsupp.s | 8 +- libsrc/gamate/crt0.s | 4 +- libsrc/geos-common/drivers/geos-stdmou.s | 12 +- libsrc/geos-common/system/crt0.s | 6 +- libsrc/kim1/crt0.s | 4 +- libsrc/lynx/crt0.s | 4 +- libsrc/lynx/lseek.s | 2 +- libsrc/nes/crt0.s | 4 +- libsrc/none/crt0.s | 4 +- libsrc/osic1p/crt0.s | 4 +- libsrc/pce/_printf.s | 12 +- libsrc/pce/crt0.s | 6 +- libsrc/pce/memcpy.s | 6 +- libsrc/pet/crt0.s | 8 +- libsrc/plus4/crt0.s | 8 +- libsrc/rp6502/crt0.s | 4 +- libsrc/rp6502/ria.s | 2 +- libsrc/rp6502/xreg.s | 6 +- libsrc/runtime/add.s | 24 ++-- libsrc/runtime/addeqsp.s | 10 +- libsrc/runtime/addysp.s | 8 +- libsrc/runtime/and.s | 8 +- libsrc/runtime/bpushbsp.s | 4 +- libsrc/runtime/decsp1.s | 8 +- libsrc/runtime/decsp2.s | 8 +- libsrc/runtime/decsp3.s | 8 +- libsrc/runtime/decsp4.s | 8 +- libsrc/runtime/decsp5.s | 8 +- libsrc/runtime/decsp6.s | 8 +- libsrc/runtime/decsp7.s | 8 +- libsrc/runtime/decsp8.s | 8 +- libsrc/runtime/enter.s | 10 +- libsrc/runtime/eq.s | 2 +- libsrc/runtime/icmp.s | 14 +- libsrc/runtime/incsp1.s | 6 +- libsrc/runtime/incsp2.s | 16 +-- libsrc/runtime/ladd.s | 12 +- libsrc/runtime/laddeqsp.s | 18 +-- libsrc/runtime/land.s | 12 +- libsrc/runtime/lcmp.s | 10 +- libsrc/runtime/ldau0sp.s | 6 +- libsrc/runtime/ldauisp.s | 6 +- libsrc/runtime/ldaxsp.s | 6 +- libsrc/runtime/ldeaxysp.s | 10 +- libsrc/runtime/leaaxsp.s | 6 +- libsrc/runtime/leave.s | 18 +-- libsrc/runtime/lmul.s | 12 +- libsrc/runtime/lor.s | 12 +- libsrc/runtime/lpop.s | 12 +- libsrc/runtime/lpush.s | 12 +- libsrc/runtime/lrsub.s | 12 +- libsrc/runtime/lsub.s | 12 +- libsrc/runtime/lsubeqsp.s | 18 +-- libsrc/runtime/ludiv.s | 12 +- libsrc/runtime/lxor.s | 12 +- libsrc/runtime/or.s | 8 +- libsrc/runtime/popa.s | 10 +- libsrc/runtime/popptr1.s | 8 +- libsrc/runtime/popsreg.s | 8 +- libsrc/runtime/pusha.s | 16 +-- libsrc/runtime/pushax.s | 14 +- libsrc/runtime/pushbsp.s | 4 +- libsrc/runtime/pushlysp.s | 10 +- libsrc/runtime/pushwsp.s | 16 +-- libsrc/runtime/regswap.s | 6 +- libsrc/runtime/regswap1.s | 6 +- libsrc/runtime/regswap2.s | 10 +- libsrc/runtime/rsub.s | 8 +- libsrc/runtime/staspidx.s | 6 +- libsrc/runtime/staxsp.s | 8 +- libsrc/runtime/staxspi.s | 8 +- libsrc/runtime/steaxsp.s | 12 +- libsrc/runtime/stkchk.s | 14 +- libsrc/runtime/sub.s | 8 +- libsrc/runtime/subeqsp.s | 10 +- libsrc/runtime/subysp.s | 8 +- libsrc/runtime/swap.s | 14 +- libsrc/runtime/tosint.s | 12 +- libsrc/runtime/toslong.s | 26 ++-- libsrc/runtime/xor.s | 8 +- libsrc/runtime/zeropage.s | 2 +- libsrc/sim6502/crt0.s | 4 +- libsrc/sim6502/exehdr.s | 4 +- libsrc/supervision/crt0.s | 4 +- libsrc/sym1/crt0.s | 4 +- libsrc/telestrat/crt0.s | 8 +- libsrc/telestrat/open.s | 2 +- libsrc/telestrat/wherex.s | 2 +- libsrc/tgi/tgi_outtextxy.s | 10 +- libsrc/vic20/crt0.s | 8 +- libsrc/zlib/inflatemem.s | 10 +- samples/getsp.s | 6 +- samples/tinyshell.c | 12 +- src/cc65/codegen.c | 155 ++++++++++++----------- src/cc65/codeinfo.c | 4 +- src/cc65/codeinfo.h | 6 +- src/cc65/codeopt.c | 2 +- src/cc65/codeoptutil.c | 22 ++-- src/cc65/coptadd.c | 60 ++++----- src/cc65/coptadd.h | 20 +-- src/cc65/coptbool.c | 12 +- src/cc65/coptcmp.c | 16 +-- src/cc65/coptcmp.h | 4 +- src/cc65/coptmisc.c | 22 ++-- src/cc65/coptptrload.c | 10 +- src/cc65/coptptrload.h | 8 +- src/cc65/coptptrstore.c | 12 +- src/cc65/coptptrstore.h | 10 +- src/cc65/coptstop.c | 6 +- src/cc65/coptstore.c | 2 +- src/cc65/locals.c | 2 +- src/cc65/stdfunc.c | 34 ++--- src/dbginfo/dbgsh.c | 2 +- src/sim65/main.c | 2 +- targettest/atari/mem.c | 2 +- targettest/ft.c | 12 +- targettest/getsp.s | 6 +- test/val/bug1652-optimizer.c | 8 +- test/val/cq85.c | 2 +- 204 files changed, 915 insertions(+), 912 deletions(-) diff --git a/asminc/zeropage.inc b/asminc/zeropage.inc index 6627d86b6..5285779ba 100644 --- a/asminc/zeropage.inc +++ b/asminc/zeropage.inc @@ -8,7 +8,7 @@ ; by the compiler, ready for usage in asm code. - .globalzp sp, sreg, regsave + .globalzp c_sp, sreg, regsave .globalzp ptr1, ptr2, ptr3, ptr4 .globalzp tmp1, tmp2, tmp3, tmp4 .globalzp regbank diff --git a/doc/atari.sgml b/doc/atari.sgml index 060bc8ad4..1a83d74fb 100644 --- a/doc/atari.sgml +++ b/doc/atari.sgml @@ -1121,7 +1121,7 @@ If BSS and/or the stack shouldn't stay at the end of the program, some parts of the cc65 runtime lib need to be replaced/modified. common/_heap.s defines the location of the heap and atari/crt0.s -defines the location of the stack by initializing sp. +defines the location of the stack by initializing c_sp. Upgrading from an older cc65 version

diff --git a/doc/ca65.sgml b/doc/ca65.sgml index d2506d958..7b36abec5 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -5016,17 +5016,17 @@ bit. Using .if (.cpu .bitand CPU_ISET_65SC02) - lda (sp) + lda (c_sp) .else ldy #$00 - lda (sp),y + lda (c_sp),y .endif it is possible to determine if the - lda (sp) + lda (c_sp) instruction is supported, which is the case for the 65SC02, 65C02 and 65816 diff --git a/doc/cc65-intern.sgml b/doc/cc65-intern.sgml index 904cee070..9c59cd79a 100644 --- a/doc/cc65-intern.sgml +++ b/doc/cc65-intern.sgml @@ -131,7 +131,7 @@ All other parameters will be pushed to the C-stack from left to right. The rightmost parameter will have the lowest address on the stack, and multi-byte parameters will have their least significant byte at the lower address. -The Epilogue, after the function call

@@ -175,12 +175,12 @@ used if the return type is 32-bit. If the function has a void return type, the compiler will not depend on the result of A/X/sreg, so these may be clobbered by the function. -The C-stack pointer 1 byte 1 byte 1 byte 1 word _exit jsr reset diff --git a/libsrc/apple2/callmain.s b/libsrc/apple2/callmain.s index 71a8b5611..c43e339aa 100644 --- a/libsrc/apple2/callmain.s +++ b/libsrc/apple2/callmain.s @@ -54,7 +54,7 @@ exit: ldx #$02 ; Copy back the zero-page stuff. ldx #zpspace-1 : lda zpsave,x - sta sp,x + sta c_sp,x dex bpl :- diff --git a/libsrc/apple2/crt0.s b/libsrc/apple2/crt0.s index ce14cc1e3..47ac70a7e 100644 --- a/libsrc/apple2/crt0.s +++ b/libsrc/apple2/crt0.s @@ -43,7 +43,7 @@ ; Save the zero-page locations that we need. init: ldx #zpspace-1 -: lda sp,x +: lda c_sp,x sta zpsave,x dex bpl :- @@ -82,8 +82,8 @@ basic: lda HIMEM ldx HIMEM+1 ; Set up the C stack. -: sta sp - stx sp+1 +: sta c_sp + stx c_sp+1 ; ProDOS TechRefMan, chapter 5.3.5: ; "Your system program should place in the RESET vector the diff --git a/libsrc/apple2/exec.s b/libsrc/apple2/exec.s index 4e5e77a6e..38f31ee37 100644 --- a/libsrc/apple2/exec.s +++ b/libsrc/apple2/exec.s @@ -42,9 +42,9 @@ _exec: ; binary programs so we should do the same too in any case ; especially as _we_ rely on it in mainargs.s for argv[0] ldy #$00 - lda (sp),y + lda (c_sp),y tay -: lda (sp),y +: lda (c_sp),y sta $0280,y dey bpl :- diff --git a/libsrc/apple2/filename.s b/libsrc/apple2/filename.s index 0d4b6bedd..f4723ee1f 100644 --- a/libsrc/apple2/filename.s +++ b/libsrc/apple2/filename.s @@ -34,8 +34,8 @@ pushname: sta mliparam + MLI::ON_LINE::UNIT_NUM ; Use allocated pathname buffer - lda sp - ldx sp+1 + lda c_sp + ldx c_sp+1 sta mliparam + MLI::ON_LINE::DATA_BUFFER stx mliparam + MLI::ON_LINE::DATA_BUFFER+1 @@ -46,16 +46,16 @@ pushname: bcs addsp65 ; Get volume name length - lda (sp),y + lda (c_sp),y and #15 ; Max volume name length ; Bracket volume name with slashes to form prefix sta tmp1 lda #'/' - sta (sp),y + sta (c_sp),y ldy tmp1 iny ; Leading slash - sta (sp),y + sta (c_sp),y iny ; Trailing slash ; Adjust source pointer for copy @@ -69,7 +69,7 @@ pushname: ; Copy source to allocated pathname buffer copy: lda (ptr1),y - sta (sp),y + sta (c_sp),y beq setlen iny cpy #FILENAME_MAX @@ -86,7 +86,7 @@ addsp65:ldy #FILENAME_MAX setlen: tya jsr decsp1 ; Preserves A ldy #$00 - sta (sp),y + sta (c_sp),y ; Return success tya diff --git a/libsrc/apple2/mli_file_info_direct.s b/libsrc/apple2/mli_file_info_direct.s index c15ebc28f..7fdaa9edf 100644 --- a/libsrc/apple2/mli_file_info_direct.s +++ b/libsrc/apple2/mli_file_info_direct.s @@ -11,8 +11,8 @@ ; Returns with carry set on error, and sets errno mli_file_info_direct: ; Set pushed name - lda sp - ldx sp+1 + lda c_sp + ldx c_sp+1 sta mliparam + MLI::INFO::PATHNAME stx mliparam + MLI::INFO::PATHNAME+1 diff --git a/libsrc/apple2/mou/a2.stdmou.s b/libsrc/apple2/mou/a2.stdmou.s index 9c2f96200..38cd7c957 100644 --- a/libsrc/apple2/mou/a2.stdmou.s +++ b/libsrc/apple2/mou/a2.stdmou.s @@ -341,10 +341,10 @@ MOVE: ldy #$00 ; Start at top of stack ; Set x - lda (sp),y + lda (c_sp),y iny sta pos1_lo,x - lda (sp),y + lda (c_sp),y sta pos1_hi,x ; Update cursor diff --git a/libsrc/apple2/open.s b/libsrc/apple2/open.s index 7ece7f18d..8f1df26df 100644 --- a/libsrc/apple2/open.s +++ b/libsrc/apple2/open.s @@ -101,8 +101,8 @@ found: tya bne oserr1 ; Set pushed name - lda sp - ldx sp+1 + lda c_sp + ldx c_sp+1 sta mliparam + MLI::OPEN::PATHNAME stx mliparam + MLI::OPEN::PATHNAME+1 diff --git a/libsrc/apple2/syschdir.s b/libsrc/apple2/syschdir.s index b3f81e2a5..be78a91b9 100644 --- a/libsrc/apple2/syschdir.s +++ b/libsrc/apple2/syschdir.s @@ -17,8 +17,8 @@ __syschdir: bne oserr ; Set pushed name - lda sp - ldx sp+1 + lda c_sp + ldx c_sp+1 sta mliparam + MLI::PREFIX::PATHNAME stx mliparam + MLI::PREFIX::PATHNAME+1 diff --git a/libsrc/apple2/sysmkdir.s b/libsrc/apple2/sysmkdir.s index 7759da260..e59421319 100644 --- a/libsrc/apple2/sysmkdir.s +++ b/libsrc/apple2/sysmkdir.s @@ -23,8 +23,8 @@ __sysmkdir: bne oserr ; Set pushed name - lda sp - ldx sp+1 + lda c_sp + ldx c_sp+1 sta mliparam + MLI::CREATE::PATHNAME stx mliparam + MLI::CREATE::PATHNAME+1 diff --git a/libsrc/apple2/sysremove.s b/libsrc/apple2/sysremove.s index 08c4dff68..088407024 100644 --- a/libsrc/apple2/sysremove.s +++ b/libsrc/apple2/sysremove.s @@ -16,8 +16,8 @@ __sysremove: bne oserr ; Set pushed name - lda sp - ldx sp+1 + lda c_sp + ldx c_sp+1 sta mliparam + MLI::DESTROY::PATHNAME stx mliparam + MLI::DESTROY::PATHNAME+1 diff --git a/libsrc/apple2/sysrename.s b/libsrc/apple2/sysrename.s index 0fe8dd7b1..3e380548f 100644 --- a/libsrc/apple2/sysrename.s +++ b/libsrc/apple2/sysrename.s @@ -22,8 +22,8 @@ __sysrename: bne oserr1 ; Save pushed oldname - lda sp - ldx sp+1 + lda c_sp + ldx c_sp+1 sta ptr3 stx ptr3+1 @@ -40,8 +40,8 @@ __sysrename: stx mliparam + MLI::RENAME::PATHNAME+1 ; Set pushed newname - lda sp - ldx sp+1 + lda c_sp + ldx c_sp+1 sta mliparam + MLI::RENAME::NEW_PATHNAME stx mliparam + MLI::RENAME::NEW_PATHNAME+1 diff --git a/libsrc/atari/crt0.s b/libsrc/atari/crt0.s index 50e3ca7b6..23c1f580c 100644 --- a/libsrc/atari/crt0.s +++ b/libsrc/atari/crt0.s @@ -59,8 +59,8 @@ start: lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) - sta sp - stx sp+1 + sta c_sp + stx c_sp+1 .else @@ -75,11 +75,11 @@ start: lda MEMTOP sbc #<__RESERVED_MEMORY__ sta APPMHI ; initialize our APPMHI value - sta sp ; set up runtime stack part 1 + sta c_sp ; set up runtime stack part 1 lda MEMTOP+1 sbc #>__RESERVED_MEMORY__ sta APPMHI+1 - sta sp+1 ; set up runtime stack part 2 + sta c_sp+1 ; set up runtime stack part 2 .endif diff --git a/libsrc/atari/diopncls.s b/libsrc/atari/diopncls.s index f40d6bba4..a5c145081 100644 --- a/libsrc/atari/diopncls.s +++ b/libsrc/atari/diopncls.s @@ -16,7 +16,7 @@ .export sectsizetab .import ___oserror, __sio_call, _dio_read .import pushax, addysp, subysp - .importzp ptr2, sp + .importzp ptr2, c_sp .include "atari.inc" @@ -78,10 +78,10 @@ _dio_open: ldy #128 jsr subysp ; allocate buffer on the stack - lda sp + lda c_sp pha - lda sp+1 - pha ; save sp (buffer address) on processor stack + lda c_sp+1 + pha ; save c_sp (buffer address) on processor stack lda ptr2 ldx ptr2+1 diff --git a/libsrc/atari/fdtable.s b/libsrc/atari/fdtable.s index fd9f5021b..d1d869387 100644 --- a/libsrc/atari/fdtable.s +++ b/libsrc/atari/fdtable.s @@ -6,7 +6,7 @@ .include "atari.inc" .include "fd.inc" - .importzp tmp1,tmp2,tmp3,ptr4,sp + .importzp tmp1,tmp2,tmp3,ptr4,c_sp .import fd_table,fd_index .import fdt_to_fdi .export clriocb @@ -229,7 +229,7 @@ freefnd:txa beq l2 l1: ldy #0 - lda (sp),y ; get device + lda (c_sp),y ; get device l2: sta fd_table+ft_dev,x ; set device lda #1 sta fd_table+ft_usa,x ; set usage counter diff --git a/libsrc/atari/mcbpm.s b/libsrc/atari/mcbpm.s index 9e6ccc2c5..bc36b6f99 100644 --- a/libsrc/atari/mcbpm.s +++ b/libsrc/atari/mcbpm.s @@ -8,7 +8,7 @@ ; .include "atari.inc" - .importzp sp + .importzp c_sp .export _mouse_pm_callbacks .constructor pm_init, 27 .destructor pm_down @@ -193,22 +193,22 @@ pm_init: .else -; use top of memory and lower sp accordingly - sta sp +; use top of memory and lower c_sp accordingly + sta c_sp sta MOUSE_PM_BASE - lda sp+1 + lda c_sp+1 and #7 ; offset within 2K cmp #3 + MOUSE_PM_RAW + 1 ; can we use it? bcc @decr ; no - lda sp+1 + lda c_sp+1 and #$F8 @set: adc #3 + MOUSE_PM_RAW - 1 ; CF is set, so adding MOUSE_PM_RAW + 3 sta MOUSE_PM_BASE+1 - sta sp+1 + sta c_sp+1 bne @cont ; jump always -@decr: lda sp+1 +@decr: lda c_sp+1 and #$F8 sbc #8 - 1 ; CF is clear, subtracts 8 bcs @set ; jump always diff --git a/libsrc/atari/mou/atrjoy.s b/libsrc/atari/mou/atrjoy.s index a93c7de13..f30d72050 100644 --- a/libsrc/atari/mou/atrjoy.s +++ b/libsrc/atari/mou/atrjoy.s @@ -241,11 +241,11 @@ MOVE: php jsr CMOVEY ; Set it ldy #$01 - lda (sp),y + lda (c_sp),y sta XPos+1 tax dey - lda (sp),y + lda (c_sp),y sta XPos ; New X position jsr CMOVEX ; Move the cursor diff --git a/libsrc/atari/mou/atrst.s b/libsrc/atari/mou/atrst.s index 626b7a8f7..7f915cc36 100644 --- a/libsrc/atari/mou/atrst.s +++ b/libsrc/atari/mou/atrst.s @@ -399,12 +399,12 @@ MOVE: php jsr CMOVEY ; Set it ldy #$01 - lda (sp),y + lda (c_sp),y sta XPos+1 sta XPosWrk+1 tax dey - lda (sp),y + lda (c_sp),y sta XPos ; New X position sta XPosWrk jsr CMOVEX ; Move the cursor diff --git a/libsrc/atari/mou/atrtt.s b/libsrc/atari/mou/atrtt.s index f7c56e9f2..516565844 100644 --- a/libsrc/atari/mou/atrtt.s +++ b/libsrc/atari/mou/atrtt.s @@ -236,11 +236,11 @@ MOVE: php jsr CMOVEY ; Set it ldy #$01 - lda (sp),y + lda (c_sp),y sta XPos+1 tax dey - lda (sp),y + lda (c_sp),y sta XPos ; New X position jsr CMOVEX ; Move the cursor diff --git a/libsrc/atari/sysrename.s b/libsrc/atari/sysrename.s index e526af5c8..b410ebcfd 100644 --- a/libsrc/atari/sysrename.s +++ b/libsrc/atari/sysrename.s @@ -6,7 +6,7 @@ .include "atari.inc" .import findfreeiocb - .importzp tmp4, sp, ptr2, ptr3 + .importzp tmp4, c_sp, ptr2, ptr3 .import incsp2, subysp, addysp, popax .ifdef UCASE_FILENAME .importzp tmp3 @@ -118,19 +118,19 @@ L1: jsr subysp ; make room on the stack ; copy old name ldy #0 con: lda (ptr3),y - sta (sp),y + sta (c_sp),y beq copyend iny bne con copyend:lda #$20 ; space - sta (sp),y + sta (c_sp),y iny tya ; get current offset (beyond old name) clc - adc sp + adc c_sp sta ptr3 - lda sp+1 + lda c_sp+1 adc #0 sta ptr3+1 ; ptr3 now contains pointer to space for new filename @@ -143,9 +143,9 @@ cnn: lda (ptr2),y bne cnn copend2:ldx tmp4 - lda sp + lda c_sp sta ICBAL,x - lda sp+1 + lda c_sp+1 sta ICBAH,x lda #RENAME sta ICCOM,x @@ -160,13 +160,13 @@ copend2:ldx tmp4 ; clean up stack - lda sp + lda c_sp clc adc sspc - sta sp - lda sp+1 + sta c_sp + lda c_sp+1 adc sspc+1 - sta sp+1 + sta c_sp+1 ; handle status diff --git a/libsrc/atari/ucase_fn.s b/libsrc/atari/ucase_fn.s index f7f03915d..534c6a21c 100644 --- a/libsrc/atari/ucase_fn.s +++ b/libsrc/atari/ucase_fn.s @@ -24,7 +24,7 @@ .importzp tmp2 .import __defdev .endif - .importzp tmp3,ptr4,sp + .importzp tmp3,ptr4,c_sp .import subysp,addysp .export ucase_fn @@ -63,13 +63,13 @@ hasdev: ldy #0 loop2: lda (ptr4),y - sta (sp),y + sta (c_sp),y beq copy_end bmi L1 ; Not lowercase (also, invalid, should reject) cmp #'a' bcc L1 ; Not lowercase and #$DF ; make upper case char, assume ASCII chars - sta (sp),y ; store back + sta (c_sp),y ; store back L1: iny bpl loop2 ; bpl: this way we only support a max. length of 127 @@ -93,15 +93,15 @@ copy_end: jsr subysp ; adjust stack pointer dey cpdev: lda __defdev,y - sta (sp),y ; insert device name, number and ':' + sta (c_sp),y ; insert device name, number and ':' dey bpl cpdev hasdev2: .endif ; leave A and X pointing to the modified filename - lda sp - ldx sp+1 + lda c_sp + ldx c_sp+1 clc ; indicate success rts diff --git a/libsrc/atari2600/crt0.s b/libsrc/atari2600/crt0.s index 4f09a0a5a..7b5b679b0 100644 --- a/libsrc/atari2600/crt0.s +++ b/libsrc/atari2600/crt0.s @@ -35,8 +35,8 @@ clearLoop: ; Initialize C stack pointer lda #<(__RAM_START__ + __RAM_SIZE__) ldx #>(__RAM_START__ + __RAM_SIZE__) - sta sp - stx sp+1 + sta c_sp + stx c_sp+1 ; Call main jsr _main diff --git a/libsrc/atari5200/crt0.s b/libsrc/atari5200/crt0.s index 8f6e02273..a72d7f9f6 100644 --- a/libsrc/atari5200/crt0.s +++ b/libsrc/atari5200/crt0.s @@ -27,8 +27,8 @@ start: lda #<(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__) ldx #>(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__) - sta sp - stx sp+1 ; Set argument stack ptr + sta c_sp + stx c_sp+1 ; Set argument stack ptr ; Call the module constructors. diff --git a/libsrc/atari7800/crt0.s b/libsrc/atari7800/crt0.s index e791179f3..dea351473 100644 --- a/libsrc/atari7800/crt0.s +++ b/libsrc/atari7800/crt0.s @@ -30,9 +30,9 @@ start: ; Set up parameter stack lda #<(__RAM3_START__ + __RAM3_SIZE__) - sta sp + sta c_sp lda #>(__RAM3_START__ + __RAM3_SIZE__) - sta sp+1 + sta c_sp+1 jsr copydata jsr zerobss diff --git a/libsrc/atari7800/mono_setcursor.s b/libsrc/atari7800/mono_setcursor.s index 02e0308f6..995f0d661 100644 --- a/libsrc/atari7800/mono_setcursor.s +++ b/libsrc/atari7800/mono_setcursor.s @@ -27,7 +27,7 @@ .constructor mono_init_cursor .interruptor mono_blink_cursor - .importzp sp + .importzp c_sp .import _zonecounter .import _mono_zones .import cursor diff --git a/libsrc/atari7800/setcursor.s b/libsrc/atari7800/setcursor.s index f438de24f..040732cff 100644 --- a/libsrc/atari7800/setcursor.s +++ b/libsrc/atari7800/setcursor.s @@ -27,7 +27,7 @@ .constructor init_cursor .interruptor blink_cursor - .importzp sp + .importzp c_sp .import _zonecounter .import _zones .import cursor diff --git a/libsrc/atmos/crt0.s b/libsrc/atmos/crt0.s index 8c2be656c..55c60dd30 100644 --- a/libsrc/atmos/crt0.s +++ b/libsrc/atmos/crt0.s @@ -51,7 +51,7 @@ _exit: jsr donelib ldx #zpspace - 1 L2: lda zpsave,x - sta sp,x + sta c_sp,x dex bpl L2 @@ -68,7 +68,7 @@ L2: lda zpsave,x ; Save the zero-page area that we're about to use. init: ldx #zpspace - 1 -L1: lda sp,x +L1: lda c_sp,x sta zpsave,x dex bpl L1 @@ -85,8 +85,8 @@ L1: lda sp,x lda #<(__MAIN_START__ + __MAIN_SIZE__) ldx #>(__MAIN_START__ + __MAIN_SIZE__) - sta sp - stx sp+1 ; Set argument stack ptr + sta c_sp + stx c_sp+1 ; Set argument stack ptr ; Call the module constructors. diff --git a/libsrc/c128/crt0.s b/libsrc/c128/crt0.s index ba6a78ac5..f6a55778c 100644 --- a/libsrc/c128/crt0.s +++ b/libsrc/c128/crt0.s @@ -39,7 +39,7 @@ Start: ; Save the zero-page locations that we need. ldx #zpspace-1 -L1: lda sp,x +L1: lda c_sp,x sta zpsave,x dex bpl L1 @@ -58,8 +58,8 @@ L1: lda sp,x lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) - sta sp - stx sp+1 ; Set argument stack ptr + sta c_sp + stx c_sp+1 ; Set argument stack ptr ; Call the module constructors. @@ -85,7 +85,7 @@ _exit: pha ; Save the return code on stack ldx #zpspace-1 L2: lda zpsave,x - sta sp,x + sta c_sp,x dex bpl L2 diff --git a/libsrc/c128/mou/c128-1351.s b/libsrc/c128/mou/c128-1351.s index 76e28d9f7..f6954c823 100644 --- a/libsrc/c128/mou/c128-1351.s +++ b/libsrc/c128/mou/c128-1351.s @@ -296,11 +296,11 @@ MOVE: sei ; No interrupts jsr CMOVEY ; Set it ldy #$01 - lda (sp),y + lda (c_sp),y sta XPos+1 tax dey - lda (sp),y + lda (c_sp),y sta XPos ; New X position jsr CMOVEX ; Move the cursor diff --git a/libsrc/c128/mou/c128-inkwell.s b/libsrc/c128/mou/c128-inkwell.s index 2aac7d32d..b86959788 100644 --- a/libsrc/c128/mou/c128-inkwell.s +++ b/libsrc/c128/mou/c128-inkwell.s @@ -323,10 +323,10 @@ MOVE: sei ; No interrupts jsr MoveY ldy #$01 - lda (sp),y + lda (c_sp),y tax dey - lda (sp),y + lda (c_sp),y jsr MoveX ; Move the cursor cli ; Allow interrupts diff --git a/libsrc/c128/mou/c128-joy.s b/libsrc/c128/mou/c128-joy.s index d809db526..26367f8df 100644 --- a/libsrc/c128/mou/c128-joy.s +++ b/libsrc/c128/mou/c128-joy.s @@ -297,11 +297,11 @@ MOVE: sei ; No interrupts jsr CMOVEY ; Set it ldy #$01 - lda (sp),y + lda (c_sp),y sta XPos+1 tax dey - lda (sp),y + lda (c_sp),y sta XPos ; New X position jsr CMOVEX ; Move the cursor diff --git a/libsrc/c128/mou/c128-pot.s b/libsrc/c128/mou/c128-pot.s index 1cbe4aa18..55de4ac12 100644 --- a/libsrc/c128/mou/c128-pot.s +++ b/libsrc/c128/mou/c128-pot.s @@ -297,11 +297,11 @@ MOVE: sei ; No interrupts jsr CMOVEY ; Set it ldy #$01 - lda (sp),y + lda (c_sp),y sta XPos+1 tax dey - lda (sp),y + lda (c_sp),y sta XPos ; New X position jsr CMOVEX ; Move the cursor diff --git a/libsrc/c16/crt0.s b/libsrc/c16/crt0.s index 1df1e5c62..c203fb20f 100644 --- a/libsrc/c16/crt0.s +++ b/libsrc/c16/crt0.s @@ -24,7 +24,7 @@ Start: ; Save the zero-page locations that we need. ldx #zpspace-1 -L1: lda sp,x +L1: lda c_sp,x sta zpsave,x dex bpl L1 @@ -49,8 +49,8 @@ L1: lda sp,x bcc MemOk ldy #$80 ldx #$00 -MemOk: stx sp - sty sp+1 ; set argument stack ptr +MemOk: stx c_sp + sty c_sp+1 ; set argument stack ptr ; Call the module constructors. @@ -69,7 +69,7 @@ _exit: pha ; Save the return code on stack ldx #zpspace-1 L2: lda zpsave,x - sta sp,x + sta c_sp,x dex bpl L2 diff --git a/libsrc/c64/crt0.s b/libsrc/c64/crt0.s index 4e5c7c9d4..dea9226aa 100644 --- a/libsrc/c64/crt0.s +++ b/libsrc/c64/crt0.s @@ -55,7 +55,7 @@ _exit: pha ; Save the return code on stack ldx #zpspace-1 L2: lda zpsave,x - sta sp,x + sta c_sp,x dex bpl L2 @@ -85,7 +85,7 @@ init: ; Save the zero-page locations that we need. ldx #zpspace-1 -L1: lda sp,x +L1: lda c_sp,x sta zpsave,x dex bpl L1 @@ -94,8 +94,8 @@ L1: lda sp,x lda #<(__MAIN_START__ + __MAIN_SIZE__) ldx #>(__MAIN_START__ + __MAIN_SIZE__) - sta sp - stx sp+1 ; Set argument stack ptr + sta c_sp + stx c_sp+1 ; Set argument stack ptr ; Switch to the second charset. diff --git a/libsrc/c64/mou/c64-1351.s b/libsrc/c64/mou/c64-1351.s index ce0f18803..dcf949730 100644 --- a/libsrc/c64/mou/c64-1351.s +++ b/libsrc/c64/mou/c64-1351.s @@ -239,11 +239,11 @@ MOVE: sei ; No interrupts jsr CMOVEY ; Set it ldy #$01 - lda (sp),y + lda (c_sp),y sta XPos+1 tax dey - lda (sp),y + lda (c_sp),y sta XPos ; New X position jsr CMOVEX ; Move the cursor diff --git a/libsrc/c64/mou/c64-inkwell.s b/libsrc/c64/mou/c64-inkwell.s index d2f14a6f0..68941260c 100644 --- a/libsrc/c64/mou/c64-inkwell.s +++ b/libsrc/c64/mou/c64-inkwell.s @@ -249,10 +249,10 @@ MOVE: sei ; No interrupts jsr MoveY ldy #$01 - lda (sp),y + lda (c_sp),y tax dey - lda (sp),y + lda (c_sp),y jsr MoveX ; Move the cursor cli ; Allow interrupts diff --git a/libsrc/c64/mou/c64-joy.s b/libsrc/c64/mou/c64-joy.s index 5ee1b4f84..901b9c42d 100644 --- a/libsrc/c64/mou/c64-joy.s +++ b/libsrc/c64/mou/c64-joy.s @@ -245,11 +245,11 @@ MOVE: sei ; No interrupts jsr CMOVEY ; Set it ldy #$01 - lda (sp),y + lda (c_sp),y sta XPos+1 tax dey - lda (sp),y + lda (c_sp),y sta XPos ; New X position jsr CMOVEX ; Move the cursor diff --git a/libsrc/c64/mou/c64-pot.s b/libsrc/c64/mou/c64-pot.s index 9bdf24f62..1728913e1 100644 --- a/libsrc/c64/mou/c64-pot.s +++ b/libsrc/c64/mou/c64-pot.s @@ -230,11 +230,11 @@ MOVE: sei ; No interrupts jsr CMOVEY ; Set it ldy #$01 - lda (sp),y + lda (c_sp),y sta XPos+1 tax dey - lda (sp),y + lda (c_sp),y sta XPos ; New X position jsr CMOVEX ; Move the cursor diff --git a/libsrc/cbm/dir.s b/libsrc/cbm/dir.s index 734485aaf..a78fc94a5 100644 --- a/libsrc/cbm/dir.s +++ b/libsrc/cbm/dir.s @@ -44,10 +44,10 @@ __dirread: ; Replace dir by dir->fd ldy #2 - lda (sp),y + lda (c_sp),y sta ptr1 iny - lda (sp),y + lda (c_sp),y sta ptr1+1 ldy #DIR::fd+1 lda (ptr1),y @@ -55,10 +55,10 @@ __dirread: dey lda (ptr1),y ldy #2 - sta (sp),y + sta (c_sp),y pla iny - sta (sp),y + sta (c_sp),y ; Get count, save it again, clear the high byte and call read(). By the ; previous actions, the stack frame is as read() needs it, and read() will diff --git a/libsrc/cbm/open.s b/libsrc/cbm/open.s index 47224925d..bf937ee0f 100644 --- a/libsrc/cbm/open.s +++ b/libsrc/cbm/open.s @@ -12,7 +12,7 @@ .import opencmdchannel, closecmdchannel, readdiskerror .import fnunit, fnisfile .import _close - .importzp sp, tmp2, tmp3 + .importzp c_sp, tmp2, tmp3 .include "errno.inc" .include "fcntl.inc" diff --git a/libsrc/cbm/write.s b/libsrc/cbm/write.s index 172e45382..43c7582f0 100644 --- a/libsrc/cbm/write.s +++ b/libsrc/cbm/write.s @@ -8,7 +8,7 @@ .constructor initstdout .import rwcommon - .importzp sp, ptr1, ptr2, ptr3 + .importzp c_sp, ptr1, ptr2, ptr3 .include "cbm.inc" .include "errno.inc" diff --git a/libsrc/cbm510/crt0.s b/libsrc/cbm510/crt0.s index 86137b1ca..80d587ff5 100644 --- a/libsrc/cbm510/crt0.s +++ b/libsrc/cbm510/crt0.s @@ -117,7 +117,7 @@ entry: php tya sec sbc #7 - sta $1FF ; Save new sp + sta $1FF ; Save new c_sp tay tsx @@ -145,7 +145,7 @@ entry: php iny sta (sysp1),y - ldy $1FF ; Restore sp in bank 15 + ldy $1FF ; Restore c_sp in bank 15 lda #.hibyte(expull-1) sta (sysp1),y @@ -245,7 +245,7 @@ L1: lda extzp,x dex bpl L1 -; Save the old stack pointer from the system bank; and, set up our hw sp. +; Save the old stack pointer from the system bank; and, set up our hw c_sp. tsx txa @@ -279,9 +279,9 @@ L3: lda vectors,x ; Set up the C stack. lda #.lobyte(callbank15::entry) - sta sp + sta c_sp lda #.hibyte(callbank15::entry) - sta sp+1 + sta c_sp+1 ; Set up the subroutine and jump vector table that redirects Kernal calls to ; the system bank. @@ -495,7 +495,7 @@ _exit: pha ; Save the return code on stack ; Set up the welcome code at the stack bottom in the system bank. ldy #$FF - lda (sysp1),y ; Load system bank sp + lda (sysp1),y ; Load system bank c_sp tax iny ; Y = 0 lda #$58 ; CLI opcode diff --git a/libsrc/cbm510/mou/cbm510-inkwl.s b/libsrc/cbm510/mou/cbm510-inkwl.s index ea6d95934..e5328cf75 100644 --- a/libsrc/cbm510/mou/cbm510-inkwl.s +++ b/libsrc/cbm510/mou/cbm510-inkwl.s @@ -256,10 +256,10 @@ MOVE: sei ; No interrupts jsr MoveY ldy #$01 - lda (sp),y + lda (c_sp),y tax dey - lda (sp),y + lda (c_sp),y jsr MoveX ; Move the cursor cli ; Allow interrupts diff --git a/libsrc/cbm510/mou/cbm510-joy.s b/libsrc/cbm510/mou/cbm510-joy.s index 4daa49272..912842be7 100644 --- a/libsrc/cbm510/mou/cbm510-joy.s +++ b/libsrc/cbm510/mou/cbm510-joy.s @@ -225,11 +225,11 @@ MOVE: sei ; No interrupts jsr MoveY ; Set new y position ldy #1 - lda (sp),y + lda (c_sp),y sta XPos+1 tax dey - lda (sp),y + lda (c_sp),y jsr MoveX ; Move the pointer cli ; Allow interrupts diff --git a/libsrc/cbm610/crt0.s b/libsrc/cbm610/crt0.s index 0ad343d7f..dc56fa2de 100644 --- a/libsrc/cbm610/crt0.s +++ b/libsrc/cbm610/crt0.s @@ -115,7 +115,7 @@ entry: php tya sec sbc #7 - sta $1FF ; Save new sp + sta $1FF ; Save new c_sp tay tsx @@ -143,7 +143,7 @@ entry: php iny sta (sysp1),y - ldy $1FF ; Restore sp in bank 15 + ldy $1FF ; Restore c_sp in bank 15 lda #.hibyte(expull-1) sta (sysp1),y @@ -243,7 +243,7 @@ L1: lda extzp,x dex bpl L1 -; Save the old stack pointer from the system bank; and, set up our hw sp. +; Save the old stack pointer from the system bank; and, set up our hw c_sp. tsx txa @@ -277,9 +277,9 @@ L3: lda vectors,x ; Set up the C stack. lda #.lobyte(callbank15::entry) - sta sp + sta c_sp lda #.hibyte(callbank15::entry) - sta sp+1 + sta c_sp+1 ; Set up the subroutine and jump vector table that redirects Kernal calls to ; the system bank. @@ -400,7 +400,7 @@ _exit: pha ; Save the return code ; Set up the welcome code at the stack bottom in the system bank. ldy #$FF - lda (sysp1),y ; Load system bank sp + lda (sysp1),y ; Load system bank c_sp tax iny ; Y = 0 lda #$58 ; CLI opcode diff --git a/libsrc/common/_fopen.s b/libsrc/common/_fopen.s index 17a1ec19b..0c234097e 100644 --- a/libsrc/common/_fopen.s +++ b/libsrc/common/_fopen.s @@ -9,7 +9,7 @@ .import _open .import pushax, incsp4, return0 - .importzp sp, ptr1 + .importzp c_sp, ptr1 .include "errno.inc" @@ -28,10 +28,10 @@ ; Get a pointer to the mode string ldy #1 - lda (sp),y + lda (c_sp),y sta ptr1+1 dey - lda (sp),y + lda (c_sp),y sta ptr1 ; Look at the first character in mode @@ -78,10 +78,10 @@ invmode: modeok: ldy #$00 txa ; Mode -> A - sta (sp),y + sta (c_sp),y tya iny - sta (sp),y + sta (c_sp),y ldy #4 ; Size of arguments in bytes jsr _open ; Will cleanup the stack diff --git a/libsrc/common/_heap.s b/libsrc/common/_heap.s index eb680fa20..e5d71d1be 100644 --- a/libsrc/common/_heap.s +++ b/libsrc/common/_heap.s @@ -6,7 +6,7 @@ .constructor initheap, 24 .import __BSS_RUN__, __BSS_SIZE__, __STACKSIZE__ - .importzp sp + .importzp c_sp .include "_heap.inc" @@ -31,10 +31,10 @@ ___heaplast: initheap: sec - lda sp + lda c_sp sbc #<__STACKSIZE__ sta ___heapend - lda sp+1 + lda c_sp+1 sbc #>__STACKSIZE__ sta ___heapend+1 rts diff --git a/libsrc/common/_idiv32by16r16.s b/libsrc/common/_idiv32by16r16.s index 7df78f4dd..9534f751f 100644 --- a/libsrc/common/_idiv32by16r16.s +++ b/libsrc/common/_idiv32by16r16.s @@ -20,17 +20,17 @@ ; Copy from stack to zeropage. This assumes ptr1 and ptr2 are adjacent. ldy #3 -@L1: lda (sp),y +@L1: lda (c_sp),y sta ptr1,y dey bpl @L1 lda #4 clc - adc sp - sta sp + adc c_sp + sta c_sp bcc @L2 - inc sp+1 + inc c_sp+1 @L2: pla ; Old rhs jmp idiv32by16r16 diff --git a/libsrc/common/_printf.s b/libsrc/common/_printf.s index d7eeb072d..40ab0bc64 100644 --- a/libsrc/common/_printf.s +++ b/libsrc/common/_printf.s @@ -338,25 +338,25 @@ MainLoop: jsr decsp6 ; 3 args ldy #5 lda OutData+1 - sta (sp),y + sta (c_sp),y dey lda OutData - sta (sp),y + sta (c_sp),y dey lda FSave+1 - sta (sp),y + sta (c_sp),y dey lda FSave - sta (sp),y + sta (c_sp),y dey lda FCount+1 - sta (sp),y + sta (c_sp),y dey lda FCount .if (.cpu .bitand ::CPU_ISET_65SC02) - sta (sp) + sta (c_sp) .else - sta (sp),y + sta (c_sp),y .endif jsr CallOutFunc ; Call the output function diff --git a/libsrc/common/_udiv32by16r16.s b/libsrc/common/_udiv32by16r16.s index a1d5f4e66..987390c04 100644 --- a/libsrc/common/_udiv32by16r16.s +++ b/libsrc/common/_udiv32by16r16.s @@ -21,17 +21,17 @@ ; Copy from stack to zeropage. This assumes ptr1 and ptr2 are adjacent. ldy #3 -@L1: lda (sp),y +@L1: lda (c_sp),y sta ptr1,y dey bpl @L1 lda #4 clc - adc sp - sta sp + adc c_sp + sta c_sp bcc @L2 - inc sp+1 + inc c_sp+1 @L2: jmp udiv32by16r16m diff --git a/libsrc/common/fprintf.s b/libsrc/common/fprintf.s index 1582e6521..af9a58ebc 100644 --- a/libsrc/common/fprintf.s +++ b/libsrc/common/fprintf.s @@ -6,7 +6,7 @@ .export _fprintf .import addysp, decsp4, _vfprintf - .importzp sp, ptr1 + .importzp c_sp, ptr1 .macpack generic @@ -38,9 +38,9 @@ _fprintf: ; Calculate a pointer to the Format argument lda ParamSize - add sp + add c_sp sta ptr1 - ldx sp+1 + ldx c_sp+1 bcc @L1 inx @L1: stx ptr1+1 @@ -49,7 +49,7 @@ _fprintf: ldy #4-1 @L2: lda (ptr1),y - sta (sp),y + sta (c_sp),y dey bpl @L2 diff --git a/libsrc/common/fread.s b/libsrc/common/fread.s index b39b9d748..be06c2a62 100644 --- a/libsrc/common/fread.s +++ b/libsrc/common/fread.s @@ -14,7 +14,7 @@ .import pushwysp .import tosumulax, tosudivax - .importzp ptr1, sp + .importzp ptr1, c_sp .include "errno.inc" .include "_file.inc" @@ -136,23 +136,23 @@ ; to read() by one, so read() starts to store data at buf+1. .if (.cpu .bitand ::CPU_ISET_65SC02) - lda (sp) + lda (c_sp) sta ptr1 add #1 - sta (sp) + sta (c_sp) ldy #1 .else ldy #0 - lda (sp),y + lda (c_sp),y sta ptr1 add #1 - sta (sp),y + sta (c_sp),y iny .endif - lda (sp),y + lda (c_sp),y sta ptr1+1 adc #0 - sta (sp),y ; ptr1 = buf++; + sta (c_sp),y ; ptr1 = buf++; ; Get the buffered character and place it as first character into the read ; buffer. diff --git a/libsrc/common/fscanf.s b/libsrc/common/fscanf.s index a3d1ec0a1..c687a0624 100644 --- a/libsrc/common/fscanf.s +++ b/libsrc/common/fscanf.s @@ -6,7 +6,7 @@ .export _fscanf .import addysp, decsp4, _vfscanf - .importzp sp, ptr1 + .importzp c_sp, ptr1 .macpack generic @@ -50,9 +50,9 @@ _fscanf: ; Calculate a pointer to the Format argument lda ParamSize - add sp + add c_sp sta ptr1 - ldx sp+1 + ldx c_sp+1 bcc @L1 inx @L1: stx ptr1+1 @@ -61,7 +61,7 @@ _fscanf: ldy #4-1 @L2: lda (ptr1),y - sta (sp),y + sta (c_sp),y dey bpl @L2 diff --git a/libsrc/common/interrupt.s b/libsrc/common/interrupt.s index 6bdbb5fe4..a67d51fda 100644 --- a/libsrc/common/interrupt.s +++ b/libsrc/common/interrupt.s @@ -93,8 +93,8 @@ zpsave: .res zpsavespace ; Set C level interrupt stack lda irqsp ldx irqsp+1 - sta sp - stx sp+1 + sta c_sp + stx c_sp+1 ; Call C level interrupt request handler jsr irqvec diff --git a/libsrc/common/itoa.s b/libsrc/common/itoa.s index 808f9bc33..a1cd53c8b 100644 --- a/libsrc/common/itoa.s +++ b/libsrc/common/itoa.s @@ -8,7 +8,7 @@ .export _itoa, _utoa .import addysp1 .import __hextab - .importzp sp, sreg, ptr2, ptr3, tmp1 + .importzp c_sp, sreg, ptr2, ptr3, tmp1 .rodata specval: @@ -21,18 +21,18 @@ specval: dopop: sta tmp1 ; will lose high byte ldy #0 - lda (sp),y + lda (c_sp),y sta ptr2 sta ptr3 iny - lda (sp),y + lda (c_sp),y sta ptr2+1 sta ptr3+1 iny - lda (sp),y + lda (c_sp),y sta sreg iny - lda (sp),y + lda (c_sp),y sta sreg+1 jmp addysp1 ; Bump stack pointer diff --git a/libsrc/common/longjmp.s b/libsrc/common/longjmp.s index 91606a442..8855286a9 100644 --- a/libsrc/common/longjmp.s +++ b/libsrc/common/longjmp.s @@ -7,7 +7,7 @@ .export _longjmp .import popptr1 - .importzp sp, ptr1, ptr2 + .importzp c_sp, ptr1, ptr2 _longjmp: sta ptr2 ; Save retval @@ -23,10 +23,10 @@ _longjmp: lda (ptr1),y iny - sta sp + sta c_sp lda (ptr1),y iny - sta sp+1 + sta c_sp+1 ; Get the old stack pointer diff --git a/libsrc/common/lz4.s b/libsrc/common/lz4.s index c53841897..5d26cb56a 100644 --- a/libsrc/common/lz4.s +++ b/libsrc/common/lz4.s @@ -61,7 +61,7 @@ ; } ; } - .importzp sp, sreg, regsave, regbank + .importzp c_sp, sreg, regsave, regbank .importzp tmp1, tmp2, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4 .macpack longbranch .import memcpy_upwards,pushax,popax diff --git a/libsrc/common/memcpy.s b/libsrc/common/memcpy.s index fd090c788..8f6531956 100644 --- a/libsrc/common/memcpy.s +++ b/libsrc/common/memcpy.s @@ -12,7 +12,7 @@ .export _memcpy, memcpy_upwards, memcpy_getparams .import popax, popptr1 - .importzp sp, ptr1, ptr2, ptr3 + .importzp c_sp, ptr1, ptr2, ptr3 ; ---------------------------------------------------------------------- _memcpy: @@ -70,10 +70,10 @@ memcpy_getparams: ; IMPORTANT! Function has to leave with Y=0! iny ; Y=0 guaranteed by popptr1, we need '1' here... ; (direct stack access is three cycles faster ; (total cycle count with return)) - lda (sp),y + lda (c_sp),y tax stx ptr2+1 ; save high byte of ptr2 dey ; Y = 0 - lda (sp),y ; Get ptr2 low + lda (c_sp),y ; Get ptr2 low sta ptr2 rts diff --git a/libsrc/common/memset.s b/libsrc/common/memset.s index be78fc30d..5d56507a5 100644 --- a/libsrc/common/memset.s +++ b/libsrc/common/memset.s @@ -17,7 +17,7 @@ .export _memset, _bzero, ___bzero .import popax - .importzp sp, ptr1, ptr2, ptr3 + .importzp c_sp, ptr1, ptr2, ptr3 _bzero: ___bzero: @@ -36,10 +36,10 @@ _memset: common: ; Fill value is in X! ldy #1 - lda (sp),y + lda (c_sp),y sta ptr1+1 ; save high byte of ptr dey ; Y = 0 - lda (sp),y ; Get ptr + lda (c_sp),y ; Get ptr sta ptr1 lsr ptr3+1 ; divide number of diff --git a/libsrc/common/printf.s b/libsrc/common/printf.s index 8d645dfa2..76e08e584 100644 --- a/libsrc/common/printf.s +++ b/libsrc/common/printf.s @@ -6,7 +6,7 @@ .export _printf .import _stdout, pushax, addysp, _vfprintf - .importzp sp, ptr1 + .importzp c_sp, ptr1 .macpack generic @@ -43,8 +43,8 @@ _printf: ; Now calculate the va_list pointer, which does points to Format - lda sp - ldx sp+1 + lda c_sp + ldx c_sp+1 add ParamSize bcc @L1 inx diff --git a/libsrc/common/realloc.s b/libsrc/common/realloc.s index 176871dd5..16d5eea41 100644 --- a/libsrc/common/realloc.s +++ b/libsrc/common/realloc.s @@ -4,7 +4,7 @@ ; void* __fastcall__ realloc (void* block, register size_t size) ; - .importzp ptr1, ptr2, ptr3, ptr4, tmp1, tmp2, tmp3, tmp4, sp + .importzp ptr1, ptr2, ptr3, ptr4, tmp1, tmp2, tmp3, tmp4, c_sp .import _malloc, _memcpy, _free .import pushax, popptr1, return0 .import incsp2, decsp2 diff --git a/libsrc/common/scanf.s b/libsrc/common/scanf.s index dd6c16ad1..92460b629 100644 --- a/libsrc/common/scanf.s +++ b/libsrc/common/scanf.s @@ -8,7 +8,7 @@ .export _scanf .import _stdin, pushax, addysp, _vfscanf - .import sp:zp, ptr1:zp + .import c_sp:zp, ptr1:zp .macpack generic @@ -34,8 +34,8 @@ _scanf: ; Now, calculate the va_list pointer, which does point to Format. - lda sp - ldx sp+1 + lda c_sp + ldx c_sp+1 add ArgSize bcc @L1 inx diff --git a/libsrc/common/setjmp.s b/libsrc/common/setjmp.s index 886853368..3c0b8aa17 100644 --- a/libsrc/common/setjmp.s +++ b/libsrc/common/setjmp.s @@ -8,7 +8,7 @@ .export ___setjmp .import return0 - .importzp sp, ptr1 + .importzp c_sp, ptr1 ___setjmp: sta ptr1 ; Save buf @@ -17,10 +17,10 @@ ___setjmp: ; The parameter stack is now empty, put it into buf - lda sp + lda c_sp sta (ptr1),y iny - lda sp+1 + lda c_sp+1 sta (ptr1),y iny diff --git a/libsrc/common/snprintf.s b/libsrc/common/snprintf.s index 33afb434d..c922a55bc 100644 --- a/libsrc/common/snprintf.s +++ b/libsrc/common/snprintf.s @@ -6,7 +6,7 @@ .export _snprintf .import pushax, addysp, decsp6, _vsnprintf - .importzp sp, ptr1 + .importzp c_sp, ptr1 .macpack generic @@ -38,9 +38,9 @@ _snprintf: ; Calculate a pointer to the Format argument lda ParamSize - add sp + add c_sp sta ptr1 - ldx sp+1 + ldx c_sp+1 bcc @L1 inx @L1: stx ptr1+1 @@ -49,7 +49,7 @@ _snprintf: ldy #6-1 @L2: lda (ptr1),y - sta (sp),y + sta (c_sp),y dey bpl @L2 diff --git a/libsrc/common/sprintf.s b/libsrc/common/sprintf.s index d502d8638..d2ce6602e 100644 --- a/libsrc/common/sprintf.s +++ b/libsrc/common/sprintf.s @@ -6,7 +6,7 @@ .export _sprintf .import pushax, addysp, decsp4, _vsprintf - .importzp sp, ptr1 + .importzp c_sp, ptr1 .macpack generic @@ -38,9 +38,9 @@ _sprintf: ; Calculate a pointer to the Format argument lda ParamSize - add sp + add c_sp sta ptr1 - ldx sp+1 + ldx c_sp+1 bcc @L1 inx @L1: stx ptr1+1 @@ -49,7 +49,7 @@ _sprintf: ldy #4-1 @L2: lda (ptr1),y - sta (sp),y + sta (c_sp),y dey bpl @L2 diff --git a/libsrc/common/sscanf.s b/libsrc/common/sscanf.s index 941f54e92..d393087d8 100644 --- a/libsrc/common/sscanf.s +++ b/libsrc/common/sscanf.s @@ -6,7 +6,7 @@ .export _sscanf .import addysp, decsp4, _vsscanf - .importzp sp, ptr1 + .importzp c_sp, ptr1 .macpack generic @@ -51,9 +51,9 @@ _sscanf: ; Calculate a pointer to the fixed parameters lda ParamSize - add sp + add c_sp sta ptr1 - ldx sp+1 + ldx c_sp+1 bcc @L1 inx @L1: stx ptr1+1 @@ -62,7 +62,7 @@ _sscanf: ldy #4-1 @L2: lda (ptr1),y - sta (sp),y + sta (c_sp),y dey bpl @L2 diff --git a/libsrc/common/vfprintf.s b/libsrc/common/vfprintf.s index 1225bcc47..3dc1e6729 100644 --- a/libsrc/common/vfprintf.s +++ b/libsrc/common/vfprintf.s @@ -8,7 +8,7 @@ .export _vfprintf .import push1, pushwysp, incsp6 .import _fwrite, __printf - .importzp sp, ptr1 + .importzp c_sp, ptr1 .macpack generic @@ -121,15 +121,15 @@ _vfprintf: ; exactly as _printf expects it. Parameters will get dropped by _printf. ldy #2 - lda (sp),y ; Low byte of f + lda (c_sp),y ; Low byte of f sta ptr lda #outdesc - sta (sp),y + sta (c_sp),y ; Restore low byte of ap and call _printf diff --git a/libsrc/common/vfscanf.s b/libsrc/common/vfscanf.s index c7d6e5564..71d7c634c 100644 --- a/libsrc/common/vfscanf.s +++ b/libsrc/common/vfscanf.s @@ -61,16 +61,16 @@ _vfscanf: ; Swap f against &d on the stack, placing f into d.data ldy #2 ; Offset of f on the stack - lda (sp),y + lda (c_sp),y sta d + SCANFDATA::DATA lda #d - sta (sp),y + sta (c_sp),y ; Restore the low byte of ap, and call the _scanf function diff --git a/libsrc/common/vprintf.s b/libsrc/common/vprintf.s index 0958b1038..1c44b61ef 100644 --- a/libsrc/common/vprintf.s +++ b/libsrc/common/vprintf.s @@ -7,7 +7,7 @@ .export _vprintf .import _vfprintf, _stdout .import decsp2 - .importzp sp + .importzp c_sp .proc _vprintf @@ -23,20 +23,20 @@ ; Move the format parameter down and store stdout in it's place ldy #2 - lda (sp),y + lda (c_sp),y ldy #0 - sta (sp),y + sta (c_sp),y ldy #3 - lda (sp),y + lda (c_sp),y ldy #1 - sta (sp),y + sta (c_sp),y iny lda _stdout - sta (sp),y + sta (c_sp),y iny lda _stdout+1 - sta (sp),y + sta (c_sp),y ; Restore A diff --git a/libsrc/common/vscanf.s b/libsrc/common/vscanf.s index 94afe527f..a97bd163a 100644 --- a/libsrc/common/vscanf.s +++ b/libsrc/common/vscanf.s @@ -31,22 +31,22 @@ _vscanf: ; Move the format down ldy #2 - lda (sp),y ; Load byte of format + lda (c_sp),y ; Load byte of format ldy #0 - sta (sp),y + sta (c_sp),y ldy #3 - lda (sp),y + lda (c_sp),y ldy #1 - sta (sp),y + sta (c_sp),y ; Store stdin into the stack frame iny lda _stdin - sta (sp),y + sta (c_sp),y iny lda _stdin+1 - sta (sp),y + sta (c_sp),y ; Restore the low byte of ap and jump to vfscanf, which will cleanup the stack diff --git a/libsrc/common/vsnprintf.s b/libsrc/common/vsnprintf.s index 048a756c3..780ab10ee 100644 --- a/libsrc/common/vsnprintf.s +++ b/libsrc/common/vsnprintf.s @@ -8,7 +8,7 @@ .export _vsnprintf, vsnprintf .import ldaxysp, popax, incsp2, incsp6 .import _memcpy, __printf - .importzp sp, ptr1 + .importzp c_sp, ptr1 .include "errno.inc" @@ -55,19 +55,19 @@ vsnprintf: ; be formatted and counted. ldy #2 - lda (sp),y + lda (c_sp),y sta ptr1 lda #outdesc - sta (sp),y + sta (c_sp),y ; Write size-1 to outdesc.uns. It will be -1 if there is no buffer. @@ -178,12 +178,12 @@ out: clc adc ccount+0 ldy #4 - sta (sp),y + sta (c_sp),y lda bufptr+1 adc ccount+1 iny - sta (sp),y + sta (c_sp),y ; Get Count from stack diff --git a/libsrc/common/vsscanf.s b/libsrc/common/vsscanf.s index 335712b20..2061861dc 100644 --- a/libsrc/common/vsscanf.s +++ b/libsrc/common/vsscanf.s @@ -9,7 +9,7 @@ .export _vsscanf .import popax, __scanf - .importzp sp, ptr1, ptr2 + .importzp c_sp, ptr1, ptr2 .macpack generic @@ -165,15 +165,15 @@ d: .addr get ; to d ldy #2 ; Stack offset of str - lda (sp),y + lda (c_sp),y sta sd + SSCANFDATA::STR lda #d - sta (sp),y + sta (c_sp),y lda #$00 sta sd + SSCANFDATA::INDEX diff --git a/libsrc/conio/cprintf.s b/libsrc/conio/cprintf.s index 01bd0bbc6..80bca2308 100644 --- a/libsrc/conio/cprintf.s +++ b/libsrc/conio/cprintf.s @@ -6,7 +6,7 @@ .export _cprintf .import pushax, addysp, _vcprintf - .importzp sp, ptr1 + .importzp c_sp, ptr1 .macpack generic @@ -31,9 +31,9 @@ _cprintf: dey dey ; Sub size of Format tya - add sp + add c_sp sta ptr1 - ldx sp+1 + ldx c_sp+1 bcc @L1 inx @L1: stx ptr1+1 diff --git a/libsrc/conio/cscanf.s b/libsrc/conio/cscanf.s index 7e54a844f..7ee532626 100644 --- a/libsrc/conio/cscanf.s +++ b/libsrc/conio/cscanf.s @@ -23,8 +23,8 @@ _cscanf: ; Now, calculate the va_list pointer -- which points to format. - ldx sp+1 - add sp + ldx c_sp+1 + add c_sp bcc @L1 inx @L1: sta ptr1 diff --git a/libsrc/conio/vcprintf.s b/libsrc/conio/vcprintf.s index 595a2d2c5..c6371f00e 100644 --- a/libsrc/conio/vcprintf.s +++ b/libsrc/conio/vcprintf.s @@ -7,7 +7,7 @@ .export _vcprintf .import pushax, popax, popptr1 .import __printf, _cputc - .importzp sp, ptr1, ptr2, ptr3, tmp1 + .importzp c_sp, ptr1, ptr2, ptr3, tmp1 .macpack generic .macpack cpu @@ -138,10 +138,10 @@ _vcprintf: ; Get the format parameter and push it again ldy #1 - lda (sp),y + lda (c_sp),y tax dey - lda (sp),y + lda (c_sp),y jsr pushax ; Replace the passed format parameter on the stack by &d - this creates @@ -150,10 +150,10 @@ _vcprintf: ldy #2 ; Low byte of d lda #outdesc - sta (sp),y + sta (c_sp),y ; Restore ap and call _printf diff --git a/libsrc/creativision/crt0.s b/libsrc/creativision/crt0.s index 5185ff237..70009e2ba 100644 --- a/libsrc/creativision/crt0.s +++ b/libsrc/creativision/crt0.s @@ -40,8 +40,8 @@ entry: ; Setup the argument stack ptr lda #<(__ZP_LAST__ + __STACKSIZE__) ldx #>(__ZP_LAST__ + __STACKSIZE__) - sta sp - stx sp+1 + sta c_sp + stx c_sp+1 ; Call module constructors jsr initlib diff --git a/libsrc/cx16/crt0.s b/libsrc/cx16/crt0.s index e37a64a7c..5ee81b184 100644 --- a/libsrc/cx16/crt0.s +++ b/libsrc/cx16/crt0.s @@ -80,8 +80,8 @@ init: lda #<(__MAIN_START__ + __MAIN_SIZE__) ldx #>(__MAIN_START__ + __MAIN_SIZE__) - sta sp - stx sp+1 ; Set argument stack ptr + sta c_sp + stx c_sp+1 ; Set argument stack ptr ; Switch to the lower/UPPER PetSCII charset. diff --git a/libsrc/cx16/mou/cx16-std.s b/libsrc/cx16/mou/cx16-std.s index f211815de..5bfe27a7d 100644 --- a/libsrc/cx16/mou/cx16-std.s +++ b/libsrc/cx16/mou/cx16-std.s @@ -238,11 +238,11 @@ MOVE: php jsr CMOVEY ; Set it ldy #$01 - lda (sp),y + lda (c_sp),y sta XPos+1 tax dey - lda (sp),y + lda (c_sp),y sta XPos ; New X position jsr CMOVEX ; Move the cursor diff --git a/libsrc/dbg/dbgdump.s b/libsrc/dbg/dbgdump.s index bc6a4bd40..335175840 100644 --- a/libsrc/dbg/dbgdump.s +++ b/libsrc/dbg/dbgdump.s @@ -7,23 +7,23 @@ .export _DbgMemDump .import addysp1 .import __hextab - .importzp sp, tmp2, tmp3, tmp4, ptr3, ptr4 + .importzp c_sp, tmp2, tmp3, tmp4, ptr3, ptr4 _DbgMemDump: ldy #0 - lda (sp),y ; Get length + lda (c_sp),y ; Get length sta tmp4 iny - lda (sp),y ; Get the string buffer + lda (c_sp),y ; Get the string buffer sta ptr3 iny - lda (sp),y + lda (c_sp),y sta ptr3+1 iny - lda (sp),y ; Get the address + lda (c_sp),y ; Get the address sta ptr4 iny - lda (sp),y + lda (c_sp),y sta ptr4+1 jsr addysp1 ; Drop the parameters diff --git a/libsrc/dbg/dbgsupp.s b/libsrc/dbg/dbgsupp.s index b1f122013..ce503bcab 100644 --- a/libsrc/dbg/dbgsupp.s +++ b/libsrc/dbg/dbgsupp.s @@ -36,9 +36,9 @@ DbgBreak: jsr DbgSwapZP ; Swap stuff lda #DbgStack - sta sp+1 + sta c_sp+1 jsr ResetDbgBreaks ; Reset temporary breakpoints jsr _DbgEntry ; Call C code jsr SetDbgBreaks ; Set temporary breakpoints @@ -61,7 +61,7 @@ DbgStack: ; Swap space for the C temporaries CTemp: -_DbgCS: .res 2 ; sp +_DbgCS: .res 2 ; c_sp _DbgHI: .res 2 ; sreg .res (zpsavespace-4) ; Other stuff @@ -78,7 +78,7 @@ Swap1: ldx CTemp,y lda <__ZP_START__,y sta CTemp,y txa - sta sp,y + sta c_sp,y dey bpl Swap1 rts diff --git a/libsrc/gamate/crt0.s b/libsrc/gamate/crt0.s index 5a5bb3aa0..67fa8813f 100644 --- a/libsrc/gamate/crt0.s +++ b/libsrc/gamate/crt0.s @@ -34,8 +34,8 @@ Start: ; Set up the stack lda #<(__RAM_START__+__RAM_SIZE__) ldx #>(__RAM_START__+__RAM_SIZE__) - sta sp - stx sp + 1 + sta c_sp + stx c_sp + 1 ; Call module constructors jsr initlib diff --git a/libsrc/geos-common/drivers/geos-stdmou.s b/libsrc/geos-common/drivers/geos-stdmou.s index 88bbc7df9..aacb2590e 100644 --- a/libsrc/geos-common/drivers/geos-stdmou.s +++ b/libsrc/geos-common/drivers/geos-stdmou.s @@ -13,7 +13,7 @@ .export _mouse_move, _mouse_buttons .import popsreg, addysp1 - .importzp sp, sreg, ptr1 + .importzp c_sp, sreg, ptr1 .include "const.inc" .include "jumptab.inc" @@ -87,22 +87,22 @@ _mouse_box: sta mouseBottom - lda (sp),y + lda (c_sp),y sta mouseRight iny - lda (sp),y + lda (c_sp),y sta mouseRight+1 ; maxx iny - lda (sp),y + lda (c_sp),y sta mouseTop iny ; Skip high byte iny - lda (sp),y + lda (c_sp),y sta mouseLeft iny - lda (sp),y + lda (c_sp),y sta mouseLeft+1 ; minx jmp addysp1 ; Drop params, return diff --git a/libsrc/geos-common/system/crt0.s b/libsrc/geos-common/system/crt0.s index 47cec74f2..e1751baef 100644 --- a/libsrc/geos-common/system/crt0.s +++ b/libsrc/geos-common/system/crt0.s @@ -11,7 +11,7 @@ .import initlib, donelib .import callmain .import zerobss - .importzp sp + .importzp c_sp .include "jumptab.inc" .include "geossym.inc" @@ -48,8 +48,8 @@ lda #<(__STACKADDR__ + __STACKSIZE__) ldx #>(__STACKADDR__ + __STACKSIZE__) - sta sp - stx sp+1 + sta c_sp + stx c_sp+1 ; Call the module constructors. diff --git a/libsrc/kim1/crt0.s b/libsrc/kim1/crt0.s index 906b3b980..adc934a78 100644 --- a/libsrc/kim1/crt0.s +++ b/libsrc/kim1/crt0.s @@ -26,9 +26,9 @@ _init: cld ; Clear decimal mode ; Set cc65 argument stack pointer lda #<(__RAM_START__ + __RAM_SIZE__) - sta sp + sta c_sp lda #>(__RAM_START__ + __RAM_SIZE__) - sta sp+1 + sta c_sp+1 ; Initialize memory storage diff --git a/libsrc/lynx/crt0.s b/libsrc/lynx/crt0.s index 030f523e9..e1f1c078e 100644 --- a/libsrc/lynx/crt0.s +++ b/libsrc/lynx/crt0.s @@ -80,8 +80,8 @@ MikeyInitData: .byte $9e,$18,$68,$1f,$00,$00,$00,$00,$00,$ff,$1a,$1b,$04,$0d,$2 lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) - sta sp - stx sp+1 + sta c_sp + stx c_sp+1 ; Init Mickey. diff --git a/libsrc/lynx/lseek.s b/libsrc/lynx/lseek.s index 04d816945..da0a1922b 100644 --- a/libsrc/lynx/lseek.s +++ b/libsrc/lynx/lseek.s @@ -11,7 +11,7 @@ ; ; off_t __fastcall__ lseek(int fd, off_t offset, int whence); - .importzp sp, sreg, regsave, regbank, tmp1, ptr1, ptr2 + .importzp c_sp, sreg, regsave, regbank, tmp1, ptr1, ptr2 .macpack longbranch .export _lseek .import addysp, stax0sp, tosand0ax, pusheax, asreax2 diff --git a/libsrc/nes/crt0.s b/libsrc/nes/crt0.s index 19e97bb12..dfc26dcde 100644 --- a/libsrc/nes/crt0.s +++ b/libsrc/nes/crt0.s @@ -107,8 +107,8 @@ start: lda #<(__SRAM_START__ + __SRAM_SIZE__) ldx #>(__SRAM_START__ + __SRAM_SIZE__) - sta sp - stx sp+1 ; Set argument stack ptr + sta c_sp + stx c_sp+1 ; Set argument stack ptr ; Call the module constructors. diff --git a/libsrc/none/crt0.s b/libsrc/none/crt0.s index 596fbcd46..443f453b9 100644 --- a/libsrc/none/crt0.s +++ b/libsrc/none/crt0.s @@ -10,8 +10,8 @@ lda #<__STACKSTART__ ldx #>__STACKSTART__ - sta sp - stx sp+1 + sta c_sp + stx c_sp+1 jsr zerobss jsr initlib jsr _main diff --git a/libsrc/osic1p/crt0.s b/libsrc/osic1p/crt0.s index 56abb7cdb..46d29ed66 100644 --- a/libsrc/osic1p/crt0.s +++ b/libsrc/osic1p/crt0.s @@ -34,8 +34,8 @@ _init: ldx #$FF ; Initialize stack pointer to $01FF lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) - sta sp - stx sp+1 + sta c_sp + stx c_sp+1 ; --------------------------------------------------------------------------- ; Initialize memory storage diff --git a/libsrc/pce/_printf.s b/libsrc/pce/_printf.s index e1d2a1cf4..675076ec6 100644 --- a/libsrc/pce/_printf.s +++ b/libsrc/pce/_printf.s @@ -329,22 +329,22 @@ MainLoop: jsr decsp6 ; 3 args ldy #5 lda OutData+1 - sta (sp),y + sta (c_sp),y dey lda OutData - sta (sp),y + sta (c_sp),y dey lda FSave+1 - sta (sp),y + sta (c_sp),y dey lda FSave - sta (sp),y + sta (c_sp),y dey lda FCount+1 - sta (sp),y + sta (c_sp),y dey lda FCount - sta (sp),y + sta (c_sp),y jsr CallOutFunc ; Call the output function ; We're back from out(), or we didn't call it. Check for end of string. diff --git a/libsrc/pce/crt0.s b/libsrc/pce/crt0.s index d6dee3ef4..660faae7f 100644 --- a/libsrc/pce/crt0.s +++ b/libsrc/pce/crt0.s @@ -13,7 +13,7 @@ .import initlib, donelib .import push0, _main .import IRQStub, __nmi - .importzp sp + .importzp c_sp ; Linker-generated .import __CARTSIZE__ @@ -86,8 +86,8 @@ start: sei ; Set up the stack lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) - sta sp - stx sp+1 + sta c_sp + stx c_sp+1 ; Call the module constructors. jsr initlib diff --git a/libsrc/pce/memcpy.s b/libsrc/pce/memcpy.s index 98db6a964..7ee33477b 100644 --- a/libsrc/pce/memcpy.s +++ b/libsrc/pce/memcpy.s @@ -18,7 +18,7 @@ .export memcpy_increment, memcpy_transfer, memcpy_getparams .import incsp2, popax, popptr1 - .importzp sp, ptr1, ptr2, ptr3 + .importzp c_sp, ptr1, ptr2, ptr3 ; The structure of the transfer instructions @@ -86,9 +86,9 @@ memcpy_getparams: ; (Direct stack access is six cycles faster [total cycle count].) iny ; (Y=0 by popptr1, need '1' here) save dest - lda (sp),y ; get high byte + lda (c_sp),y ; get high byte tax - lda (sp) ; get low byte + lda (c_sp) ; get low byte sta ptr2 stx ptr2+1 rts ; return dest address (for memmove) diff --git a/libsrc/pet/crt0.s b/libsrc/pet/crt0.s index e56a7eca4..e3c6ed4b4 100644 --- a/libsrc/pet/crt0.s +++ b/libsrc/pet/crt0.s @@ -23,7 +23,7 @@ Start: ; Save the zero-page locations that we need. ldx #zpspace-1 -L1: lda sp,x +L1: lda c_sp,x sta zpsave,x dex bpl L1 @@ -52,9 +52,9 @@ L1: lda sp,x stx spsave ; Save the system stack ptr lda MEMSIZE - sta sp + sta c_sp lda MEMSIZE+1 - sta sp+1 ; Set argument stack ptr + sta c_sp+1 ; Set argument stack ptr ; Call the module constructors. @@ -73,7 +73,7 @@ _exit: pha ; Save the return code on stack ldx #zpspace-1 L2: lda zpsave,x - sta sp,x + sta c_sp,x dex bpl L2 diff --git a/libsrc/plus4/crt0.s b/libsrc/plus4/crt0.s index d1eea9472..a8a5b8e63 100644 --- a/libsrc/plus4/crt0.s +++ b/libsrc/plus4/crt0.s @@ -33,7 +33,7 @@ Start: sei ; No interrupts since we're banking out the ROM sta ENABLE_RAM ldx #zpspace-1 -L1: lda sp,x +L1: lda c_sp,x sta zpsave,x dex bpl L1 @@ -53,8 +53,8 @@ L1: lda sp,x lda #<__HIMEM__ ldx #>__HIMEM__ - sta sp - stx sp+1 + sta c_sp + stx c_sp+1 ; Set up the IRQ vector in the banked RAM; and, switch off the ROM. @@ -114,7 +114,7 @@ _exit: pha ; Save the return code ldx #zpspace-1 L2: lda zpsave,x - sta sp,x + sta c_sp,x dex bpl L2 diff --git a/libsrc/rp6502/crt0.s b/libsrc/rp6502/crt0.s index 165ecf0a2..32d565fda 100644 --- a/libsrc/rp6502/crt0.s +++ b/libsrc/rp6502/crt0.s @@ -24,9 +24,9 @@ _init: ; Set cc65 argument stack pointer lda #<(__RAM_START__ + __RAM_SIZE__) - sta sp + sta c_sp lda #>(__RAM_START__ + __RAM_SIZE__) - sta sp+1 + sta c_sp+1 ; Initialize memory storage jsr zerobss ; Clear BSS segment diff --git a/libsrc/rp6502/ria.s b/libsrc/rp6502/ria.s index a1b53efb1..78da4daba 100644 --- a/libsrc/rp6502/ria.s +++ b/libsrc/rp6502/ria.s @@ -11,7 +11,7 @@ .export _ria_call_int, _ria_call_long .export _ria_call_int_errno, _ria_call_long_errno -.importzp sp, sreg +.importzp c_sp, sreg .import ___mappederrno, incsp1 .code diff --git a/libsrc/rp6502/xreg.s b/libsrc/rp6502/xreg.s index 40d4a6705..a882ab10f 100644 --- a/libsrc/rp6502/xreg.s +++ b/libsrc/rp6502/xreg.s @@ -5,7 +5,7 @@ ; int __cdecl__ xreg(char device, char channel, unsigned char address, ...); .export _xreg -.importzp sp +.importzp c_sp .import addysp, _ria_call_int_errno .include "rp6502.inc" @@ -20,12 +20,12 @@ @copy: ; copy stack dey - lda (sp),y + lda (c_sp),y sta RIA_XSTACK tya bne @copy - ; recover variadic size and move sp + ; recover variadic size and move c_sp txa tay jsr addysp diff --git a/libsrc/runtime/add.s b/libsrc/runtime/add.s index a4658cc13..85ddd0f25 100644 --- a/libsrc/runtime/add.s +++ b/libsrc/runtime/add.s @@ -9,7 +9,7 @@ ; called a lot! .export tosadda0, tosaddax - .importzp sp, tmp1 + .importzp c_sp, tmp1 .macpack cpu @@ -20,34 +20,34 @@ tosaddax: .if (.cpu .bitand ::CPU_ISET_65SC02) - adc (sp) ; (7) + adc (c_sp) ; (7) tay ; (9) - inc sp ; (14) + inc c_sp ; (14) bne hiadd ; (17) - inc sp+1 ; (-1+5) + inc c_sp+1 ; (-1+5) hiadd: txa ; (19) - adc (sp) ; (24) + adc (c_sp) ; (24) tax ; (26) - inc sp ; (31) + inc c_sp ; (31) bne done ; (34) - inc sp+1 ; (-1+5) + inc c_sp+1 ; (-1+5) done: tya ; (36) .else ldy #0 ; (4) - adc (sp),y ; (9) lo byte + adc (c_sp),y ; (9) lo byte iny ; (11) sta tmp1 ; (14) save it txa ; (16) - adc (sp),y ; (21) hi byte + adc (c_sp),y ; (21) hi byte tax ; (23) clc ; (25) - lda sp ; (28) + lda c_sp ; (28) adc #2 ; (30) - sta sp ; (33) + sta c_sp ; (33) bcc L1 ; (36) - inc sp+1 ; (-1+5) + inc c_sp+1 ; (-1+5) L1: lda tmp1 ; (39) restore low byte .endif diff --git a/libsrc/runtime/addeqsp.s b/libsrc/runtime/addeqsp.s index 5112d2790..3c098ea5f 100644 --- a/libsrc/runtime/addeqsp.s +++ b/libsrc/runtime/addeqsp.s @@ -5,19 +5,19 @@ ; .export addeq0sp, addeqysp - .importzp sp + .importzp c_sp addeq0sp: ldy #0 addeqysp: clc - adc (sp),y - sta (sp),y + adc (c_sp),y + sta (c_sp),y pha iny txa - adc (sp),y - sta (sp),y + adc (c_sp),y + sta (c_sp),y tax pla rts diff --git a/libsrc/runtime/addysp.s b/libsrc/runtime/addysp.s index e0e7db1ce..d48e048bb 100644 --- a/libsrc/runtime/addysp.s +++ b/libsrc/runtime/addysp.s @@ -5,17 +5,17 @@ ; .export addysp1, addysp - .importzp sp + .importzp c_sp addysp1: iny addysp: pha ; Save A clc tya ; Get the value - adc sp ; Add low byte - sta sp ; Put it back + adc c_sp ; Add low byte + sta c_sp ; Put it back bcc @L1 ; If no carry, we're done - inc sp+1 ; Inc high byte + inc c_sp+1 ; Inc high byte @L1: pla ; Restore A rts diff --git a/libsrc/runtime/and.s b/libsrc/runtime/and.s index 8c180b580..8411660ab 100644 --- a/libsrc/runtime/and.s +++ b/libsrc/runtime/and.s @@ -6,7 +6,7 @@ .export tosanda0, tosandax .import addysp1 - .importzp sp, ptr4 + .importzp c_sp, ptr4 .macpack cpu @@ -14,16 +14,16 @@ tosanda0: ldx #$00 tosandax: .if (.cpu .bitand CPU_ISET_65SC02) - and (sp) ; 65SC02 version, saves 2 cycles and 1 byte + and (c_sp) ; 65SC02 version, saves 2 cycles and 1 byte ldy #1 .else ldy #0 - and (sp),y + and (c_sp),y iny .endif pha txa - and (sp),y + and (c_sp),y tax pla jmp addysp1 ; drop TOS, set condition codes diff --git a/libsrc/runtime/bpushbsp.s b/libsrc/runtime/bpushbsp.s index 1c6add4a9..c2cc18cf6 100644 --- a/libsrc/runtime/bpushbsp.s +++ b/libsrc/runtime/bpushbsp.s @@ -6,12 +6,12 @@ .export bpushbsp, bpushbysp .import pusha - .importzp sp + .importzp c_sp bpushbsp: ldy #0 bpushbysp: - lda (sp),y + lda (c_sp),y jmp pusha diff --git a/libsrc/runtime/decsp1.s b/libsrc/runtime/decsp1.s index 3c673664a..4fd5392bb 100644 --- a/libsrc/runtime/decsp1.s +++ b/libsrc/runtime/decsp1.s @@ -5,14 +5,14 @@ ; .export decsp1 - .importzp sp + .importzp c_sp .proc decsp1 - ldy sp + ldy c_sp bne @L1 - dec sp+1 -@L1: dec sp + dec c_sp+1 +@L1: dec c_sp rts .endproc diff --git a/libsrc/runtime/decsp2.s b/libsrc/runtime/decsp2.s index a3793e778..c6c533d83 100644 --- a/libsrc/runtime/decsp2.s +++ b/libsrc/runtime/decsp2.s @@ -5,18 +5,18 @@ ; .export decsp2 - .importzp sp + .importzp c_sp .proc decsp2 - lda sp + lda c_sp sec sbc #2 - sta sp + sta c_sp bcc @L1 rts -@L1: dec sp+1 +@L1: dec c_sp+1 rts .endproc diff --git a/libsrc/runtime/decsp3.s b/libsrc/runtime/decsp3.s index a3ad7777e..2a2b22a15 100644 --- a/libsrc/runtime/decsp3.s +++ b/libsrc/runtime/decsp3.s @@ -5,18 +5,18 @@ ; .export decsp3 - .importzp sp + .importzp c_sp .proc decsp3 - lda sp + lda c_sp sec sbc #3 - sta sp + sta c_sp bcc @L1 rts -@L1: dec sp+1 +@L1: dec c_sp+1 rts .endproc diff --git a/libsrc/runtime/decsp4.s b/libsrc/runtime/decsp4.s index 5c7e94943..c756473bd 100644 --- a/libsrc/runtime/decsp4.s +++ b/libsrc/runtime/decsp4.s @@ -5,18 +5,18 @@ ; .export decsp4 - .importzp sp + .importzp c_sp .proc decsp4 - lda sp + lda c_sp sec sbc #4 - sta sp + sta c_sp bcc @L1 rts -@L1: dec sp+1 +@L1: dec c_sp+1 rts .endproc diff --git a/libsrc/runtime/decsp5.s b/libsrc/runtime/decsp5.s index 7ff4605cf..71b2fb176 100644 --- a/libsrc/runtime/decsp5.s +++ b/libsrc/runtime/decsp5.s @@ -5,18 +5,18 @@ ; .export decsp5 - .importzp sp + .importzp c_sp .proc decsp5 - lda sp + lda c_sp sec sbc #5 - sta sp + sta c_sp bcc @L1 rts -@L1: dec sp+1 +@L1: dec c_sp+1 rts .endproc diff --git a/libsrc/runtime/decsp6.s b/libsrc/runtime/decsp6.s index 6e55e664d..1d0b93136 100644 --- a/libsrc/runtime/decsp6.s +++ b/libsrc/runtime/decsp6.s @@ -5,18 +5,18 @@ ; .export decsp6 - .importzp sp + .importzp c_sp .proc decsp6 - lda sp + lda c_sp sec sbc #6 - sta sp + sta c_sp bcc @L1 rts -@L1: dec sp+1 +@L1: dec c_sp+1 rts .endproc diff --git a/libsrc/runtime/decsp7.s b/libsrc/runtime/decsp7.s index ee82232f6..1646d9ec9 100644 --- a/libsrc/runtime/decsp7.s +++ b/libsrc/runtime/decsp7.s @@ -5,18 +5,18 @@ ; .export decsp7 - .importzp sp + .importzp c_sp .proc decsp7 - lda sp + lda c_sp sec sbc #7 - sta sp + sta c_sp bcc @L1 rts -@L1: dec sp+1 +@L1: dec c_sp+1 rts .endproc diff --git a/libsrc/runtime/decsp8.s b/libsrc/runtime/decsp8.s index 47d44593e..1726331c5 100644 --- a/libsrc/runtime/decsp8.s +++ b/libsrc/runtime/decsp8.s @@ -5,18 +5,18 @@ ; .export decsp8 - .importzp sp + .importzp c_sp .proc decsp8 - lda sp + lda c_sp sec sbc #8 - sta sp + sta c_sp bcc @L1 rts -@L1: dec sp+1 +@L1: dec c_sp+1 rts .endproc diff --git a/libsrc/runtime/enter.s b/libsrc/runtime/enter.s index c51b4f7bb..454c2a6f9 100644 --- a/libsrc/runtime/enter.s +++ b/libsrc/runtime/enter.s @@ -5,14 +5,14 @@ ; .export enter - .importzp sp + .importzp c_sp enter: tya ; get arg size - ldy sp + ldy c_sp bne L1 - dec sp+1 -L1: dec sp + dec c_sp+1 +L1: dec c_sp ldy #0 - sta (sp),y ; Store the arg count + sta (c_sp),y ; Store the arg count rts diff --git a/libsrc/runtime/eq.s b/libsrc/runtime/eq.s index c2a537a35..87cf1c085 100644 --- a/libsrc/runtime/eq.s +++ b/libsrc/runtime/eq.s @@ -6,7 +6,7 @@ .export toseq00, toseqa0, toseqax .import tosicmp, booleq - .importzp sp, tmp1 + .importzp c_sp, tmp1 toseq00: lda #$00 diff --git a/libsrc/runtime/icmp.s b/libsrc/runtime/icmp.s index 05c73bd01..eba8ce561 100644 --- a/libsrc/runtime/icmp.s +++ b/libsrc/runtime/icmp.s @@ -6,7 +6,7 @@ ; .export tosicmp, tosicmp0 - .importzp sp, sreg + .importzp c_sp, sreg tosicmp0: @@ -17,16 +17,16 @@ tosicmp: stx sreg+1 ; Save ax ldy #$00 - lda (sp),y ; Get low byte + lda (c_sp),y ; Get low byte tax - inc sp ; 5 + inc c_sp ; 5 bne @L1 ; 3 - inc sp+1 ; (5) + inc c_sp+1 ; (5) @L1: - lda (sp),y ; Get high byte - inc sp ; 5 + lda (c_sp),y ; Get high byte + inc c_sp ; 5 bne @L2 ; 3 - inc sp+1 ; (5) + inc c_sp+1 ; (5) ; Do the compare. diff --git a/libsrc/runtime/incsp1.s b/libsrc/runtime/incsp1.s index 2272e200f..dde6c47b2 100644 --- a/libsrc/runtime/incsp1.s +++ b/libsrc/runtime/incsp1.s @@ -5,13 +5,13 @@ ; .export incsp1 - .importzp sp + .importzp c_sp .proc incsp1 - inc sp + inc c_sp bne @L1 - inc sp+1 + inc c_sp+1 @L1: rts .endproc diff --git a/libsrc/runtime/incsp2.s b/libsrc/runtime/incsp2.s index 0ed0ffcdf..c3260c19d 100644 --- a/libsrc/runtime/incsp2.s +++ b/libsrc/runtime/incsp2.s @@ -5,7 +5,7 @@ ; this module also contains the popax function. .export popax, incsp2 - .importzp sp + .importzp c_sp .macpack cpu @@ -14,13 +14,13 @@ .proc popax ldy #1 - lda (sp),y ; get hi byte + lda (c_sp),y ; get hi byte tax ; into x .if (.cpu .bitand ::CPU_ISET_65SC02) - lda (sp) ; get lo byte + lda (c_sp) ; get lo byte .else dey - lda (sp),y ; get lo byte + lda (c_sp),y ; get lo byte .endif .endproc @@ -29,14 +29,14 @@ .proc incsp2 - inc sp ; 5 + inc c_sp ; 5 beq @L1 ; 2 - inc sp ; 5 + inc c_sp ; 5 beq @L2 ; 2 rts -@L1: inc sp ; 5 -@L2: inc sp+1 ; 5 +@L1: inc c_sp ; 5 +@L2: inc c_sp+1 ; 5 rts .endproc diff --git a/libsrc/runtime/ladd.s b/libsrc/runtime/ladd.s index 23b3436c0..6c187f32d 100644 --- a/libsrc/runtime/ladd.s +++ b/libsrc/runtime/ladd.s @@ -6,7 +6,7 @@ .export tosadd0ax, tosaddeax .import addysp1 - .importzp sp, sreg, tmp1 + .importzp c_sp, sreg, tmp1 .macpack cpu @@ -20,24 +20,24 @@ tosadd0ax: tosaddeax: clc .if (.cpu .bitand CPU_ISET_65SC02) - adc (sp) ; 65SC02 version - saves 2 cycles + adc (c_sp) ; 65SC02 version - saves 2 cycles ldy #1 .else ldy #0 - adc (sp),y ; lo byte + adc (c_sp),y ; lo byte iny .endif sta tmp1 ; use as temp storage txa - adc (sp),y ; byte 1 + adc (c_sp),y ; byte 1 tax iny lda sreg - adc (sp),y ; byte 2 + adc (c_sp),y ; byte 2 sta sreg iny lda sreg+1 - adc (sp),y ; byte 3 + adc (c_sp),y ; byte 3 sta sreg+1 lda tmp1 ; load byte 0 jmp addysp1 ; drop TOS diff --git a/libsrc/runtime/laddeqsp.s b/libsrc/runtime/laddeqsp.s index 46c3c1f29..13dbf8112 100644 --- a/libsrc/runtime/laddeqsp.s +++ b/libsrc/runtime/laddeqsp.s @@ -5,29 +5,29 @@ ; .export laddeq0sp, laddeqysp - .importzp sp, sreg + .importzp c_sp, sreg laddeq0sp: ldy #0 laddeqysp: clc - adc (sp),y - sta (sp),y + adc (c_sp),y + sta (c_sp),y pha iny txa - adc (sp),y - sta (sp),y + adc (c_sp),y + sta (c_sp),y tax iny lda sreg - adc (sp),y - sta (sp),y + adc (c_sp),y + sta (c_sp),y sta sreg iny lda sreg+1 - adc (sp),y - sta (sp),y + adc (c_sp),y + sta (c_sp),y sta sreg+1 pla rts diff --git a/libsrc/runtime/land.s b/libsrc/runtime/land.s index 8e21ebb60..400fede3b 100644 --- a/libsrc/runtime/land.s +++ b/libsrc/runtime/land.s @@ -7,7 +7,7 @@ .export tosand0ax, tosandeax .import addysp1 - .importzp sp, sreg, tmp1 + .importzp c_sp, sreg, tmp1 .macpack cpu @@ -23,24 +23,24 @@ tosand0ax: tosandeax: .if (.cpu .bitand ::CPU_ISET_65SC02) - and (sp) ; byte 0 + and (c_sp) ; byte 0 ldy #1 .else ldy #0 - and (sp),y ; byte 0 + and (c_sp),y ; byte 0 iny .endif sta tmp1 txa - and (sp),y ; byte 1 + and (c_sp),y ; byte 1 tax iny lda sreg - and (sp),y ; byte 2 + and (c_sp),y ; byte 2 sta sreg iny lda sreg+1 - and (sp),y ; byte 3 + and (c_sp),y ; byte 3 sta sreg+1 lda tmp1 diff --git a/libsrc/runtime/lcmp.s b/libsrc/runtime/lcmp.s index d0ba4d81f..59c02dd56 100644 --- a/libsrc/runtime/lcmp.s +++ b/libsrc/runtime/lcmp.s @@ -7,7 +7,7 @@ .export toslcmp .import incsp4 - .importzp sp, sreg, ptr1 + .importzp c_sp, sreg, ptr1 toslcmp: @@ -15,23 +15,23 @@ toslcmp: stx ptr1+1 ; EAX now in sreg:ptr1 ldy #$03 - lda (sp),y + lda (c_sp),y sec sbc sreg+1 bne L4 dey - lda (sp),y + lda (c_sp),y cmp sreg bne L1 dey - lda (sp),y + lda (c_sp),y cmp ptr1+1 bne L1 dey - lda (sp),y + lda (c_sp),y cmp ptr1 L1: php ; Save flags diff --git a/libsrc/runtime/ldau0sp.s b/libsrc/runtime/ldau0sp.s index a986d52da..a808f6f84 100644 --- a/libsrc/runtime/ldau0sp.s +++ b/libsrc/runtime/ldau0sp.s @@ -5,17 +5,17 @@ ; .export ldau00sp, ldau0ysp - .importzp sp, ptr1 + .importzp c_sp, ptr1 .macpack cpu ldau00sp: ldy #1 ldau0ysp: - lda (sp),y + lda (c_sp),y sta ptr1+1 dey - lda (sp),y + lda (c_sp),y sta ptr1 ldx #0 .if (.cpu .bitand CPU_ISET_65SC02) diff --git a/libsrc/runtime/ldauisp.s b/libsrc/runtime/ldauisp.s index 54f4d1bd1..957f245be 100644 --- a/libsrc/runtime/ldauisp.s +++ b/libsrc/runtime/ldauisp.s @@ -5,15 +5,15 @@ ; .export ldaui0sp, ldauiysp - .importzp sp, ptr1 + .importzp c_sp, ptr1 ldaui0sp: ldy #1 ldauiysp: - lda (sp),y + lda (c_sp),y sta ptr1+1 dey - lda (sp),y + lda (c_sp),y sta ptr1 txa tay diff --git a/libsrc/runtime/ldaxsp.s b/libsrc/runtime/ldaxsp.s index aa94b43cd..b744ce242 100644 --- a/libsrc/runtime/ldaxsp.s +++ b/libsrc/runtime/ldaxsp.s @@ -5,16 +5,16 @@ ; .export ldax0sp, ldaxysp - .importzp sp + .importzp c_sp ; Beware: The optimizer knows about the value in Y after return! ldax0sp: ldy #1 ldaxysp: - lda (sp),y ; get high byte + lda (c_sp),y ; get high byte tax ; and save it dey ; point to lo byte - lda (sp),y ; load low byte + lda (c_sp),y ; load low byte rts diff --git a/libsrc/runtime/ldeaxysp.s b/libsrc/runtime/ldeaxysp.s index 1d65e9c38..b6ce7254f 100644 --- a/libsrc/runtime/ldeaxysp.s +++ b/libsrc/runtime/ldeaxysp.s @@ -9,20 +9,20 @@ .export ldeax0sp, ldeaxysp - .importzp sreg, sp + .importzp sreg, c_sp ldeax0sp: ldy #3 ldeaxysp: - lda (sp),y + lda (c_sp),y sta sreg+1 dey - lda (sp),y + lda (c_sp),y sta sreg dey - lda (sp),y + lda (c_sp),y tax dey - lda (sp),y + lda (c_sp),y rts diff --git a/libsrc/runtime/leaaxsp.s b/libsrc/runtime/leaaxsp.s index 0741170ca..451d7191f 100644 --- a/libsrc/runtime/leaaxsp.s +++ b/libsrc/runtime/leaaxsp.s @@ -5,16 +5,16 @@ ; .export leaaxsp, leaa0sp - .importzp sp + .importzp c_sp leaa0sp: ldx #$00 leaaxsp: clc - adc sp + adc c_sp pha txa - adc sp+1 + adc c_sp+1 tax pla rts diff --git a/libsrc/runtime/leave.s b/libsrc/runtime/leave.s index 95dcdec9d..408fdd159 100644 --- a/libsrc/runtime/leave.s +++ b/libsrc/runtime/leave.s @@ -12,7 +12,7 @@ .export leave00, leave0, leavey00, leavey0, leavey .export leave .import addysp - .importzp sp + .importzp c_sp .macpack cpu @@ -31,24 +31,24 @@ leavey: .if (.cpu .bitand ::CPU_ISET_65SC02) leave: tay ; save A a sec - lda (sp) ; that's the pushed arg size + lda (c_sp) ; that's the pushed arg size sec ; Count the byte, the count's stored in - adc sp - sta sp + adc c_sp + sta c_sp bcc L1 - inc sp+1 + inc c_sp+1 L1: tya ; Get return value back .else leave: pha ; save A a sec ldy #0 - lda (sp),y ; that's the pushed arg size + lda (c_sp),y ; that's the pushed arg size sec ; Count the byte, the count's stored in - adc sp - sta sp + adc c_sp + sta c_sp bcc L1 - inc sp+1 + inc c_sp+1 L1: pla ; Get return value back .endif diff --git a/libsrc/runtime/lmul.s b/libsrc/runtime/lmul.s index 90d5f1e97..a68c3e5c1 100644 --- a/libsrc/runtime/lmul.s +++ b/libsrc/runtime/lmul.s @@ -7,7 +7,7 @@ .export tosumul0ax, tosumuleax, tosmul0ax, tosmuleax .import addysp1 - .importzp sp, sreg, tmp1, tmp2, tmp3, tmp4, ptr1, ptr3, ptr4 + .importzp c_sp, sreg, tmp1, tmp2, tmp3, tmp4, ptr1, ptr3, ptr4 .macpack cpu @@ -27,21 +27,21 @@ tosumuleax: mul32: sta ptr1 stx ptr1+1 ; op2 now in ptr1/sreg .if (.cpu .bitand ::CPU_ISET_65SC02) - lda (sp) + lda (c_sp) ldy #1 .else ldy #0 - lda (sp),y + lda (c_sp),y iny .endif sta ptr3 - lda (sp),y + lda (c_sp),y sta ptr3+1 iny - lda (sp),y + lda (c_sp),y sta ptr4 iny - lda (sp),y + lda (c_sp),y sta ptr4+1 ; op1 in pre3/ptr4 jsr addysp1 ; Drop TOS diff --git a/libsrc/runtime/lor.s b/libsrc/runtime/lor.s index f2204b981..888a0c611 100644 --- a/libsrc/runtime/lor.s +++ b/libsrc/runtime/lor.s @@ -7,7 +7,7 @@ .export tosor0ax, tosoreax .import addysp1 - .importzp sp, sreg, tmp1 + .importzp c_sp, sreg, tmp1 .macpack cpu @@ -23,24 +23,24 @@ tosor0ax: tosoreax: .if (.cpu .bitand ::CPU_ISET_65SC02) - ora (sp) + ora (c_sp) ldy #1 .else ldy #0 - ora (sp),y ; byte 0 + ora (c_sp),y ; byte 0 iny .endif sta tmp1 txa - ora (sp),y ; byte 1 + ora (c_sp),y ; byte 1 tax iny lda sreg - ora (sp),y ; byte 2 + ora (c_sp),y ; byte 2 sta sreg iny lda sreg+1 - ora (sp),y ; byte 3 + ora (c_sp),y ; byte 3 sta sreg+1 lda tmp1 diff --git a/libsrc/runtime/lpop.s b/libsrc/runtime/lpop.s index a90ea5fcb..9690aff24 100644 --- a/libsrc/runtime/lpop.s +++ b/libsrc/runtime/lpop.s @@ -7,24 +7,24 @@ .export popeax .import incsp4 - .importzp sp, sreg + .importzp c_sp, sreg .macpack cpu popeax: ldy #3 - lda (sp),y + lda (c_sp),y sta sreg+1 dey - lda (sp),y + lda (c_sp),y sta sreg dey - lda (sp),y + lda (c_sp),y tax .if (.cpu .bitand ::CPU_ISET_65SC02) - lda (sp) + lda (c_sp) .else dey - lda (sp),y + lda (c_sp),y .endif jmp incsp4 diff --git a/libsrc/runtime/lpush.s b/libsrc/runtime/lpush.s index 0bc67b523..ec2c865af 100644 --- a/libsrc/runtime/lpush.s +++ b/libsrc/runtime/lpush.s @@ -10,7 +10,7 @@ ; .export pushl0, push0ax, pusheax .import decsp4 - .importzp sp, sreg + .importzp c_sp, sreg .macpack cpu @@ -31,19 +31,19 @@ pusheax: jsr decsp4 ldy #3 lda sreg+1 - sta (sp),y + sta (c_sp),y dey lda sreg - sta (sp),y + sta (c_sp),y dey txa - sta (sp),y + sta (c_sp),y pla .if (.cpu .bitand ::CPU_ISET_65SC02) - sta (sp) + sta (c_sp) .else dey - sta (sp),y + sta (c_sp),y .endif rts diff --git a/libsrc/runtime/lrsub.s b/libsrc/runtime/lrsub.s index 5e8d0b543..456d8d8d5 100644 --- a/libsrc/runtime/lrsub.s +++ b/libsrc/runtime/lrsub.s @@ -10,7 +10,7 @@ ; .export tosrsub0ax, tosrsubeax .import addysp1 - .importzp sp, sreg, tmp1 + .importzp c_sp, sreg, tmp1 .macpack cpu @@ -27,24 +27,24 @@ tosrsub0ax: tosrsubeax: sec .if (.cpu .bitand ::CPU_ISET_65SC02) - sbc (sp) + sbc (c_sp) ldy #1 .else ldy #0 - sbc (sp),y ; byte 0 + sbc (c_sp),y ; byte 0 iny .endif sta tmp1 ; use as temp storage txa - sbc (sp),y ; byte 1 + sbc (c_sp),y ; byte 1 tax iny lda sreg - sbc (sp),y ; byte 2 + sbc (c_sp),y ; byte 2 sta sreg iny lda sreg+1 - sbc (sp),y ; byte 3 + sbc (c_sp),y ; byte 3 sta sreg+1 lda tmp1 jmp addysp1 ; drop TOS diff --git a/libsrc/runtime/lsub.s b/libsrc/runtime/lsub.s index 4c50ded14..17b225404 100644 --- a/libsrc/runtime/lsub.s +++ b/libsrc/runtime/lsub.s @@ -9,7 +9,7 @@ ; .export tossub0ax, tossubeax .import addysp1 - .importzp sp, sreg + .importzp c_sp, sreg .macpack cpu @@ -27,24 +27,24 @@ tossubeax: sec eor #$FF .if (.cpu .bitand ::CPU_ISET_65SC02) - adc (sp) ; 65SC02 version - saves 2 cycles + adc (c_sp) ; 65SC02 version - saves 2 cycles ldy #1 .else ldy #0 - adc (sp),y ; lo byte + adc (c_sp),y ; lo byte iny .endif pha ; Save low byte txa eor #$FF - adc (sp),y ; byte 1 + adc (c_sp),y ; byte 1 tax iny - lda (sp),y + lda (c_sp),y sbc sreg ; byte 2 sta sreg iny - lda (sp),y + lda (c_sp),y sbc sreg+1 ; byte 3 sta sreg+1 pla ; Restore byte 0 diff --git a/libsrc/runtime/lsubeqsp.s b/libsrc/runtime/lsubeqsp.s index f32930c69..6f8377484 100644 --- a/libsrc/runtime/lsubeqsp.s +++ b/libsrc/runtime/lsubeqsp.s @@ -5,31 +5,31 @@ ; .export lsubeq0sp, lsubeqysp - .importzp sp, sreg + .importzp c_sp, sreg lsubeq0sp: ldy #0 lsubeqysp: sec eor #$FF - adc (sp),y - sta (sp),y + adc (c_sp),y + sta (c_sp),y pha ; Save low byte iny txa eor #$FF - adc (sp),y - sta (sp),y + adc (c_sp),y + sta (c_sp),y tax iny - lda (sp),y + lda (c_sp),y sbc sreg - sta (sp),y + sta (c_sp),y sta sreg iny - lda (sp),y + lda (c_sp),y sbc sreg+1 - sta (sp),y + sta (c_sp),y sta sreg+1 pla rts diff --git a/libsrc/runtime/ludiv.s b/libsrc/runtime/ludiv.s index 77335d8f5..b47207222 100644 --- a/libsrc/runtime/ludiv.s +++ b/libsrc/runtime/ludiv.s @@ -7,7 +7,7 @@ .export tosudiv0ax, tosudiveax, getlop, udiv32 .import addysp1 - .importzp sp, sreg, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4 + .importzp c_sp, sreg, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4 .macpack cpu @@ -39,21 +39,21 @@ getlop: sta ptr3 ; Put right operand in place sta ptr4+1 .if (.cpu .bitand ::CPU_ISET_65SC02) - lda (sp) + lda (c_sp) ldy #1 .else ldy #0 ; Put left operand in place - lda (sp),y + lda (c_sp),y iny .endif sta ptr1 - lda (sp),y + lda (c_sp),y sta ptr1+1 iny - lda (sp),y + lda (c_sp),y sta sreg iny - lda (sp),y + lda (c_sp),y sta sreg+1 jmp addysp1 ; Drop parameters diff --git a/libsrc/runtime/lxor.s b/libsrc/runtime/lxor.s index a92a59959..6d9f7db3a 100644 --- a/libsrc/runtime/lxor.s +++ b/libsrc/runtime/lxor.s @@ -7,7 +7,7 @@ .export tosxor0ax, tosxoreax .import addysp1 - .importzp sp, sreg, tmp1 + .importzp c_sp, sreg, tmp1 .macpack cpu @@ -23,24 +23,24 @@ tosxor0ax: tosxoreax: .if (.cpu .bitand ::CPU_ISET_65SC02) - eor (sp) ; byte 0 + eor (c_sp) ; byte 0 ldy #1 .else ldy #0 - eor (sp),y ; byte 0 + eor (c_sp),y ; byte 0 iny .endif sta tmp1 txa - eor (sp),y ; byte 1 + eor (c_sp),y ; byte 1 tax iny lda sreg - eor (sp),y ; byte 2 + eor (c_sp),y ; byte 2 sta sreg iny lda sreg+1 - eor (sp),y ; byte 3 + eor (c_sp),y ; byte 3 sta sreg+1 lda tmp1 diff --git a/libsrc/runtime/or.s b/libsrc/runtime/or.s index 735f30f61..04389be5f 100644 --- a/libsrc/runtime/or.s +++ b/libsrc/runtime/or.s @@ -7,7 +7,7 @@ .export tosora0, tosorax .import addysp1 - .importzp sp, tmp1 + .importzp c_sp, tmp1 .macpack cpu @@ -15,16 +15,16 @@ tosora0: ldx #$00 tosorax: .if (.cpu .bitand ::CPU_ISET_65SC02) - ora (sp) + ora (c_sp) ldy #1 .else ldy #0 - ora (sp),y + ora (c_sp),y iny .endif sta tmp1 txa - ora (sp),y + ora (c_sp),y tax lda tmp1 jmp addysp1 ; drop TOS, set condition codes diff --git a/libsrc/runtime/popa.s b/libsrc/runtime/popa.s index bb74df0ca..c1700071d 100644 --- a/libsrc/runtime/popa.s +++ b/libsrc/runtime/popa.s @@ -5,23 +5,23 @@ ; .export popa - .importzp sp + .importzp c_sp .macpack cpu .proc popa .if (.cpu .bitand ::CPU_ISET_65SC02) - lda (sp) + lda (c_sp) .else ldy #0 ; (2) - lda (sp),y ; (7) Read byte + lda (c_sp),y ; (7) Read byte .endif - inc sp ; (12) + inc c_sp ; (12) beq @L1 ; (14) rts ; (20) -@L1: inc sp+1 +@L1: inc c_sp+1 rts .endproc diff --git a/libsrc/runtime/popptr1.s b/libsrc/runtime/popptr1.s index b54bb9eb3..45043dd27 100644 --- a/libsrc/runtime/popptr1.s +++ b/libsrc/runtime/popptr1.s @@ -6,19 +6,19 @@ .export popptr1 .import incsp2 - .importzp sp, ptr1 + .importzp c_sp, ptr1 .macpack cpu .proc popptr1 ; 14 bytes (four usages = at least 2 bytes saved) ldy #1 - lda (sp),y ; get hi byte + lda (c_sp),y ; get hi byte sta ptr1+1 ; into ptr hi dey ; dey even for for 65C02 here to have Y=0 at exit! .if (.cpu .bitand ::CPU_ISET_65SC02) - lda (sp) ; get lo byte + lda (c_sp) ; get lo byte .else - lda (sp),y ; get lo byte + lda (c_sp),y ; get lo byte .endif sta ptr1 ; to ptr lo jmp incsp2 diff --git a/libsrc/runtime/popsreg.s b/libsrc/runtime/popsreg.s index 47d67503a..c7f667246 100644 --- a/libsrc/runtime/popsreg.s +++ b/libsrc/runtime/popsreg.s @@ -6,20 +6,20 @@ .export popsreg .import incsp2 - .importzp sp, sreg + .importzp c_sp, sreg .macpack cpu popsreg: pha ; save A ldy #1 - lda (sp),y ; get hi byte + lda (c_sp),y ; get hi byte sta sreg+1 ; store it .if (.cpu .bitand ::CPU_ISET_65SC02) - lda (sp) ; get lo byte + lda (c_sp) ; get lo byte .else dey - lda (sp),y ; get lo byte + lda (c_sp),y ; get lo byte .endif sta sreg ; store it pla ; get A back diff --git a/libsrc/runtime/pusha.s b/libsrc/runtime/pusha.s index 04233282e..399423077 100644 --- a/libsrc/runtime/pusha.s +++ b/libsrc/runtime/pusha.s @@ -5,7 +5,7 @@ ; .export pusha0sp, pushaysp, pusha - .importzp sp + .importzp c_sp .macpack cpu @@ -14,16 +14,16 @@ pusha0sp: ldy #$00 pushaysp: - lda (sp),y -pusha: ldy sp ; (3) + lda (c_sp),y +pusha: ldy c_sp ; (3) beq @L1 ; (6) - dec sp ; (11) + dec c_sp ; (11) ldy #0 ; (13) - sta (sp),y ; (19) + sta (c_sp),y ; (19) rts ; (25) -@L1: dec sp+1 ; (11) - dec sp ; (16) - sta (sp),y ; (22) +@L1: dec c_sp+1 ; (11) + dec c_sp ; (16) + sta (c_sp),y ; (22) rts ; (28) diff --git a/libsrc/runtime/pushax.s b/libsrc/runtime/pushax.s index 27ddf641d..f77a9bcc3 100644 --- a/libsrc/runtime/pushax.s +++ b/libsrc/runtime/pushax.s @@ -5,7 +5,7 @@ ; .export push0, pusha0, pushax - .importzp sp + .importzp c_sp .macpack cpu @@ -20,21 +20,21 @@ pusha0: ldx #0 .proc pushax pha ; (3) - lda sp ; (6) + lda c_sp ; (6) sec ; (8) sbc #2 ; (10) - sta sp ; (13) + sta c_sp ; (13) bcs @L1 ; (17) - dec sp+1 ; (+5) + dec c_sp+1 ; (+5) @L1: ldy #1 ; (19) txa ; (21) - sta (sp),y ; (27) + sta (c_sp),y ; (27) pla ; (31) dey ; (33) .if (.cpu .bitand ::CPU_ISET_65SC02) - sta (sp) ; (37) + sta (c_sp) ; (37) .else - sta (sp),y ; (38) + sta (c_sp),y ; (38) .endif rts ; (44/43) diff --git a/libsrc/runtime/pushbsp.s b/libsrc/runtime/pushbsp.s index 0b5cbe854..45ad93b12 100644 --- a/libsrc/runtime/pushbsp.s +++ b/libsrc/runtime/pushbsp.s @@ -6,12 +6,12 @@ .export pushbsp, pushbysp .import pusha0 - .importzp sp + .importzp c_sp pushbsp: ldy #0 pushbysp: - lda (sp),y ; get lo byte + lda (c_sp),y ; get lo byte jmp pusha0 ; promote to unsigned and push diff --git a/libsrc/runtime/pushlysp.s b/libsrc/runtime/pushlysp.s index ca1834265..86bb87dbd 100644 --- a/libsrc/runtime/pushlysp.s +++ b/libsrc/runtime/pushlysp.s @@ -7,23 +7,23 @@ .export pushlysp .import pusheax - .importzp sreg, sp + .importzp sreg, c_sp .proc pushlysp iny iny - lda (sp),y + lda (c_sp),y iny sta sreg - lda (sp),y + lda (c_sp),y sta sreg+1 dey dey - lda (sp),y + lda (c_sp),y dey tax - lda (sp),y + lda (c_sp),y jmp pusheax .endproc diff --git a/libsrc/runtime/pushwsp.s b/libsrc/runtime/pushwsp.s index f5ebe0d7e..31c08d624 100644 --- a/libsrc/runtime/pushwsp.s +++ b/libsrc/runtime/pushwsp.s @@ -5,27 +5,27 @@ ; .export pushwysp, pushw0sp - .importzp sp + .importzp c_sp .macpack generic pushw0sp: ldy #3 pushwysp: - lda sp ; 3 + lda c_sp ; 3 sub #2 ; 4 - sta sp ; 3 + sta c_sp ; 3 bcs @L1 ; 3(+1) - dec sp+1 ; (5) -@L1: lda (sp),y ; 5 =16 + dec c_sp+1 ; (5) +@L1: lda (c_sp),y ; 5 =16 tax ; 2 dey ; 2 - lda (sp),y ; 5 + lda (c_sp),y ; 5 ldy #$00 ; 2 - sta (sp),y ; 5 + sta (c_sp),y ; 5 iny ; 2 txa ; 2 - sta (sp),y ; 5 + sta (c_sp),y ; 5 rts diff --git a/libsrc/runtime/regswap.s b/libsrc/runtime/regswap.s index 689d8d12a..17db9ee27 100644 --- a/libsrc/runtime/regswap.s +++ b/libsrc/runtime/regswap.s @@ -5,17 +5,17 @@ ; .export regswap - .importzp sp, regbank, tmp1 + .importzp c_sp, regbank, tmp1 .proc regswap sta tmp1 ; Store count @L1: lda regbank,x ; Get old value pha ; Save it - lda (sp),y ; Get stack loc + lda (c_sp),y ; Get stack loc sta regbank,x ; Store new value pla - sta (sp),y ; Store old value + sta (c_sp),y ; Store old value inx iny dec tmp1 diff --git a/libsrc/runtime/regswap1.s b/libsrc/runtime/regswap1.s index 753020acb..22cf170dc 100644 --- a/libsrc/runtime/regswap1.s +++ b/libsrc/runtime/regswap1.s @@ -5,16 +5,16 @@ ; .export regswap1 - .importzp sp, regbank + .importzp c_sp, regbank .proc regswap1 lda regbank,x ; Get old value pha ; Save it - lda (sp),y ; Get stack loc + lda (c_sp),y ; Get stack loc sta regbank,x ; Store new value pla - sta (sp),y ; Store old value + sta (c_sp),y ; Store old value rts .endproc diff --git a/libsrc/runtime/regswap2.s b/libsrc/runtime/regswap2.s index df5109dc6..07bc7c196 100644 --- a/libsrc/runtime/regswap2.s +++ b/libsrc/runtime/regswap2.s @@ -5,7 +5,7 @@ ; .export regswap2 - .importzp sp, regbank + .importzp c_sp, regbank .proc regswap2 @@ -13,20 +13,20 @@ lda regbank,x ; Get old value pha ; Save it - lda (sp),y ; Get stack loc + lda (c_sp),y ; Get stack loc sta regbank,x ; Store new value pla - sta (sp),y ; Store old value + sta (c_sp),y ; Store old value ; Second byte iny lda regbank+1,x ; Get old value pha ; Save it - lda (sp),y ; Get stack loc + lda (c_sp),y ; Get stack loc sta regbank+1,x ; Store new value pla - sta (sp),y ; Store old value + sta (c_sp),y ; Store old value rts diff --git a/libsrc/runtime/rsub.s b/libsrc/runtime/rsub.s index 69ee6da22..bacb3c7fc 100644 --- a/libsrc/runtime/rsub.s +++ b/libsrc/runtime/rsub.s @@ -7,7 +7,7 @@ .export tosrsuba0, tosrsubax .import addysp1 - .importzp sp, tmp1 + .importzp c_sp, tmp1 .macpack cpu @@ -20,16 +20,16 @@ tosrsuba0: tosrsubax: sec .if (.cpu .bitand CPU_ISET_65SC02) - sbc (sp) + sbc (c_sp) ldy #1 .else ldy #0 - sbc (sp),y ; lo byte + sbc (c_sp),y ; lo byte iny .endif sta tmp1 ; save lo byte txa - sbc (sp),y ; hi byte + sbc (c_sp),y ; hi byte tax lda tmp1 jmp addysp1 ; drop TOS, set condition codes diff --git a/libsrc/runtime/staspidx.s b/libsrc/runtime/staspidx.s index c8d42f34c..bd9b0c79d 100644 --- a/libsrc/runtime/staspidx.s +++ b/libsrc/runtime/staspidx.s @@ -6,17 +6,17 @@ .export staspidx .import incsp2 - .importzp sp, tmp1, ptr1 + .importzp c_sp, tmp1, ptr1 .proc staspidx pha sty tmp1 ; Save Index ldy #1 - lda (sp),y + lda (c_sp),y sta ptr1+1 dey - lda (sp),y + lda (c_sp),y sta ptr1 ; Pointer now in ptr1 ldy tmp1 ; Restore offset pla ; Restore value diff --git a/libsrc/runtime/staxsp.s b/libsrc/runtime/staxsp.s index 599e92a32..15bec22ee 100644 --- a/libsrc/runtime/staxsp.s +++ b/libsrc/runtime/staxsp.s @@ -1,20 +1,20 @@ ; ; Ullrich von Bassewitz, 31.08.1998 ; -; CC65 runtime: Store ax at (sp),y +; CC65 runtime: Store ax at (c_sp),y ; .export staxysp, stax0sp - .importzp sp + .importzp c_sp stax0sp: ldy #0 staxysp: - sta (sp),y + sta (c_sp),y iny pha txa - sta (sp),y + sta (c_sp),y pla rts diff --git a/libsrc/runtime/staxspi.s b/libsrc/runtime/staxspi.s index 3114f449c..aefed428f 100644 --- a/libsrc/runtime/staxspi.s +++ b/libsrc/runtime/staxspi.s @@ -7,7 +7,7 @@ .export staxspidx .import incsp2 - .importzp sp, tmp1, ptr1 + .importzp c_sp, tmp1, ptr1 .macpack cpu @@ -16,13 +16,13 @@ sty tmp1 ; Save Y pha ; Save A ldy #1 - lda (sp),y + lda (c_sp),y sta ptr1+1 .if (.cpu .bitand ::CPU_ISET_65SC02) - lda (sp) + lda (c_sp) .else dey - lda (sp),y + lda (c_sp),y .endif sta ptr1 ; Address now in ptr1 ldy tmp1 ; Restore Y diff --git a/libsrc/runtime/steaxsp.s b/libsrc/runtime/steaxsp.s index 6ac3891c9..33dbc04d7 100644 --- a/libsrc/runtime/steaxsp.s +++ b/libsrc/runtime/steaxsp.s @@ -1,26 +1,26 @@ ; ; Ullrich von Bassewitz, 31.08.1998 ; -; CC65 runtime: Store eax at (sp),y +; CC65 runtime: Store eax at (c_sp),y ; .export steaxysp, steax0sp - .importzp sp, sreg + .importzp c_sp, sreg steax0sp: ldy #0 steaxysp: - sta (sp),y + sta (c_sp),y iny pha txa - sta (sp),y + sta (c_sp),y iny lda sreg - sta (sp),y + sta (c_sp),y iny lda sreg+1 - sta (sp),y + sta (c_sp),y pla rts diff --git a/libsrc/runtime/stkchk.s b/libsrc/runtime/stkchk.s index ceab4c703..a7ca39f21 100644 --- a/libsrc/runtime/stkchk.s +++ b/libsrc/runtime/stkchk.s @@ -17,7 +17,7 @@ .constructor initstkchk, 25 .import __STACKSIZE__ ; Linker defined .import pusha0, _exit - .importzp sp + .importzp c_sp ; Use macros for better readability .macpack generic @@ -32,11 +32,11 @@ .proc initstkchk - lda sp + lda c_sp sta initialsp sub #<__STACKSIZE__ sta lowwater - lda sp+1 + lda c_sp+1 sta initialsp+1 sbc #>__STACKSIZE__ .if (.cpu .bitand ::CPU_ISET_65SC02) @@ -70,7 +70,7 @@ cstkchk: ; Check the high byte of the software stack @L0: lda lowwater+1 - cmp sp+1 + cmp c_sp+1 bcs @L1 rts @@ -78,7 +78,7 @@ cstkchk: @L1: bne CStackOverflow lda lowwater - cmp sp + cmp c_sp bcs CStackOverflow Done: rts @@ -87,9 +87,9 @@ Done: rts CStackOverflow: lda initialsp - sta sp + sta c_sp lda initialsp+1 - sta sp+1 + sta c_sp+1 ; Generic abort entry. We should output a diagnostic here, but this is ; difficult, since we're operating at a lower level here. diff --git a/libsrc/runtime/sub.s b/libsrc/runtime/sub.s index b41df3d91..58ffb4c91 100644 --- a/libsrc/runtime/sub.s +++ b/libsrc/runtime/sub.s @@ -6,7 +6,7 @@ .export tossuba0, tossubax .import addysp1 - .importzp sp + .importzp c_sp .macpack cpu @@ -18,17 +18,17 @@ tossubax: sec eor #$FF .if (.cpu .bitand CPU_ISET_65SC02) - adc (sp) + adc (c_sp) ldy #1 .else ldy #0 - adc (sp),y ; Subtract low byte + adc (c_sp),y ; Subtract low byte iny .endif pha ; Save high byte txa eor #$FF - adc (sp),y ; Subtract high byte + adc (c_sp),y ; Subtract high byte tax ; High byte into X pla ; Restore low byte jmp addysp1 ; drop TOS diff --git a/libsrc/runtime/subeqsp.s b/libsrc/runtime/subeqsp.s index 24080d97d..880e5f2fc 100644 --- a/libsrc/runtime/subeqsp.s +++ b/libsrc/runtime/subeqsp.s @@ -5,21 +5,21 @@ ; .export subeq0sp, subeqysp - .importzp sp + .importzp c_sp subeq0sp: ldy #0 subeqysp: sec eor #$FF - adc (sp),y - sta (sp),y + adc (c_sp),y + sta (c_sp),y pha ; Save low byte iny txa eor #$FF - adc (sp),y - sta (sp),y + adc (c_sp),y + sta (c_sp),y tax pla ; Restore low byte rts diff --git a/libsrc/runtime/subysp.s b/libsrc/runtime/subysp.s index 9fae44222..8f5bea806 100644 --- a/libsrc/runtime/subysp.s +++ b/libsrc/runtime/subysp.s @@ -6,17 +6,17 @@ ; .export subysp - .importzp sp + .importzp c_sp .proc subysp tya eor #$ff sec - adc sp - sta sp + adc c_sp + sta c_sp bcs @L1 - dec sp+1 + dec c_sp+1 @L1: rts .endproc diff --git a/libsrc/runtime/swap.s b/libsrc/runtime/swap.s index 5358e08d3..3796b0a97 100644 --- a/libsrc/runtime/swap.s +++ b/libsrc/runtime/swap.s @@ -6,7 +6,7 @@ ; .export swapstk - .importzp sp, ptr4 + .importzp c_sp, ptr4 .macpack cpu @@ -14,22 +14,22 @@ swapstk: sta ptr4 stx ptr4+1 ldy #1 ; index - lda (sp),y + lda (c_sp),y tax lda ptr4+1 - sta (sp),y + sta (c_sp),y .if (.cpu .bitand ::CPU_ISET_65SC02) - lda (sp) + lda (c_sp) tay lda ptr4 - sta (sp) + sta (c_sp) tya .else dey - lda (sp),y + lda (c_sp),y pha lda ptr4 - sta (sp),y + sta (c_sp),y pla .endif rts ; whew! diff --git a/libsrc/runtime/tosint.s b/libsrc/runtime/tosint.s index ed32298bd..2aaa19ccc 100644 --- a/libsrc/runtime/tosint.s +++ b/libsrc/runtime/tosint.s @@ -6,7 +6,7 @@ .export tosint .import incsp2 - .importzp sp + .importzp c_sp .macpack cpu @@ -16,17 +16,17 @@ pha .if (.cpu .bitand ::CPU_ISET_65SC02) - lda (sp) + lda (c_sp) .else ldy #0 - lda (sp),y ; sp+1 + lda (c_sp),y ; c_sp+1 .endif ldy #2 - sta (sp),y + sta (c_sp),y dey - lda (sp),y + lda (c_sp),y ldy #3 - sta (sp),y + sta (c_sp),y pla jmp incsp2 ; Drop 16 bit diff --git a/libsrc/runtime/toslong.s b/libsrc/runtime/toslong.s index 9065d3e6c..cf8eff031 100644 --- a/libsrc/runtime/toslong.s +++ b/libsrc/runtime/toslong.s @@ -6,7 +6,7 @@ .export tosulong, toslong .import decsp2 - .importzp sp + .importzp c_sp .macpack cpu @@ -16,25 +16,25 @@ tosulong: pha jsr decsp2 ; Make room ldy #2 - lda (sp),y + lda (c_sp),y .if (.cpu .bitand CPU_ISET_65SC02) - sta (sp) ; 65C02 version + sta (c_sp) ; 65C02 version iny ; Y = 3 .else ldy #0 - sta (sp),y + sta (c_sp),y ldy #3 .endif - lda (sp),y + lda (c_sp),y toslong1: ldy #1 - sta (sp),y + sta (c_sp),y lda #0 ; Zero extend toslong2: iny - sta (sp),y + sta (c_sp),y iny - sta (sp),y + sta (c_sp),y pla rts @@ -42,19 +42,19 @@ toslong: pha jsr decsp2 ; Make room ldy #2 - lda (sp),y + lda (c_sp),y .if (.cpu .bitand CPU_ISET_65SC02) - sta (sp) ; 65C02 version + sta (c_sp) ; 65C02 version iny ; Y = 3 .else ldy #0 - sta (sp),y + sta (c_sp),y ldy #3 .endif - lda (sp),y + lda (c_sp),y bpl toslong1 ; Jump if positive, high word is zero ldy #1 - sta (sp),y + sta (c_sp),y lda #$FF bne toslong2 ; Branch always diff --git a/libsrc/runtime/xor.s b/libsrc/runtime/xor.s index e03922926..15394413c 100644 --- a/libsrc/runtime/xor.s +++ b/libsrc/runtime/xor.s @@ -7,7 +7,7 @@ .export tosxora0, tosxorax .import addysp1 - .importzp sp, tmp1 + .importzp c_sp, tmp1 .macpack cpu @@ -15,16 +15,16 @@ tosxora0: ldx #$00 tosxorax: .if (.cpu .bitand CPU_ISET_65SC02) - eor (sp) + eor (c_sp) ldy #1 .else ldy #0 - eor (sp),y + eor (c_sp),y iny .endif sta tmp1 txa - eor (sp),y + eor (c_sp),y tax lda tmp1 jmp addysp1 ; drop TOS, set condition codes diff --git a/libsrc/runtime/zeropage.s b/libsrc/runtime/zeropage.s index 2bbe7ceee..75856f751 100644 --- a/libsrc/runtime/zeropage.s +++ b/libsrc/runtime/zeropage.s @@ -10,7 +10,7 @@ .zeropage -sp: .res 2 ; Stack pointer +c_sp: .res 2 ; Stack pointer sreg: .res 2 ; Secondary register/high 16 bit for longs regsave: .res 4 ; Slot to save/restore (E)AX into ptr1: .res 2 diff --git a/libsrc/sim6502/crt0.s b/libsrc/sim6502/crt0.s index c04a2b8a6..26be7888b 100644 --- a/libsrc/sim6502/crt0.s +++ b/libsrc/sim6502/crt0.s @@ -22,8 +22,8 @@ startup:cld txs lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) - sta sp - stx sp+1 + sta c_sp + stx c_sp+1 jsr zerobss jsr initlib jsr callmain diff --git a/libsrc/sim6502/exehdr.s b/libsrc/sim6502/exehdr.s index 6487e5b0c..224b2af2d 100644 --- a/libsrc/sim6502/exehdr.s +++ b/libsrc/sim6502/exehdr.s @@ -5,7 +5,7 @@ ; .export __EXEHDR__ : absolute = 1 ; Linker referenced - .importzp sp + .importzp c_sp .import __MAIN_START__ .import startup @@ -24,6 +24,6 @@ .else .error Unknown CPU type. .endif - .byte sp ; sp address + .byte c_sp ; c_sp address .addr __MAIN_START__ ; load address .addr startup ; reset address diff --git a/libsrc/supervision/crt0.s b/libsrc/supervision/crt0.s index fbae1fc46..1cfba1845 100644 --- a/libsrc/supervision/crt0.s +++ b/libsrc/supervision/crt0.s @@ -33,8 +33,8 @@ reset: lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) ldx #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) - sta sp - stx sp+1 ; Set argument stack ptr + sta c_sp + stx c_sp+1 ; Set argument stack ptr jsr initlib jsr _main _exit: jsr donelib diff --git a/libsrc/sym1/crt0.s b/libsrc/sym1/crt0.s index 5d4e0449b..d20b4cf6c 100644 --- a/libsrc/sym1/crt0.s +++ b/libsrc/sym1/crt0.s @@ -33,9 +33,9 @@ _init: jsr ACCESS ; Unlock System RAM ; Set cc65 argument stack pointer lda #<(__RAM_START__ + __RAM_SIZE__) - sta sp + sta c_sp lda #>(__RAM_START__ + __RAM_SIZE__) - sta sp+1 + sta c_sp+1 ; Initialize memory storage diff --git a/libsrc/telestrat/crt0.s b/libsrc/telestrat/crt0.s index df75520ce..aa32ed0d0 100644 --- a/libsrc/telestrat/crt0.s +++ b/libsrc/telestrat/crt0.s @@ -47,7 +47,7 @@ _exit: jsr donelib ldx #zpspace - 1 L2: lda zpsave,x - sta sp,x + sta c_sp,x dex bpl L2 @@ -64,7 +64,7 @@ L2: lda zpsave,x ; Save the zero-page area that we're about to use. init: ldx #zpspace - 1 -L1: lda sp,x +L1: lda c_sp,x sta zpsave,x dex bpl L1 @@ -74,8 +74,8 @@ L1: lda sp,x lda #<(__MAIN_START__ + __MAIN_SIZE__) ldx #>(__MAIN_START__ + __MAIN_SIZE__) - sta sp - stx sp+1 ; Set argument stack ptr + sta c_sp + stx c_sp+1 ; Set argument stack ptr ; Call the module constructors. diff --git a/libsrc/telestrat/open.s b/libsrc/telestrat/open.s index f59d3d31a..08c572e23 100644 --- a/libsrc/telestrat/open.s +++ b/libsrc/telestrat/open.s @@ -2,7 +2,7 @@ .import addysp,popax - .importzp sp,tmp2,tmp3,tmp1 + .importzp c_sp,tmp2,tmp3,tmp1 .include "telestrat.inc" diff --git a/libsrc/telestrat/wherex.s b/libsrc/telestrat/wherex.s index 8616003c8..256b967c3 100644 --- a/libsrc/telestrat/wherex.s +++ b/libsrc/telestrat/wherex.s @@ -3,7 +3,7 @@ ; .export _wherex - .importzp sp + .importzp c_sp .include "telestrat.inc" diff --git a/libsrc/tgi/tgi_outtextxy.s b/libsrc/tgi/tgi_outtextxy.s index 3934df871..24183396f 100644 --- a/libsrc/tgi/tgi_outtextxy.s +++ b/libsrc/tgi/tgi_outtextxy.s @@ -8,7 +8,7 @@ .include "tgi-kernel.inc" .import addysp1 - .importzp sp + .importzp c_sp .proc _tgi_outtextxy @@ -17,16 +17,16 @@ pha ; ldy #0 - lda (sp),y + lda (c_sp),y sta _tgi_cury iny - lda (sp),y + lda (c_sp),y sta _tgi_cury+1 iny - lda (sp),y + lda (c_sp),y sta _tgi_curx iny - lda (sp),y + lda (c_sp),y sta _tgi_curx+1 pla jsr addysp1 ; Drop arguments from stack diff --git a/libsrc/vic20/crt0.s b/libsrc/vic20/crt0.s index c5486063b..189114f5d 100644 --- a/libsrc/vic20/crt0.s +++ b/libsrc/vic20/crt0.s @@ -24,7 +24,7 @@ Start: ; Save the zero-page locations that we need. ldx #zpspace-1 -L1: lda sp,x +L1: lda c_sp,x sta zpsave,x dex bpl L1 @@ -45,8 +45,8 @@ L1: lda sp,x lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) - sta sp - stx sp+1 ; Set argument stack ptr + sta c_sp + stx c_sp+1 ; Set argument stack ptr ; Call the module constructors. @@ -65,7 +65,7 @@ _exit: pha ; Save the return code on stack ldx #zpspace-1 L2: lda zpsave,x - sta sp,x + sta c_sp,x dex bpl L2 diff --git a/libsrc/zlib/inflatemem.s b/libsrc/zlib/inflatemem.s index 80c19f223..2f2a1b295 100644 --- a/libsrc/zlib/inflatemem.s +++ b/libsrc/zlib/inflatemem.s @@ -12,7 +12,7 @@ .export _inflatemem .import incsp2 - .importzp sp, sreg, ptr1, ptr2, ptr3, ptr4 + .importzp c_sp, sreg, ptr1, ptr2, ptr3, ptr4 ; -------------------------------------------------------------------------- ; @@ -79,10 +79,10 @@ _inflatemem: stx inputPointer+1 ; outputPointer = dest ldy #1 - lda (sp),y + lda (c_sp),y sta outputPointer+1 dey - lda (sp),y + lda (c_sp),y sta outputPointer ; ldy #0 @@ -129,11 +129,11 @@ inflate_nextBlock: lda outputPointer ; ldy #0 ; sec - sbc (sp),y + sbc (c_sp),y iny pha lda outputPointer+1 - sbc (sp),y + sbc (c_sp),y tax pla ; pop dest diff --git a/samples/getsp.s b/samples/getsp.s index 9f169dc0b..95db689f4 100644 --- a/samples/getsp.s +++ b/samples/getsp.s @@ -1,11 +1,11 @@ .export _getsp - .importzp sp + .importzp c_sp .proc _getsp - ldx sp+1 - lda sp + ldx c_sp+1 + lda c_sp rts .endproc diff --git a/samples/tinyshell.c b/samples/tinyshell.c index 71e9b56e3..a8d5340d9 100644 --- a/samples/tinyshell.c +++ b/samples/tinyshell.c @@ -112,17 +112,17 @@ static void get_command(void) #ifdef CHECK_SP static char firstcall = 1; static unsigned int good_sp; - unsigned int sp; + unsigned int c_sp; if (firstcall) - sp = good_sp = getsp(); + c_sp = good_sp = getsp(); else - sp = getsp(); + c_sp = getsp(); - if (sp != good_sp) { - printf("SP: 0x%04X ***MISMATCH*** 0x%04X\n", sp, good_sp); + if (c_sp != good_sp) { + printf("SP: 0x%04X ***MISMATCH*** 0x%04X\n", c_sp, good_sp); } else if (verbose) - printf("SP: 0x%04X\n", sp); + printf("SP: 0x%04X\n", c_sp); #endif arg1 = arg2 = arg3 = NULL; diff --git a/src/cc65/codegen.c b/src/cc65/codegen.c index 17618e5ff..42be0099a 100644 --- a/src/cc65/codegen.c +++ b/src/cc65/codegen.c @@ -220,7 +220,10 @@ void g_preamble (void) AddTextLine ("\t.debuginfo\t%s", (DebugInfo != 0)? "on" : "off"); /* Import zero page variables */ - AddTextLine ("\t.importzp\tsp, sreg, regsave, regbank"); + AddTextLine ("\t.importzp\t" "c_sp, sreg, regsave, regbank"); + /* The space above is intentional, to ease replacement of the name of + ** the stack pointer. Don't worry, the preprocessor will concatenate them. + */ AddTextLine ("\t.importzp\ttmp1, tmp2, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4"); /* Define long branch macros */ @@ -571,11 +574,11 @@ void g_swap_regvars (int StackOffs, int RegOffs, unsigned Bytes) AddCodeLine ("ldx #$%02X", RegOffs & 0xFF); AddCodeLine ("jsr regswap1"); } else { - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("ldx regbank%+d", RegOffs); AddCodeLine ("sta regbank%+d", RegOffs); AddCodeLine ("txa"); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("sta (c_sp),y"); } } else if (Bytes == 2) { @@ -617,7 +620,7 @@ void g_save_regvars (int RegOffs, unsigned Bytes) AddCodeLine ("ldx #$%02X", (unsigned char) Bytes); g_defcodelabel (Label); AddCodeLine ("lda regbank%+d,x", RegOffs-1); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("sta (c_sp),y"); AddCodeLine ("dey"); AddCodeLine ("dex"); AddCodeLine ("bne %s", LocalLabelName (Label)); @@ -641,28 +644,28 @@ void g_restore_regvars (int StackOffs, int RegOffs, unsigned Bytes) if (Bytes == 1) { AddCodeLine ("ldy #$%02X", StackOffs); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("sta regbank%+d", RegOffs); } else if (Bytes == 2) { AddCodeLine ("ldy #$%02X", StackOffs); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("sta regbank%+d", RegOffs); AddCodeLine ("iny"); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("sta regbank%+d", RegOffs+1); } else if (Bytes == 3 && IS_Get (&CodeSizeFactor) >= 133) { AddCodeLine ("ldy #$%02X", StackOffs); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("sta regbank%+d", RegOffs); AddCodeLine ("iny"); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("sta regbank%+d", RegOffs+1); AddCodeLine ("iny"); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("sta regbank%+d", RegOffs+2); } else if (StackOffs <= RegOffs) { @@ -674,7 +677,7 @@ void g_restore_regvars (int StackOffs, int RegOffs, unsigned Bytes) unsigned Label = GetLocalLabel (); AddCodeLine ("ldy #$%02X", StackOffs); g_defcodelabel (Label); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("sta regbank%+d,y", RegOffs - StackOffs); AddCodeLine ("iny"); AddCodeLine ("cpy #$%02X", StackOffs + Bytes); @@ -690,7 +693,7 @@ void g_restore_regvars (int StackOffs, int RegOffs, unsigned Bytes) AddCodeLine ("ldy #$%02X", (unsigned char) (StackOffs + Bytes - 1)); AddCodeLine ("ldx #$%02X", (unsigned char) (Bytes - 1)); g_defcodelabel (Label); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("sta regbank%+d,x", RegOffs); AddCodeLine ("dey"); AddCodeLine ("dex"); @@ -836,11 +839,11 @@ void g_getlocal (unsigned Flags, int Offs) CheckLocalOffs (Offs); if ((Flags & CF_FORCECHAR) || (Flags & CF_TEST)) { AddCodeLine ("ldy #$%02X", Offs); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); } else { AddCodeLine ("ldy #$%02X", Offs); AddCodeLine ("ldx #$00"); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); if ((Flags & CF_UNSIGNED) == 0) { unsigned L = GetLocalLabel(); AddCodeLine ("bpl %s", LocalLabelName (L)); @@ -854,9 +857,9 @@ void g_getlocal (unsigned Flags, int Offs) CheckLocalOffs (Offs + 1); AddCodeLine ("ldy #$%02X", (unsigned char) (Offs+1)); if (Flags & CF_TEST) { - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("dey"); - AddCodeLine ("ora (sp),y"); + AddCodeLine ("ora (c_sp),y"); } else { AddCodeLine ("jsr ldaxysp"); } @@ -937,7 +940,7 @@ void g_leasp (int Offs) { unsigned char Lo, Hi; - /* Calculate the offset relative to sp */ + /* Calculate the offset relative to c_sp */ Offs -= StackPtr; /* Get low and high byte */ @@ -947,17 +950,17 @@ void g_leasp (int Offs) /* Generate code */ if (Lo == 0) { if (Hi <= 3) { - AddCodeLine ("lda sp"); - AddCodeLine ("ldx sp+1"); + AddCodeLine ("lda c_sp"); + AddCodeLine ("ldx c_sp+1"); while (Hi--) { AddCodeLine ("inx"); } } else { - AddCodeLine ("lda sp+1"); + AddCodeLine ("lda c_sp+1"); AddCodeLine ("clc"); AddCodeLine ("adc #$%02X", Hi); AddCodeLine ("tax"); - AddCodeLine ("lda sp"); + AddCodeLine ("lda c_sp"); } } else if (Hi == 0) { /* 8 bit offset */ @@ -968,8 +971,8 @@ void g_leasp (int Offs) } else { /* 8 bit offset inlined */ unsigned L = GetLocalLabel (); - AddCodeLine ("lda sp"); - AddCodeLine ("ldx sp+1"); + AddCodeLine ("lda c_sp"); + AddCodeLine ("ldx c_sp+1"); AddCodeLine ("clc"); AddCodeLine ("adc #$%02X", Lo); AddCodeLine ("bcc %s", LocalLabelName (L)); @@ -983,11 +986,11 @@ void g_leasp (int Offs) AddCodeLine ("jsr leaaxsp"); } else { /* Full 16 bit offset inlined */ - AddCodeLine ("lda sp"); + AddCodeLine ("lda c_sp"); AddCodeLine ("clc"); AddCodeLine ("adc #$%02X", Lo); AddCodeLine ("pha"); - AddCodeLine ("lda sp+1"); + AddCodeLine ("lda c_sp+1"); AddCodeLine ("adc #$%02X", Hi); AddCodeLine ("tax"); AddCodeLine ("pla"); @@ -1003,10 +1006,10 @@ void g_leavariadic (int Offs) { unsigned ArgSizeOffs; - /* Calculate the offset relative to sp */ + /* Calculate the offset relative to c_sp */ Offs -= StackPtr; - /* Get the offset of the parameter which is stored at sp+0 on function + /* Get the offset of the parameter which is stored at c_sp+0 on function ** entry and check if this offset is reachable with a byte offset. */ CHECK (StackPtr <= 0); @@ -1015,14 +1018,14 @@ void g_leavariadic (int Offs) /* Get the size of all parameters. */ AddCodeLine ("ldy #$%02X", ArgSizeOffs); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); /* Add the value of the stackpointer */ if (IS_Get (&CodeSizeFactor) > 250) { unsigned L = GetLocalLabel(); - AddCodeLine ("ldx sp+1"); + AddCodeLine ("ldx c_sp+1"); AddCodeLine ("clc"); - AddCodeLine ("adc sp"); + AddCodeLine ("adc c_sp"); AddCodeLine ("bcc %s", LocalLabelName (L)); AddCodeLine ("inx"); g_defcodelabel (L); @@ -1094,14 +1097,14 @@ void g_putlocal (unsigned Flags, int Offs, long Val) AddCodeLine ("lda #$%02X", (unsigned char) Val); } AddCodeLine ("ldy #$%02X", Offs); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("sta (c_sp),y"); break; case CF_INT: if (Flags & CF_CONST) { AddCodeLine ("ldy #$%02X", Offs+1); AddCodeLine ("lda #$%02X", (unsigned char) (Val >> 8)); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("sta (c_sp),y"); if ((Flags & CF_NOKEEP) == 0) { /* Place high byte into X */ AddCodeLine ("tax"); @@ -1114,16 +1117,16 @@ void g_putlocal (unsigned Flags, int Offs, long Val) AddCodeLine ("dey"); AddCodeLine ("lda #$%02X", (unsigned char) Val); } - AddCodeLine ("sta (sp),y"); + AddCodeLine ("sta (c_sp),y"); } else { AddCodeLine ("ldy #$%02X", Offs); if ((Flags & CF_NOKEEP) == 0 || IS_Get (&CodeSizeFactor) < 160) { AddCodeLine ("jsr staxysp"); } else { - AddCodeLine ("sta (sp),y"); + AddCodeLine ("sta (c_sp),y"); AddCodeLine ("iny"); AddCodeLine ("txa"); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("sta (c_sp),y"); } } break; @@ -1163,12 +1166,12 @@ void g_putind (unsigned Flags, unsigned Offs) AddCodeLine ("pha"); } AddCodeLine ("lda #$%02X", Offs & 0xFF); - AddCodeLine ("adc (sp),y"); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("adc (c_sp),y"); + AddCodeLine ("sta (c_sp),y"); AddCodeLine ("iny"); AddCodeLine ("lda #$%02X", (Offs >> 8) & 0xFF); - AddCodeLine ("adc (sp),y"); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("adc (c_sp),y"); + AddCodeLine ("sta (c_sp),y"); if ((Flags & CF_NOKEEP) == 0) { AddCodeLine ("pla"); } @@ -1185,8 +1188,8 @@ void g_putind (unsigned Flags, unsigned Offs) AddCodeLine ("pha"); } AddCodeLine ("lda #$%02X", (Offs >> 8) & 0xFF); - AddCodeLine ("adc (sp),y"); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("adc (c_sp),y"); + AddCodeLine ("sta (c_sp),y"); if ((Flags & CF_NOKEEP) == 0) { AddCodeLine ("pla"); } @@ -1620,7 +1623,7 @@ void g_addlocal (unsigned flags, int offs) L = GetLocalLabel(); AddCodeLine ("ldy #$%02X", NewOff & 0xFF); AddCodeLine ("clc"); - AddCodeLine ("adc (sp),y"); + AddCodeLine ("adc (c_sp),y"); AddCodeLine ("bcc %s", LocalLabelName (L)); AddCodeLine ("inx"); g_defcodelabel (L); @@ -1629,11 +1632,11 @@ void g_addlocal (unsigned flags, int offs) case CF_INT: AddCodeLine ("ldy #$%02X", NewOff & 0xFF); AddCodeLine ("clc"); - AddCodeLine ("adc (sp),y"); + AddCodeLine ("adc (c_sp),y"); AddCodeLine ("pha"); AddCodeLine ("txa"); AddCodeLine ("iny"); - AddCodeLine ("adc (sp),y"); + AddCodeLine ("adc (c_sp),y"); AddCodeLine ("tax"); AddCodeLine ("pla"); break; @@ -1841,12 +1844,12 @@ void g_addeqlocal (unsigned flags, int Offs, unsigned long val) if (flags & CF_CONST) { AddCodeLine ("clc"); AddCodeLine ("lda #$%02X", (int)(val & 0xFF)); - AddCodeLine ("adc (sp),y"); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("adc (c_sp),y"); + AddCodeLine ("sta (c_sp),y"); } else { AddCodeLine ("clc"); - AddCodeLine ("adc (sp),y"); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("adc (c_sp),y"); + AddCodeLine ("sta (c_sp),y"); } if ((flags & CF_UNSIGNED) == 0) { unsigned L = GetLocalLabel(); @@ -1864,16 +1867,16 @@ void g_addeqlocal (unsigned flags, int Offs, unsigned long val) if (IS_Get (&CodeSizeFactor) >= 400) { AddCodeLine ("clc"); AddCodeLine ("lda #$%02X", (int)(val & 0xFF)); - AddCodeLine ("adc (sp),y"); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("adc (c_sp),y"); + AddCodeLine ("sta (c_sp),y"); AddCodeLine ("iny"); AddCodeLine ("lda #$%02X", (int) ((val >> 8) & 0xFF)); - AddCodeLine ("adc (sp),y"); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("adc (c_sp),y"); + AddCodeLine ("sta (c_sp),y"); if ((flags & CF_NOKEEP) == 0) { AddCodeLine ("tax"); AddCodeLine ("dey"); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); } } else { g_getimmed (flags, val, 0); @@ -1925,7 +1928,7 @@ void g_addeqind (unsigned flags, unsigned offs, unsigned long val) case CF_INT: case CF_LONG: AddCodeLine ("jsr pushax"); /* Push the address */ - push (CF_PTR); /* Correct the internal sp */ + push (CF_PTR); /* Correct the internal c_sp */ g_getind (flags, offs); /* Fetch the value */ g_inc (flags, val); /* Increment value in primary */ g_putind (flags, offs); /* Store the value back */ @@ -2091,15 +2094,15 @@ void g_subeqlocal (unsigned flags, int Offs, unsigned long val) AddCodeLine ("ldy #$%02X", Offs); AddCodeLine ("ldx #$00"); if (flags & CF_CONST) { - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("sec"); AddCodeLine ("sbc #$%02X", (unsigned char)val); } else { AddCodeLine ("eor #$FF"); AddCodeLine ("sec"); - AddCodeLine ("adc (sp),y"); + AddCodeLine ("adc (c_sp),y"); } - AddCodeLine ("sta (sp),y"); + AddCodeLine ("sta (c_sp),y"); if ((flags & CF_UNSIGNED) == 0) { unsigned L = GetLocalLabel(); AddCodeLine ("bpl %s", LocalLabelName (L)); @@ -2159,7 +2162,7 @@ void g_subeqind (unsigned flags, unsigned offs, unsigned long val) case CF_INT: case CF_LONG: AddCodeLine ("jsr pushax"); /* Push the address */ - push (CF_PTR); /* Correct the internal sp */ + push (CF_PTR); /* Correct the internal c_sp */ g_getind (flags, offs); /* Fetch the value */ g_dec (flags, val); /* Increment value in primary */ g_putind (flags, offs); /* Store the value back */ @@ -2210,10 +2213,10 @@ void g_addaddr_local (unsigned flags attribute ((unused)), int offs) /* Label was used above */ g_defcodelabel (L); } - AddCodeLine ("adc sp"); + AddCodeLine ("adc c_sp"); AddCodeLine ("tay"); AddCodeLine ("txa"); - AddCodeLine ("adc sp+1"); + AddCodeLine ("adc c_sp+1"); AddCodeLine ("tax"); AddCodeLine ("tya"); } @@ -2514,10 +2517,10 @@ void g_callind (unsigned Flags, unsigned ArgSize, int Offs) CheckLocalOffs (Offs); AddCodeLine ("pha"); AddCodeLine ("ldy #$%02X", Offs); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("sta jmpvec+1"); AddCodeLine ("iny"); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("sta jmpvec+2"); AddCodeLine ("pla"); AddCodeLine ("jsr jmpvec"); @@ -2575,11 +2578,11 @@ void g_lateadjustSP (unsigned label) AddCodeLine ("pha"); AddCodeLine ("lda %s", LocalDataLabelName (label)); AddCodeLine ("clc"); - AddCodeLine ("adc sp"); - AddCodeLine ("sta sp"); + AddCodeLine ("adc c_sp"); + AddCodeLine ("sta c_sp"); AddCodeLine ("lda %s+1", LocalDataLabelName (label)); - AddCodeLine ("adc sp+1"); - AddCodeLine ("sta sp+1"); + AddCodeLine ("adc c_sp+1"); + AddCodeLine ("sta c_sp+1"); AddCodeLine ("pla"); } @@ -2593,11 +2596,11 @@ void g_drop (unsigned Space) AddCodeLine ("pha"); AddCodeLine ("lda #$%02X", (unsigned char) Space); AddCodeLine ("clc"); - AddCodeLine ("adc sp"); - AddCodeLine ("sta sp"); + AddCodeLine ("adc c_sp"); + AddCodeLine ("sta c_sp"); AddCodeLine ("lda #$%02X", (unsigned char) (Space >> 8)); - AddCodeLine ("adc sp+1"); - AddCodeLine ("sta sp+1"); + AddCodeLine ("adc c_sp+1"); + AddCodeLine ("sta c_sp+1"); AddCodeLine ("pla"); } else if (Space > 8) { AddCodeLine ("ldy #$%02X", Space); @@ -2620,13 +2623,13 @@ void g_space (int Space) ** overhead. */ AddCodeLine ("pha"); - AddCodeLine ("lda sp"); + AddCodeLine ("lda c_sp"); AddCodeLine ("sec"); AddCodeLine ("sbc #$%02X", (unsigned char) Space); - AddCodeLine ("sta sp"); - AddCodeLine ("lda sp+1"); + AddCodeLine ("sta c_sp"); + AddCodeLine ("lda c_sp+1"); AddCodeLine ("sbc #$%02X", (unsigned char) (Space >> 8)); - AddCodeLine ("sta sp+1"); + AddCodeLine ("sta c_sp+1"); AddCodeLine ("pla"); } else if (Space > 8) { AddCodeLine ("ldy #$%02X", Space); @@ -4586,14 +4589,14 @@ void g_initauto (unsigned Label, unsigned Size) AddCodeLine ("ldy #$%02X", Size-1); g_defcodelabel (CodeLabel); AddCodeLine ("lda %s,y", GetLabelName (CF_STATIC, Label, 0)); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("sta (c_sp),y"); AddCodeLine ("dey"); AddCodeLine ("bpl %s", LocalLabelName (CodeLabel)); } else if (Size <= 256) { AddCodeLine ("ldy #$00"); g_defcodelabel (CodeLabel); AddCodeLine ("lda %s,y", GetLabelName (CF_STATIC, Label, 0)); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("sta (c_sp),y"); AddCodeLine ("iny"); AddCmpCodeIfSizeNot256 ("cpy #$%02X", Size); AddCodeLine ("bne %s", LocalLabelName (CodeLabel)); diff --git a/src/cc65/codeinfo.c b/src/cc65/codeinfo.c index 29f18cb78..25712d546 100644 --- a/src/cc65/codeinfo.c +++ b/src/cc65/codeinfo.c @@ -386,6 +386,8 @@ static const FuncInfo FuncInfoTable[] = { /* CAUTION: table must be sorted for bsearch */ static const ZPInfo ZPInfoTable[] = { /* BEGIN SORTED.SH */ + { 0, "c_sp", 2, REG_SP_LO, REG_SP }, + { 0, "c_sp+1", 1, REG_SP_HI, REG_SP }, { 0, "ptr1", 2, REG_PTR1_LO, REG_PTR1 }, { 0, "ptr1+1", 1, REG_PTR1_HI, REG_PTR1 }, { 0, "ptr2", 2, REG_PTR2_LO, REG_PTR2 }, @@ -395,8 +397,6 @@ static const ZPInfo ZPInfoTable[] = { { 7, "regbank", 6, REG_NONE, REG_NONE }, { 0, "regsave", 4, REG_SAVE_LO, REG_SAVE }, { 0, "regsave+1", 3, REG_SAVE_HI, REG_SAVE }, - { 0, "sp", 2, REG_SP_LO, REG_SP }, - { 0, "sp+1", 1, REG_SP_HI, REG_SP }, { 0, "sreg", 2, REG_SREG_LO, REG_SREG }, { 0, "sreg+1", 1, REG_SREG_HI, REG_SREG }, { 0, "tmp1", 1, REG_TMP1, REG_TMP1 }, diff --git a/src/cc65/codeinfo.h b/src/cc65/codeinfo.h index c57908dad..d03962343 100644 --- a/src/cc65/codeinfo.h +++ b/src/cc65/codeinfo.h @@ -75,8 +75,8 @@ struct RegContents; #define REG_SP_HI 0x2000U /* Defines for some special register usage */ -#define SLV_IND 0x00010000U /* Accesses (sp),y */ -#define SLV_TOP 0x00020000U /* Accesses (sp),0 */ +#define SLV_IND 0x00010000U /* Accesses (c_sp),y */ +#define SLV_TOP 0x00020000U /* Accesses (c_sp),0 */ #define SLV_SP65 0x00200000U /* Accesses 6502 stack pointer */ #define SLV_PH65 0x00400000U /* Pushes onto 6502 stack */ #define SLV_PL65 0x00800000U /* Pops from 6502 stack */ @@ -122,7 +122,7 @@ struct RegContents; typedef struct ZPInfo ZPInfo; struct ZPInfo { unsigned char Len; /* Length of the following string */ - char Name[10]; /* Name of zero page symbol */ + char Name[64]; /* Name of zero page symbol */ unsigned char Size; /* Maximum buffer size of this register */ unsigned short ByteUse; /* Register info for this symbol */ unsigned short WordUse; /* Register info for 16 bit access */ diff --git a/src/cc65/codeopt.c b/src/cc65/codeopt.c index 19acfde74..e3869d786 100644 --- a/src/cc65/codeopt.c +++ b/src/cc65/codeopt.c @@ -825,7 +825,7 @@ static unsigned RunOptGroup5 (CodeSeg* S) static unsigned RunOptGroup6 (CodeSeg* S) -/* This one is quite special. It tries to replace "lda (sp),y" by "lda (sp,x)". +/* This one is quite special. It tries to replace "lda (c_sp),y" by "lda (c_sp,x)". ** The latter is ony cycle slower, but if we're able to remove the necessary ** load of the Y register, because X is zero anyway, we gain 1 cycle and ** shorten the code by one (transfer) or two bytes (load). So what we do is diff --git a/src/cc65/codeoptutil.c b/src/cc65/codeoptutil.c index 7547ef5ba..0d3dba95c 100644 --- a/src/cc65/codeoptutil.c +++ b/src/cc65/codeoptutil.c @@ -333,14 +333,14 @@ static int Affected (LoadRegInfo* LRI, const CodeEntry* E) */ if (E->AM == AM65_ABS || E->AM == AM65_ZP || - (E->AM == AM65_ZP_INDY && strcmp (E->ArgBase, "sp") == 0) + (E->AM == AM65_ZP_INDY && strcmp (E->ArgBase, "c_sp") == 0) ) { if ((LRI->Flags & LI_CHECK_ARG) != 0) { if (AE == 0 || (AE->AM != AM65_ABS && AE->AM != AM65_ZP && (AE->AM != AM65_ZP_INDY || - strcmp (AE->ArgBase, "sp") != 0)) || + strcmp (AE->ArgBase, "c_sp") != 0)) || (AE->ArgOff == E->ArgOff && strcmp (AE->ArgBase, E->ArgBase) == 0)) { @@ -445,7 +445,7 @@ void PrepairLoadRegInfoForArgCheck (CodeSeg* S, LoadRegInfo* LRI, CodeEntry* E) /* These insns are replaceable only if they are not modified later */ LRI->Flags |= LI_CHECK_ARG | LI_CHECK_Y; } else if ((E->AM == AM65_ZP_INDY) && - strcmp (E->Arg, "sp") == 0) { + strcmp (E->Arg, "c_sp") == 0) { /* A load from the stack with known offset is also ok, but in this ** case we must reload the index register later. Please note that ** a load indirect via other zero page locations is not ok, since @@ -556,7 +556,7 @@ unsigned int TrackLoads (LoadInfo* LI, CodeSeg* S, int I) /* These insns are replaceable only if they are not modified later */ LRI->Flags |= LI_CHECK_ARG | LI_CHECK_Y; } else if (E->AM == AM65_ZP_INDY && - strcmp (E->Arg, "sp") == 0) { + strcmp (E->Arg, "c_sp") == 0) { /* A load from the stack with known offset is also ok, but in this ** case we must reload the index register later. Please note that ** a load indirect via other zero page locations is not ok, since @@ -839,7 +839,7 @@ void AdjustStackOffset (StackOpData* D, unsigned Offs) if (E->OPC != OP65_JSR) { /* Check against some things that should not happen */ CHECK (E->AM == AM65_ZP_INDY && E->RI->In.RegY >= (short) Offs); - CHECK (strcmp (E->Arg, "sp") == 0); + CHECK (strcmp (E->Arg, "c_sp") == 0); /* We need to correct this one */ Correction = 2; @@ -1056,8 +1056,8 @@ void AddOpLow (StackOpData* D, opc_t OPC, LoadInfo* LI) InsertEntry (D, X, D->IP++); if (LI->A.LoadEntry->OPC == OP65_JSR) { - /* opc (sp),y */ - X = NewCodeEntry (OPC, AM65_ZP_INDY, "sp", 0, D->OpEntry->LI); + /* opc (c_sp),y */ + X = NewCodeEntry (OPC, AM65_ZP_INDY, "c_sp", 0, D->OpEntry->LI); } else { /* opc src,y */ X = NewCodeEntry (OPC, LI->A.LoadEntry->AM, LI->A.LoadEntry->Arg, 0, D->OpEntry->LI); @@ -1119,8 +1119,8 @@ void AddOpHigh (StackOpData* D, opc_t OPC, LoadInfo* LI, int KeepResult) InsertEntry (D, X, D->IP++); if (LI->X.LoadEntry->OPC == OP65_JSR) { - /* opc (sp),y */ - X = NewCodeEntry (OPC, AM65_ZP_INDY, "sp", 0, D->OpEntry->LI); + /* opc (c_sp),y */ + X = NewCodeEntry (OPC, AM65_ZP_INDY, "c_sp", 0, D->OpEntry->LI); } else { /* opc src,y */ X = NewCodeEntry (OPC, LI->X.LoadEntry->AM, LI->X.LoadEntry->Arg, 0, D->OpEntry->LI); @@ -1312,10 +1312,10 @@ const char* GetZPName (unsigned ZPLoc) return "save+1"; } if ((ZPLoc & REG_SP_LO) != 0) { - return "sp"; + return "c_sp"; } if ((ZPLoc & REG_SP_HI) != 0) { - return "sp+1"; + return "c_sp+1"; } return 0; diff --git a/src/cc65/coptadd.c b/src/cc65/coptadd.c index bc67f7a74..3636e0e20 100644 --- a/src/cc65/coptadd.c +++ b/src/cc65/coptadd.c @@ -62,15 +62,15 @@ unsigned OptAdd1 (CodeSeg* S) ** and replace it by: ** ** ldy #xx-1 -** lda (sp),y +** lda (c_sp),y ** ldy #yy-3 ** clc -** adc (sp),y +** adc (c_sp),y ** pha ** ldy #xx -** lda (sp),y +** lda (c_sp),y ** ldy #yy-2 -** adc (sp),y +** adc (c_sp),y ** tax ** pla */ @@ -104,8 +104,8 @@ unsigned OptAdd1 (CodeSeg* S) /* Correct the stack of the first Y register load */ CE_SetNumArg (L[0], L[0]->Num - 1); - /* lda (sp),y */ - X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "sp", 0, L[1]->LI); + /* lda (c_sp),y */ + X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "c_sp", 0, L[1]->LI); CS_InsertEntry (S, X, I+1); /* ldy #yy-3 */ @@ -117,8 +117,8 @@ unsigned OptAdd1 (CodeSeg* S) X = NewCodeEntry (OP65_CLC, AM65_IMP, 0, 0, L[5]->LI); CS_InsertEntry (S, X, I+3); - /* adc (sp),y */ - X = NewCodeEntry (OP65_ADC, AM65_ZP_INDY, "sp", 0, L[5]->LI); + /* adc (c_sp),y */ + X = NewCodeEntry (OP65_ADC, AM65_ZP_INDY, "c_sp", 0, L[5]->LI); CS_InsertEntry (S, X, I+4); /* pha */ @@ -130,8 +130,8 @@ unsigned OptAdd1 (CodeSeg* S) X = NewCodeEntry (OP65_LDY, AM65_IMM, Arg, 0, L[1]->LI); CS_InsertEntry (S, X, I+6); - /* lda (sp),y */ - X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "sp", 0, L[1]->LI); + /* lda (c_sp),y */ + X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "c_sp", 0, L[1]->LI); CS_InsertEntry (S, X, I+7); /* ldy #yy-2 */ @@ -139,8 +139,8 @@ unsigned OptAdd1 (CodeSeg* S) X = NewCodeEntry (OP65_LDY, AM65_IMM, Arg, 0, L[4]->LI); CS_InsertEntry (S, X, I+8); - /* adc (sp),y */ - X = NewCodeEntry (OP65_ADC, AM65_ZP_INDY, "sp", 0, L[5]->LI); + /* adc (c_sp),y */ + X = NewCodeEntry (OP65_ADC, AM65_ZP_INDY, "c_sp", 0, L[5]->LI); CS_InsertEntry (S, X, I+9); /* tax */ @@ -181,16 +181,16 @@ unsigned OptAdd2 (CodeSeg* S) ** and replace it by: ** ** ldy #xx-1 -** lda (sp),y +** lda (c_sp),y ** ldy #yy ** clc -** adc (sp),y -** sta (sp),y +** adc (c_sp),y +** sta (c_sp),y ** ldy #xx -** lda (sp),y +** lda (c_sp),y ** ldy #yy+1 -** adc (sp),y -** sta (sp),y +** adc (c_sp),y +** sta (c_sp),y ** ** provided that a/x is not used later. */ @@ -226,8 +226,8 @@ unsigned OptAdd2 (CodeSeg* S) X = NewCodeEntry (OP65_LDY, AM65_IMM, Arg, 0, L[0]->LI); CS_InsertEntry (S, X, I+4); - /* lda (sp),y */ - X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "sp", 0, L[1]->LI); + /* lda (c_sp),y */ + X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "c_sp", 0, L[1]->LI); CS_InsertEntry (S, X, I+5); /* ldy #yy */ @@ -238,20 +238,20 @@ unsigned OptAdd2 (CodeSeg* S) X = NewCodeEntry (OP65_CLC, AM65_IMP, 0, 0, L[3]->LI); CS_InsertEntry (S, X, I+7); - /* adc (sp),y */ - X = NewCodeEntry (OP65_ADC, AM65_ZP_INDY, "sp", 0, L[3]->LI); + /* adc (c_sp),y */ + X = NewCodeEntry (OP65_ADC, AM65_ZP_INDY, "c_sp", 0, L[3]->LI); CS_InsertEntry (S, X, I+8); - /* sta (sp),y */ - X = NewCodeEntry (OP65_STA, AM65_ZP_INDY, "sp", 0, L[3]->LI); + /* sta (c_sp),y */ + X = NewCodeEntry (OP65_STA, AM65_ZP_INDY, "c_sp", 0, L[3]->LI); CS_InsertEntry (S, X, I+9); /* ldy #xx */ X = NewCodeEntry (OP65_LDY, AM65_IMM, L[0]->Arg, 0, L[0]->LI); CS_InsertEntry (S, X, I+10); - /* lda (sp),y */ - X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "sp", 0, L[1]->LI); + /* lda (c_sp),y */ + X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "c_sp", 0, L[1]->LI); CS_InsertEntry (S, X, I+11); /* ldy #yy+1 */ @@ -259,12 +259,12 @@ unsigned OptAdd2 (CodeSeg* S) X = NewCodeEntry (OP65_LDY, AM65_IMM, Arg, 0, L[2]->LI); CS_InsertEntry (S, X, I+12); - /* adc (sp),y */ - X = NewCodeEntry (OP65_ADC, AM65_ZP_INDY, "sp", 0, L[3]->LI); + /* adc (c_sp),y */ + X = NewCodeEntry (OP65_ADC, AM65_ZP_INDY, "c_sp", 0, L[3]->LI); CS_InsertEntry (S, X, I+13); - /* sta (sp),y */ - X = NewCodeEntry (OP65_STA, AM65_ZP_INDY, "sp", 0, L[3]->LI); + /* sta (c_sp),y */ + X = NewCodeEntry (OP65_STA, AM65_ZP_INDY, "c_sp", 0, L[3]->LI); CS_InsertEntry (S, X, I+14); /* Delete the old code */ diff --git a/src/cc65/coptadd.h b/src/cc65/coptadd.h index e4df3b304..d29783305 100644 --- a/src/cc65/coptadd.h +++ b/src/cc65/coptadd.h @@ -55,14 +55,14 @@ unsigned OptAdd1 (CodeSeg* S); ** jsr pushax ** ldy xxx ** ldx #$00 -** lda (sp),y +** lda (c_sp),y ** jsr tosaddax ** ** and replace it by: ** ** ldy xxx-2 ** clc -** adc (sp),y +** adc (c_sp),y ** bcc L ** inx ** L: @@ -72,26 +72,26 @@ unsigned OptAdd2 (CodeSeg* S); /* Search for the sequence ** ** ldy #xx -** lda (sp),y +** lda (c_sp),y ** tax ** dey -** lda (sp),y +** lda (c_sp),y ** ldy #$yy ** jsr addeqysp ** ** and replace it by: ** ** ldy #xx-1 -** lda (sp),y +** lda (c_sp),y ** ldy #yy ** clc -** adc (sp),y -** sta (sp),y +** adc (c_sp),y +** sta (c_sp),y ** ldy #xx -** lda (sp),y +** lda (c_sp),y ** ldy #yy+1 -** adc (sp),y -** sta (sp),y +** adc (c_sp),y +** sta (c_sp),y ** ** provided that a/x is not used later. */ diff --git a/src/cc65/coptbool.c b/src/cc65/coptbool.c index 3a3b3fa7c..e0a79238e 100644 --- a/src/cc65/coptbool.c +++ b/src/cc65/coptbool.c @@ -743,9 +743,9 @@ unsigned OptBNegAX2 (CodeSeg* S) ** and replace it by ** ** ldy #xx -** lda (sp),y +** lda (c_sp),y ** dey -** ora (sp),y +** ora (c_sp),y ** jeq/jne ... */ { @@ -772,16 +772,16 @@ unsigned OptBNegAX2 (CodeSeg* S) CodeEntry* X; - /* lda (sp),y */ - X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "sp", 0, L[1]->LI); + /* lda (c_sp),y */ + X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "c_sp", 0, L[1]->LI); CS_InsertEntry (S, X, I+1); /* dey */ X = NewCodeEntry (OP65_DEY, AM65_IMP, 0, 0, L[1]->LI); CS_InsertEntry (S, X, I+2); - /* ora (sp),y */ - X = NewCodeEntry (OP65_ORA, AM65_ZP_INDY, "sp", 0, L[1]->LI); + /* ora (c_sp),y */ + X = NewCodeEntry (OP65_ORA, AM65_ZP_INDY, "c_sp", 0, L[1]->LI); CS_InsertEntry (S, X, I+3); /* Invert the branch */ diff --git a/src/cc65/coptcmp.c b/src/cc65/coptcmp.c index 2970b363b..eb138e78d 100644 --- a/src/cc65/coptcmp.c +++ b/src/cc65/coptcmp.c @@ -431,22 +431,22 @@ unsigned OptCmp5 (CodeSeg* S) /* The value is zero, we may use the simple code version: ** ldy #o-1 - ** lda (sp),y + ** lda (c_sp),y ** ldy #o - ** ora (sp),y + ** ora (c_sp),y ** jne/jeq ... */ sprintf (Buf, "$%02X", (int)(L[0]->Num-1)); X = NewCodeEntry (OP65_LDY, AM65_IMM, Buf, 0, L[0]->LI); CS_InsertEntry (S, X, I+1); - X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "sp", 0, L[1]->LI); + X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "c_sp", 0, L[1]->LI); CS_InsertEntry (S, X, I+2); X = NewCodeEntry (OP65_LDY, AM65_IMM, L[0]->Arg, 0, L[0]->LI); CS_InsertEntry (S, X, I+3); - X = NewCodeEntry (OP65_ORA, AM65_ZP_INDY, "sp", 0, L[1]->LI); + X = NewCodeEntry (OP65_ORA, AM65_ZP_INDY, "c_sp", 0, L[1]->LI); CS_InsertEntry (S, X, I+4); CS_DelEntries (S, I+5, 3); /* cpx/bne/cmp */ @@ -461,18 +461,18 @@ unsigned OptCmp5 (CodeSeg* S) ** of the low byte after the first branch if possible: ** ** ldy #o - ** lda (sp),y + ** lda (c_sp),y ** cmp #a ** bne L1 ** ldy #o-1 - ** lda (sp),y + ** lda (c_sp),y ** cmp #b ** jne/jeq ... */ X = NewCodeEntry (OP65_LDY, AM65_IMM, L[0]->Arg, 0, L[0]->LI); CS_InsertEntry (S, X, I+3); - X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "sp", 0, L[1]->LI); + X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "c_sp", 0, L[1]->LI); CS_InsertEntry (S, X, I+4); X = NewCodeEntry (OP65_CMP, L[2]->AM, L[2]->Arg, 0, L[2]->LI); @@ -482,7 +482,7 @@ unsigned OptCmp5 (CodeSeg* S) X = NewCodeEntry (OP65_LDY, AM65_IMM, Buf, 0, L[0]->LI); CS_InsertEntry (S, X, I+7); - X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "sp", 0, L[1]->LI); + X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "c_sp", 0, L[1]->LI); CS_InsertEntry (S, X, I+8); CS_DelEntries (S, I, 3); /* ldy/jsr/cpx */ diff --git a/src/cc65/coptcmp.h b/src/cc65/coptcmp.h index dd188f7fc..98e75715b 100644 --- a/src/cc65/coptcmp.h +++ b/src/cc65/coptcmp.h @@ -113,10 +113,10 @@ unsigned OptCmp5 (CodeSeg* S); /* Optimize compares of local variables: ** ** ldy #o -** lda (sp),y +** lda (c_sp),y ** tax ** dey -** lda (sp),y +** lda (c_sp),y ** cpx #a ** bne L1 ** cmp #b diff --git a/src/cc65/coptmisc.c b/src/cc65/coptmisc.c index b23ee6e0a..a2cda7495 100644 --- a/src/cc65/coptmisc.c +++ b/src/cc65/coptmisc.c @@ -492,9 +492,9 @@ unsigned OptGotoSPAdj (CodeSeg* S) L[1]->AM == AM65_ABS && L[2]->OPC == OP65_CLC && L[3]->OPC == OP65_ADC && - strcmp (L[3]->Arg, "sp") == 0 && + strcmp (L[3]->Arg, "c_sp") == 0 && L[6]->OPC == OP65_ADC && - strcmp (L[6]->Arg, "sp+1") == 0 && + strcmp (L[6]->Arg, "c_sp+1") == 0 && L[9]->OPC == OP65_JMP) { adjustment = FindSPAdjustment (L[1]->Arg); @@ -663,7 +663,7 @@ unsigned OptLoad1 (CodeSeg* S) CS_InsertEntry (S, X, I+1); /* Load from stack */ - X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "sp", 0, E->LI); + X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "c_sp", 0, E->LI); CS_InsertEntry (S, X, I+2); /* Now remove the call to the subroutine */ @@ -719,8 +719,8 @@ unsigned OptLoad2 (CodeSeg* S) ** later */ - /* lda (sp),y */ - X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "sp", 0, L[0]->LI); + /* lda (c_sp),y */ + X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "c_sp", 0, L[0]->LI); CS_InsertEntry (S, X, I+3); /* sta abs */ @@ -731,8 +731,8 @@ unsigned OptLoad2 (CodeSeg* S) X = NewCodeEntry (OP65_DEY, AM65_IMP, 0, 0, L[0]->LI); CS_InsertEntry (S, X, I+5); - /* lda (sp),y */ - X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "sp", 0, L[0]->LI); + /* lda (c_sp),y */ + X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "c_sp", 0, L[0]->LI); CS_InsertEntry (S, X, I+6); /* sta abs */ @@ -746,8 +746,8 @@ unsigned OptLoad2 (CodeSeg* S) /* Standard replacement */ - /* lda (sp),y */ - X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "sp", 0, L[0]->LI); + /* lda (c_sp),y */ + X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "c_sp", 0, L[0]->LI); CS_InsertEntry (S, X, I+1); /* tax */ @@ -758,8 +758,8 @@ unsigned OptLoad2 (CodeSeg* S) X = NewCodeEntry (OP65_DEY, AM65_IMP, 0, 0, L[0]->LI); CS_InsertEntry (S, X, I+3); - /* lda (sp),y */ - X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "sp", 0, L[0]->LI); + /* lda (c_sp),y */ + X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "c_sp", 0, L[0]->LI); CS_InsertEntry (S, X, I+4); /* Now remove the call to the subroutine */ diff --git a/src/cc65/coptptrload.c b/src/cc65/coptptrload.c index 046e65d79..e28bf5d39 100644 --- a/src/cc65/coptptrload.c +++ b/src/cc65/coptptrload.c @@ -359,7 +359,7 @@ unsigned OptPtrLoad4 (CodeSeg* S) ** ldx #>(label+0) ** ldy #$xx ** clc -** adc (sp),y +** adc (c_sp),y ** bcc L ** inx ** L: ldy #$00 @@ -368,7 +368,7 @@ unsigned OptPtrLoad4 (CodeSeg* S) ** and replace it by: ** ** ldy #$xx -** lda (sp),y +** lda (c_sp),y ** tay ** ldx #$00 ** lda label,y @@ -553,7 +553,7 @@ unsigned OptPtrLoad6 (CodeSeg* S) ** jsr pushax ** ldy #xxx ** ldx #$00 -** lda (sp),y +** lda (c_sp),y ** jsr tosaddax ** ldy #$00 ** jsr ldauidx @@ -563,7 +563,7 @@ unsigned OptPtrLoad6 (CodeSeg* S) ** sta ptr1 ** stx ptr1+1 ** ldy #xxx-2 -** lda (sp),y +** lda (c_sp),y ** tay ** ldx #$00 ** lda (ptr1),y @@ -613,7 +613,7 @@ unsigned OptPtrLoad6 (CodeSeg* S) X = NewCodeEntry (OP65_LDY, AM65_IMM, Arg, 0, L[1]->LI); CS_InsertEntry (S, X, I+9); - /* lda (sp),y */ + /* lda (c_sp),y */ X = NewCodeEntry (OP65_LDA, L[3]->AM, L[3]->Arg, 0, L[3]->LI); CS_InsertEntry (S, X, I+10); diff --git a/src/cc65/coptptrload.h b/src/cc65/coptptrload.h index d4e0e2ed4..259d1587b 100644 --- a/src/cc65/coptptrload.h +++ b/src/cc65/coptptrload.h @@ -127,7 +127,7 @@ unsigned OptPtrLoad4 (CodeSeg* S); ** ldx #>(label+0) ** ldy #$xx ** clc -** adc (sp),y +** adc (c_sp),y ** bcc L ** inx ** L: ldy #$00 @@ -136,7 +136,7 @@ unsigned OptPtrLoad4 (CodeSeg* S); ** and replace it by: ** ** ldy #$xx -** lda (sp),y +** lda (c_sp),y ** tay ** ldx #$00 ** lda label,y @@ -166,7 +166,7 @@ unsigned OptPtrLoad6 (CodeSeg* S); ** jsr pushax ** ldy xxx ** ldx #$00 -** lda (sp),y +** lda (c_sp),y ** jsr tosaddax ** ldy #$00 ** jsr ldauidx @@ -176,7 +176,7 @@ unsigned OptPtrLoad6 (CodeSeg* S); ** sta ptr1 ** stx ptr1+1 ** ldy xxx -** lda (sp),y +** lda (c_sp),y ** tay ** lda (ptr1),y */ diff --git a/src/cc65/coptptrstore.c b/src/cc65/coptptrstore.c index 11832910f..6891d8353 100644 --- a/src/cc65/coptptrstore.c +++ b/src/cc65/coptptrstore.c @@ -396,7 +396,7 @@ unsigned OptPtrStore2 (CodeSeg* S) ** L: jsr pushax ** ldy yyy ** ldx #$00 -** lda (sp),y +** lda (c_sp),y ** ldy #$00 ** jsr staspidx ** @@ -406,7 +406,7 @@ unsigned OptPtrStore2 (CodeSeg* S) ** stx ptr1+1 ** ldy yyy-2 ** ldx #$00 -** lda (sp),y +** lda (c_sp),y ** ldy xxx ** sta (ptr1),y ** @@ -414,7 +414,7 @@ unsigned OptPtrStore2 (CodeSeg* S) ** ** ldy yyy-2 ** ldx #$00 -** lda (sp),y +** lda (c_sp),y ** ldy xxx ** sta (zp),y ** @@ -422,7 +422,7 @@ unsigned OptPtrStore2 (CodeSeg* S) ** ** ldy yyy-2 ** ldx #$00 -** lda (sp),y +** lda (c_sp),y ** ldy xxx ** sta label,y ** @@ -430,7 +430,7 @@ unsigned OptPtrStore2 (CodeSeg* S) ** ** ldy yyy-2 ** ldx #$00 -** lda (sp),y +** lda (c_sp),y ** ldy xxx ** sta $xxxx,y ** @@ -468,7 +468,7 @@ unsigned OptPtrStore2 (CodeSeg* S) L[6]->OPC == OP65_LDX && L[7]->OPC == OP65_LDA && L[7]->AM == AM65_ZP_INDY && - strcmp (L[7]->Arg, "sp") == 0 && + strcmp (L[7]->Arg, "c_sp") == 0 && L[8]->OPC == OP65_LDY && (L[8]->AM == AM65_ABS || L[8]->AM == AM65_ZP || diff --git a/src/cc65/coptptrstore.h b/src/cc65/coptptrstore.h index 3f8fc91f9..fd36eddba 100644 --- a/src/cc65/coptptrstore.h +++ b/src/cc65/coptptrstore.h @@ -105,7 +105,7 @@ unsigned OptPtrStore2 (CodeSeg* S); ** L: jsr pushax ** ldy yyy ** ldx #$00 -** lda (sp),y +** lda (c_sp),y ** ldy #$00 ** jsr staspidx ** @@ -115,7 +115,7 @@ unsigned OptPtrStore2 (CodeSeg* S); ** stx ptr1+1 ** ldy yyy-2 ** ldx #$00 -** lda (sp),y +** lda (c_sp),y ** ldy xxx ** sta (ptr1),y ** @@ -123,7 +123,7 @@ unsigned OptPtrStore2 (CodeSeg* S); ** ** ldy yyy-2 ** ldx #$00 -** lda (sp),y +** lda (c_sp),y ** ldy xxx ** sta (zp),y ** @@ -131,7 +131,7 @@ unsigned OptPtrStore2 (CodeSeg* S); ** ** ldy yyy-2 ** ldx #$00 -** lda (sp),y +** lda (c_sp),y ** ldy xxx ** sta label,y ** @@ -139,7 +139,7 @@ unsigned OptPtrStore2 (CodeSeg* S); ** ** ldy yyy-2 ** ldx #$00 -** lda (sp),y +** lda (c_sp),y ** ldy xxx ** sta $xxxx,y ** diff --git a/src/cc65/coptstop.c b/src/cc65/coptstop.c index e5d686d1a..7a9416b51 100644 --- a/src/cc65/coptstop.c +++ b/src/cc65/coptstop.c @@ -1292,10 +1292,10 @@ static unsigned Opt_a_tosicmp (StackOpData* D) } InsertEntry (D, X, D->IP++); - /* cmp src,y OR cmp (sp),y */ + /* cmp src,y OR cmp (c_sp),y */ if (D->Rhs.A.LoadEntry->OPC == OP65_JSR) { - /* opc (sp),y */ - X = NewCodeEntry (OP65_CMP, AM65_ZP_INDY, "sp", 0, D->OpEntry->LI); + /* opc (c_sp),y */ + X = NewCodeEntry (OP65_CMP, AM65_ZP_INDY, "c_sp", 0, D->OpEntry->LI); } else { /* opc src,y */ X = NewCodeEntry (OP65_CMP, D->Rhs.A.LoadEntry->AM, D->Rhs.A.LoadEntry->Arg, 0, D->OpEntry->LI); diff --git a/src/cc65/coptstore.c b/src/cc65/coptstore.c index b0dfe3b6d..2fc83b5fb 100644 --- a/src/cc65/coptstore.c +++ b/src/cc65/coptstore.c @@ -48,7 +48,7 @@ static void InsertStore (CodeSeg* S, unsigned* IP, LineInfo* LI) { - CodeEntry* X = NewCodeEntry (OP65_STA, AM65_ZP_INDY, "sp", 0, LI); + CodeEntry* X = NewCodeEntry (OP65_STA, AM65_ZP_INDY, "c_sp", 0, LI); CS_InsertEntry (S, X, (*IP)++); } diff --git a/src/cc65/locals.c b/src/cc65/locals.c index 08e41918e..08fe83b75 100644 --- a/src/cc65/locals.c +++ b/src/cc65/locals.c @@ -269,7 +269,7 @@ static void ParseAutoDecl (Declarator* Decl) Sym->V.Offs = F_ReserveLocalSpace (CurrentFunc, Size); /* Next, allocate the space on the stack. This means that the - ** variable is now located at offset 0 from the current sp. + ** variable is now located at offset 0 from the current c_sp. */ F_AllocLocalSpace (CurrentFunc); diff --git a/src/cc65/stdfunc.c b/src/cc65/stdfunc.c index 3f33cdcce..1597380e8 100644 --- a/src/cc65/stdfunc.c +++ b/src/cc65/stdfunc.c @@ -371,7 +371,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1)); g_defcodelabel (Label); AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs)); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("sta (c_sp),y"); AddCodeLine ("dey"); AddCodeLine ("bpl %s", LocalLabelName (Label)); } else { @@ -379,7 +379,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1)); g_defcodelabel (Label); AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0)); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("sta (c_sp),y"); AddCodeLine ("dey"); AddCodeLine ("dex"); AddCodeLine ("bpl %s", LocalLabelName (Label)); @@ -391,7 +391,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) AddCodeLine ("ldy #$%02X", (unsigned char) Offs); g_defcodelabel (Label); AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs)); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("sta (c_sp),y"); AddCodeLine ("iny"); AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal); AddCodeLine ("bne %s", LocalLabelName (Label)); @@ -400,7 +400,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) AddCodeLine ("ldy #$%02X", (unsigned char) Offs); g_defcodelabel (Label); AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0)); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("sta (c_sp),y"); AddCodeLine ("iny"); AddCodeLine ("inx"); AddCmpCodeIfSizeNot256 ("cpx #$%02X", Arg3.Expr.IVal); @@ -448,7 +448,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) if (Offs == 0) { AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal - 1)); g_defcodelabel (Label); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); AddCodeLine ("dey"); AddCodeLine ("bpl %s", LocalLabelName (Label)); @@ -456,7 +456,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) AddCodeLine ("ldx #$%02X", (unsigned char) (Arg3.Expr.IVal-1)); AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1)); g_defcodelabel (Label); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0)); AddCodeLine ("dey"); AddCodeLine ("dex"); @@ -468,7 +468,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) if (Offs == 0 || AllowOneIndex) { AddCodeLine ("ldy #$%02X", (unsigned char) Offs); g_defcodelabel (Label); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, -Offs)); AddCodeLine ("iny"); AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal); @@ -477,7 +477,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) AddCodeLine ("ldx #$00"); AddCodeLine ("ldy #$%02X", (unsigned char) Offs); g_defcodelabel (Label); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0)); AddCodeLine ("iny"); AddCodeLine ("inx"); @@ -512,14 +512,14 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) if (Arg3.Expr.IVal <= 129) { AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal - 1)); g_defcodelabel (Label); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("sta (ptr1),y"); AddCodeLine ("dey"); AddCodeLine ("bpl %s", LocalLabelName (Label)); } else { AddCodeLine ("ldy #$00"); g_defcodelabel (Label); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("sta (ptr1),y"); AddCodeLine ("iny"); AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal); @@ -703,7 +703,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr) AddCodeLine ("ldy #$%02X", (unsigned char) Offs); AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal); g_defcodelabel (Label); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("sta (c_sp),y"); AddCodeLine ("iny"); AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal); AddCodeLine ("bne %s", LocalLabelName (Label)); @@ -857,7 +857,7 @@ static void StdFunc_strcmp (FuncDesc* F attribute ((unused)), ExprDesc* Expr) /* Generate code */ AddCodeLine ("ldy #$%02X", Offs); AddCodeLine ("ldx #$00"); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); } else if (IsArray && ED_IsLocConst (&Arg1.Expr)) { /* Drop the generated code */ RemoveCode (&Arg1.Load); @@ -1090,14 +1090,14 @@ static void StdFunc_strcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) if (Offs == 0 || AllowOneIndex) { g_defcodelabel (L1); AddCodeLine ("iny"); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, -Offs)); } else { AddCodeLine ("ldx #$FF"); g_defcodelabel (L1); AddCodeLine ("iny"); AddCodeLine ("inx"); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0)); } AddCodeLine ("bne %s", LocalLabelName (L1)); @@ -1138,14 +1138,14 @@ static void StdFunc_strcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) g_defcodelabel (L1); AddCodeLine ("iny"); AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs)); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("sta (c_sp),y"); } else { AddCodeLine ("ldx #$FF"); g_defcodelabel (L1); AddCodeLine ("iny"); AddCodeLine ("inx"); AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0)); - AddCodeLine ("sta (sp),y"); + AddCodeLine ("sta (c_sp),y"); } AddCodeLine ("bne %s", LocalLabelName (L1)); @@ -1285,7 +1285,7 @@ static void StdFunc_strlen (FuncDesc* F attribute ((unused)), ExprDesc* Expr) g_defcodelabel (L); AddCodeLine ("inx"); AddCodeLine ("iny"); - AddCodeLine ("lda (sp),y"); + AddCodeLine ("lda (c_sp),y"); AddCodeLine ("bne %s", LocalLabelName (L)); AddCodeLine ("txa"); AddCodeLine ("ldx #$00"); diff --git a/src/dbginfo/dbgsh.c b/src/dbginfo/dbgsh.c index 6a95db2af..280221fc9 100644 --- a/src/dbginfo/dbgsh.c +++ b/src/dbginfo/dbgsh.c @@ -458,7 +458,7 @@ static unsigned FindIdType (const char* TypeName) { "segment", SegmentId }, { "source", SourceId }, { "src", SourceId }, - { "sp", SpanId }, + { "c_sp", SpanId }, { "span", SpanId }, { "sym", SymbolId }, { "symbol", SymbolId }, diff --git a/src/sim65/main.c b/src/sim65/main.c index 828ea498e..3cc9581b5 100644 --- a/src/sim65/main.c +++ b/src/sim65/main.c @@ -230,7 +230,7 @@ static unsigned char ReadProgramFile (void) } } - /* Get the address of sp from the file header */ + /* Get the address of c_sp from the file header */ if ((Val = fgetc(F)) != EOF) { SPAddr = Val; } diff --git a/targettest/atari/mem.c b/targettest/atari/mem.c index b15b215ed..f063d1e46 100644 --- a/targettest/atari/mem.c +++ b/targettest/atari/mem.c @@ -41,7 +41,7 @@ int main(void) printf(" data: $%04X (data)\n", &data); printf(" _dos_type: $%04X (bss)\n", &_dos_type); printf(" allocmem: $%04X (dyn. data)\n", allocmem); - printf(" sp: $%04X (stack ptr)\n", getsp()); + printf(" c_sp: $%04X (stack ptr)\n", getsp()); if (allocmem) free(allocmem); if (doesclrscrafterexit()) cgetc(); diff --git a/targettest/ft.c b/targettest/ft.c index 3dfa0e37b..a28795f2b 100644 --- a/targettest/ft.c +++ b/targettest/ft.c @@ -10,7 +10,7 @@ ** got one from argv). I then opens the file, ** reads the first 16 bytes and displays them ** (as hex values). -** The values of sp (cc65 runtime stack pointer) +** The values of c_sp (cc65 runtime stack pointer) ** are displayed at some places. The displayed ** value should always be the same. */ @@ -64,16 +64,16 @@ int main(int argc,char **argv) } printf("using filename \"%s\"\n",filename); csp = getsp(); - printf("now opening file... sp = %d\n",csp); + printf("now opening file... c_sp = %d\n",csp); fd = open(filename,O_RDONLY); csp = getsp(); if (fd == -1) { char x1 = _oserror; - printf("open failed: os: %d,\n\terrno: %d, sp = %d\n",x1,errno,csp); + printf("open failed: os: %d,\n\terrno: %d, c_sp = %d\n",x1,errno,csp); cgetc(); return(0); } - printf("open success -- handle = $%x, sp = %d\n",fd,csp); + printf("open success -- handle = $%x, c_sp = %d\n",fd,csp); #ifdef __ATARI__ printf("fd_index:\n "); for (i=0; i<12; i++) printf("%02X ",__fd_index[i]); @@ -88,7 +88,7 @@ int main(int argc,char **argv) lr = read(fd,buf,16); /* read first 16 bytes */ csp = getsp(); if (lr == -1) { - printf("read failed: %d (sp = %d)\n",errno,csp); + printf("read failed: %d (c_sp = %d)\n",errno,csp); cgetc(); return(0); } @@ -99,7 +99,7 @@ int main(int argc,char **argv) return(0); } csp = getsp(); - printf("\n\nThe data read: (%d bytes, sp = %d)\n",lr,csp); + printf("\n\nThe data read: (%d bytes, c_sp = %d)\n",lr,csp); for (i=0; i