2002-11-25 12:38:38 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 25.11.2002
|
|
|
|
;
|
|
|
|
; CC65 runtime: Swap 2 bytes of register variable space
|
|
|
|
;
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export regswap2
|
|
|
|
.importzp sp, regbank
|
2002-11-25 12:38:38 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.proc regswap2
|
2002-11-25 12:38:38 +00:00
|
|
|
|
|
|
|
; 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
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
rts
|
2002-11-25 12:38:38 +00:00
|
|
|
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
|