Optimize ldax?sp/sta/stx to ldptr1?sp

This commit is contained in:
Colin Leroy-Mira
2025-07-20 12:24:24 +02:00
parent 5fc300b987
commit 17b8645360
5 changed files with 103 additions and 0 deletions

20
libsrc/runtime/ldptr1sp.s Normal file
View File

@@ -0,0 +1,20 @@
;
; Ullrich von Bassewitz, 31.08.1998
;
; CC65 runtime: Load ptr1 from offset in stack
;
.export ldptr10sp, ldptr1ysp
.importzp c_sp, ptr1
; Beware: The optimizer knows about the value in Y after return!
ldptr10sp:
ldy #1
ldptr1ysp:
lda (c_sp),y ; get high byte
sta ptr1+1 ; and save it
dey ; point to lo byte
lda (c_sp),y ; load low byte
sta ptr1
rts