mirror of
https://github.com/cc65/cc65.git
synced 2024-12-27 00:29:31 +00:00
New functions to swap register variables
git-svn-id: svn://svn.cc65.org/cc65/trunk@1629 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
da44e7ae4b
commit
e1385c925a
@ -159,6 +159,9 @@ OBJS = add.o \
|
||||
pushlysp.o \
|
||||
pushw.o \
|
||||
pushwsp.o \
|
||||
regswap.o \
|
||||
regswap1.o \
|
||||
regswap2.o \
|
||||
return0.o \
|
||||
return1.o \
|
||||
rsub.o \
|
||||
|
28
libsrc/runtime/regswap.s
Normal file
28
libsrc/runtime/regswap.s
Normal file
@ -0,0 +1,28 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 25.11.2002
|
||||
;
|
||||
; CC65 runtime: Swap x bytes of register variable space
|
||||
;
|
||||
|
||||
.export regswap
|
||||
.importzp 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
|
||||
sta regbank,x ; Store new value
|
||||
pla
|
||||
sta (sp),y ; Store old value
|
||||
inx
|
||||
iny
|
||||
dec tmp1
|
||||
bne @L1
|
||||
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
22
libsrc/runtime/regswap1.s
Normal file
22
libsrc/runtime/regswap1.s
Normal file
@ -0,0 +1,22 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 25.11.2002
|
||||
;
|
||||
; CC65 runtime: Swap 1 byte of register variable space
|
||||
;
|
||||
|
||||
.export regswap1
|
||||
.importzp sp, regbank
|
||||
|
||||
.proc regswap1
|
||||
|
||||
lda regbank,x ; Get old value
|
||||
pha ; Save it
|
||||
lda (sp),y ; Get stack loc
|
||||
sta regbank,x ; Store new value
|
||||
pla
|
||||
sta (sp),y ; Store old value
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
35
libsrc/runtime/regswap2.s
Normal file
35
libsrc/runtime/regswap2.s
Normal file
@ -0,0 +1,35 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 25.11.2002
|
||||
;
|
||||
; CC65 runtime: Swap 2 bytes of register variable space
|
||||
;
|
||||
|
||||
.export regswap2
|
||||
.importzp sp, regbank
|
||||
|
||||
.proc regswap2
|
||||
|
||||
; First byte
|
||||
|
||||
lda regbank,x ; Get old value
|
||||
pha ; Save it
|
||||
lda (sp),y ; Get stack loc
|
||||
sta regbank,x ; Store new value
|
||||
pla
|
||||
sta (sp),y ; Store old value
|
||||
|
||||
; Second byte
|
||||
|
||||
iny
|
||||
lda regbank+1,x ; Get old value
|
||||
pha ; Save it
|
||||
lda (sp),y ; Get stack loc
|
||||
sta regbank+1,x ; Store new value
|
||||
pla
|
||||
sta (sp),y ; Store old value
|
||||
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user