pushlysp.o \
pushw.o \
pushwsp.o \
+ regswap.o \
+ regswap1.o \
+ regswap2.o \
return0.o \
return1.o \
rsub.o \
--- /dev/null
+;
+; 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
+
+
--- /dev/null
+;
+; 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
+
+
--- /dev/null
+;
+; 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
+
+