1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-15 02:29:32 +00:00

few 6502 and some 65SC02 optimizations

This commit is contained in:
IrgendwerA8 2017-03-12 23:21:43 +01:00
parent 0ec4534bd6
commit 0de44517ac
23 changed files with 272 additions and 78 deletions

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 05.08.1998 ; Ullrich von Bassewitz, 05.08.1998
; Christian Krueger, 11-Mar-2017, spend two bytes for one cycle, improved 65SC02 optimization
; ;
; CC65 runtime: add ints ; CC65 runtime: add ints
; ;
@ -8,32 +9,46 @@
; called a lot! ; called a lot!
.export tosadda0, tosaddax .export tosadda0, tosaddax
.importzp sp .importzp sp, tmp1
.macpack cpu .macpack cpu
tosadda0: tosadda0:
ldx #0 ldx #0
tosaddax: tosaddax:
clc clc ; (2)
.if (.cpu .bitand CPU_ISET_65SC02)
adc (sp) ; 65SC02 version - saves 2 cycles
ldy #1
.else
ldy #0
adc (sp),y ; lo byte
iny
.endif
pha ; save it
txa
adc (sp),y ; hi byte
tax
clc
lda sp
adc #2
sta sp
bcc L1
inc sp+1
L1: pla ; Restore low byte
rts
.if (.cpu .bitand ::CPU_ISET_65SC02)
adc (sp) ; (7)
tay ; (9)
inc sp ; (14)
bne hiadd ; (17)
inc sp+1 ; (-1+5)
hiadd: txa ; (19)
adc (sp) ; (24)
tax ; (26)
inc sp ; (31)
bne done ; (34)
inc sp+1 ; (-1+5)
done: tya ; (36)
.else
ldy #0 ; (4)
adc (sp),y ; (9) lo byte
iny ; (11)
sta tmp1 ; (14) save it
txa ; (16)
adc (sp),y ; (21) hi byte
tax ; (23)
clc ; (25)
lda sp ; (28)
adc #2 ; (30)
sta sp ; (33)
bcc L1 ; (36)
inc sp+1 ; (-1+5)
L1: lda tmp1 ; (39) restore low byte
.endif
rts ; (6502: 45 cycles, 26 bytes <-> 65SC02: 42 cycles, 22 bytes )

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 23.11.2002 ; Ullrich von Bassewitz, 23.11.2002
; Christian Krueger, 11-Mar-2017, saved 5 bytes
; ;
; CC65 runtime: Convert char in ax into a long ; CC65 runtime: Convert char in ax into a long
; ;
@ -9,16 +10,12 @@
; Convert A from char to long in EAX ; Convert A from char to long in EAX
along: ldx #$ff
cmp #$80 ; Positive?
bcs store ; no, apply $FF
aulong: ldx #0 aulong: ldx #0
stx sreg store: stx sreg
stx sreg+1 stx sreg+1
rts rts
along: cmp #$80 ; Positive?
bcc aulong ; Yes, handle like unsigned type
ldx #$ff
stx sreg
stx sreg+1
rts

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 07.04.2000 ; Ullrich von Bassewitz, 07.04.2000
; Christian Krueger, 12-Mar-2017, added 65SC02 optimization
; ;
; CC65 runtime: += operator ; CC65 runtime: += operator
; ;
@ -10,6 +11,7 @@
.export laddeq1, laddeqa, laddeq .export laddeq1, laddeqa, laddeq
.importzp sreg, ptr1, tmp1 .importzp sreg, ptr1, tmp1
.macpack cpu
laddeq1: laddeq1:
lda #$01 lda #$01
@ -20,14 +22,20 @@ laddeqa:
stx sreg+1 stx sreg+1
laddeq: sty ptr1+1 ; Store high byte of address laddeq: sty ptr1+1 ; Store high byte of address
ldy #$00 ; Address low byte
clc clc
.if (.cpu .bitand ::CPU_ISET_65SC02)
adc (ptr1)
sta (ptr1)
ldy #$01 ; Address byte 1
.else
ldy #$00 ; Address low byte
adc (ptr1),y adc (ptr1),y
sta (ptr1),y sta (ptr1),y
iny ; Address byte 1
.endif
pha ; Save byte 0 of result for later pha ; Save byte 0 of result for later
iny ; Address byte 1
txa txa
adc (ptr1),y ; Load byte 1 adc (ptr1),y ; Load byte 1
sta (ptr1),y sta (ptr1),y

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 06.08.1998 ; Ullrich von Bassewitz, 06.08.1998
; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
; ;
; CC65 runtime: and on longs ; CC65 runtime: and on longs
; ;
@ -8,17 +9,28 @@
.import addysp1 .import addysp1
.importzp sp, sreg, tmp1 .importzp sp, sreg, tmp1
.macpack cpu
tosand0ax: tosand0ax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
stz sreg
stz sreg+1
.else
ldy #$00 ldy #$00
sty sreg sty sreg
sty sreg+1 sty sreg+1
.endif
tosandeax: tosandeax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
and (sp) ; byte 0
ldy #1
.else
ldy #0 ldy #0
and (sp),y ; byte 0 and (sp),y ; byte 0
sta tmp1
iny iny
.endif
sta tmp1
txa txa
and (sp),y ; byte 1 and (sp),y ; byte 1
tax tax

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 06.08.1998 ; Ullrich von Bassewitz, 06.08.1998
; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
; ;
; CC65 runtime: function epilogue ; CC65 runtime: function epilogue
; ;
@ -13,6 +14,8 @@
.import addysp .import addysp
.importzp sp .importzp sp
.macpack cpu
leave00: leave00:
lda #0 lda #0
leave0: ldx #0 leave0: ldx #0
@ -24,6 +27,20 @@ leavey0:
ldx #0 ; return < 256 ldx #0 ; return < 256
leavey: leavey:
jsr addysp ; drop stack frame jsr addysp ; drop stack frame
.if (.cpu .bitand ::CPU_ISET_65SC02)
leave: tay ; save A a sec
lda (sp) ; that's the pushed arg size
sec ; Count the byte, the count's stored in
adc sp
sta sp
bcc L1
inc sp+1
L1: tya ; Get return value back
.else
leave: pha ; save A a sec leave: pha ; save A a sec
ldy #0 ldy #0
lda (sp),y ; that's the pushed arg size lda (sp),y ; that's the pushed arg size
@ -33,5 +50,7 @@ leave: pha ; save A a sec
bcc L1 bcc L1
inc sp+1 inc sp+1
L1: pla ; Get return value back L1: pla ; Get return value back
.endif
rts rts

View File

@ -1,6 +1,6 @@
; ;
; Ullrich von Bassewitz, 07.08.1998 ; Ullrich von Bassewitz, 07.08.1998
; ; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
; CC65 runtime: modulo operation for long signed ints ; CC65 runtime: modulo operation for long signed ints
; ;
@ -11,10 +11,17 @@
.import poplsargs, udiv32, negeax .import poplsargs, udiv32, negeax
.importzp sreg, ptr1, ptr2, tmp1, tmp3, tmp4 .importzp sreg, ptr1, ptr2, tmp1, tmp3, tmp4
.macpack cpu
tosmod0ax: tosmod0ax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
stz sreg
stz sreg+1
.else
ldy #$00 ldy #$00
sty sreg sty sreg
sty sreg+1 sty sreg+1
.endif
tosmodeax: tosmodeax:
jsr poplsargs ; Get arguments from stack, adjust sign jsr poplsargs ; Get arguments from stack, adjust sign

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 13.08.1998 ; Ullrich von Bassewitz, 13.08.1998
; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
; ;
; CC65 runtime: multiplication for long (unsigned) ints ; CC65 runtime: multiplication for long (unsigned) ints
; ;
@ -8,20 +9,32 @@
.import addysp1 .import addysp1
.importzp sp, sreg, tmp1, tmp2, tmp3, tmp4, ptr1, ptr3, ptr4 .importzp sp, sreg, tmp1, tmp2, tmp3, tmp4, ptr1, ptr3, ptr4
.macpack cpu
tosmul0ax: tosmul0ax:
tosumul0ax: tosumul0ax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
stz sreg
stz sreg+1
.else
ldy #$00 ldy #$00
sty sreg sty sreg
sty sreg+1 sty sreg+1
.endif
tosmuleax: tosmuleax:
tosumuleax: tosumuleax:
mul32: sta ptr1 mul32: sta ptr1
stx ptr1+1 ; op2 now in ptr1/sreg stx ptr1+1 ; op2 now in ptr1/sreg
.if (.cpu .bitand ::CPU_ISET_65SC02)
lda (sp)
ldy #1
.else
ldy #0 ldy #0
lda (sp),y lda (sp),y
sta ptr3
iny iny
.endif
sta ptr3
lda (sp),y lda (sp),y
sta ptr3+1 sta ptr3+1
iny iny

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 06.08.1998 ; Ullrich von Bassewitz, 06.08.1998
; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
; ;
; CC65 runtime: or on longs ; CC65 runtime: or on longs
; ;
@ -8,17 +9,28 @@
.import addysp1 .import addysp1
.importzp sp, sreg, tmp1 .importzp sp, sreg, tmp1
.macpack cpu
tosor0ax: tosor0ax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
stz sreg
stz sreg+1
.else
ldy #$00 ldy #$00
sty sreg sty sreg
sty sreg+1 sty sreg+1
.endif
tosoreax: tosoreax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
ora (sp)
ldy #1
.else
ldy #0 ldy #0
ora (sp),y ; byte 0 ora (sp),y ; byte 0
sta tmp1
iny iny
.endif
sta tmp1
txa txa
ora (sp),y ; byte 1 ora (sp),y ; byte 1
tax tax

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 29.12.1999 ; Ullrich von Bassewitz, 29.12.1999
; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
; ;
; CC65 runtime: long pop ; CC65 runtime: long pop
; ;
@ -8,6 +9,7 @@
.import incsp4 .import incsp4
.importzp sp, sreg .importzp sp, sreg
.macpack cpu
popeax: ldy #3 popeax: ldy #3
lda (sp),y lda (sp),y
@ -18,8 +20,12 @@ popeax: ldy #3
dey dey
lda (sp),y lda (sp),y
tax tax
.if (.cpu .bitand ::CPU_ISET_65SC02)
lda (sp)
.else
dey dey
lda (sp),y lda (sp),y
.endif
jmp incsp4 jmp incsp4

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 06.08.1998 ; Ullrich von Bassewitz, 06.08.1998
; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
; ;
; CC65 runtime: long push ; CC65 runtime: long push
; ;
@ -11,13 +12,20 @@
.import decsp4 .import decsp4
.importzp sp, sreg .importzp sp, sreg
.macpack cpu
pushl0: pushl0:
lda #0 lda #0
tax tax
push0ax: push0ax:
ldy #0 .if (.cpu .bitand ::CPU_ISET_65SC02)
stz sreg
stz sreg+1
.else
ldy #$00
sty sreg sty sreg
sty sreg+1 sty sreg+1
.endif
pusheax: pusheax:
pha ; decsp will destroy A (but not X) pha ; decsp will destroy A (but not X)
jsr decsp4 jsr decsp4
@ -30,8 +38,12 @@ pusheax:
dey dey
txa txa
sta (sp),y sta (sp),y
dey
pla pla
.if (.cpu .bitand ::CPU_ISET_65SC02)
sta (sp)
.else
dey
sta (sp),y sta (sp),y
.endif
rts rts

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 05.08.1998 ; Ullrich von Bassewitz, 05.08.1998
; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
; ;
; CC65 runtime: long sub reversed ; CC65 runtime: long sub reversed
; ;
@ -11,18 +12,30 @@
.import addysp1 .import addysp1
.importzp sp, sreg, tmp1 .importzp sp, sreg, tmp1
.macpack cpu
tosrsub0ax: tosrsub0ax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
stz sreg
stz sreg+1
.else
ldy #$00 ldy #$00
sty sreg sty sreg
sty sreg+1 sty sreg+1
.endif
tosrsubeax: tosrsubeax:
ldy #0
sec sec
.if (.cpu .bitand ::CPU_ISET_65SC02)
sbc (sp)
ldy #1
.else
ldy #0
sbc (sp),y ; byte 0 sbc (sp),y ; byte 0
iny
.endif
sta tmp1 ; use as temp storage sta tmp1 ; use as temp storage
txa txa
iny
sbc (sp),y ; byte 1 sbc (sp),y ; byte 1
tax tax
iny iny

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 08.08.1998 ; Ullrich von Bassewitz, 08.08.1998
; Christian Krueger, 11-Mar-2017, optimization
; ;
; CC65 runtime: save ax into temp storage/restore ax from temp storage ; CC65 runtime: save ax into temp storage/restore ax from temp storage
; ;
@ -10,11 +11,10 @@
saveeax: saveeax:
sta regsave sta regsave
stx regsave+1 stx regsave+1
lda sreg ldy sreg
sta regsave+2 sty regsave+2
lda sreg+1 ldy sreg+1
sta regsave+3 sty regsave+3
lda regsave
rts rts
resteax: resteax:

View File

@ -1,6 +1,6 @@
; ;
; Ullrich von Bassewitz, 05.08.1998 ; Ullrich von Bassewitz, 05.08.1998
; ; Christian Krueger, 11-Mar-2017, ímproved 65SC02 optimization
; CC65 runtime: long sub ; CC65 runtime: long sub
; ;
@ -14,14 +14,19 @@
.macpack cpu .macpack cpu
tossub0ax: tossub0ax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
stz sreg
stz sreg+1
.else
ldy #$00 ldy #$00
sty sreg sty sreg
sty sreg+1 sty sreg+1
.endif
tossubeax: tossubeax:
sec sec
eor #$FF eor #$FF
.if (.cpu .bitand CPU_ISET_65SC02) .if (.cpu .bitand ::CPU_ISET_65SC02)
adc (sp) ; 65SC02 version - saves 2 cycles adc (sp) ; 65SC02 version - saves 2 cycles
ldy #1 ldy #1
.else .else

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 07.04.2000 ; Ullrich von Bassewitz, 07.04.2000
; Christian Krueger, 12-Mar-2017, added 65SC02 optimization
; ;
; CC65 runtime: -= operator ; CC65 runtime: -= operator
; ;
@ -10,6 +11,7 @@
.export lsubeq1, lsubeqa, lsubeq .export lsubeq1, lsubeqa, lsubeq
.importzp sreg, ptr1 .importzp sreg, ptr1
.macpack cpu
lsubeq1: lsubeq1:
lda #$01 lda #$01
@ -20,15 +22,20 @@ lsubeqa:
stx sreg+1 stx sreg+1
lsubeq: sty ptr1+1 ; Store high byte of address lsubeq: sty ptr1+1 ; Store high byte of address
ldy #$00 ; Address low byte
sec sec
eor #$FF eor #$FF
.if (.cpu .bitand ::CPU_ISET_65SC02)
adc (ptr1) ; Subtract byte 0
sta (ptr1)
ldy #$01 ; Address byte 1
.else
ldy #$00 ; Address low byte
adc (ptr1),y ; Subtract byte 0 adc (ptr1),y ; Subtract byte 0
sta (ptr1),y sta (ptr1),y
iny ; Address byte 1
.endif
pha ; Save byte 0 of result for later pha ; Save byte 0 of result for later
iny ; Address byte 1
txa txa
eor #$FF eor #$FF
adc (ptr1),y ; Subtract byte 1 adc (ptr1),y ; Subtract byte 1

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 17.08.1998 ; Ullrich von Bassewitz, 17.08.1998
; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
; ;
; CC65 runtime: division for long unsigned ints ; CC65 runtime: division for long unsigned ints
; ;
@ -8,10 +9,17 @@
.import addysp1 .import addysp1
.importzp sp, sreg, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4 .importzp sp, sreg, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4
.macpack cpu
tosudiv0ax: tosudiv0ax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
stz sreg
stz sreg+1
.else
ldy #$00 ldy #$00
sty sreg sty sreg
sty sreg+1 sty sreg+1
.endif
tosudiveax: tosudiveax:
jsr getlop ; Get the paramameters jsr getlop ; Get the paramameters
@ -30,10 +38,15 @@ getlop: sta ptr3 ; Put right operand in place
lda sreg+1 lda sreg+1
sta ptr4+1 sta ptr4+1
.if (.cpu .bitand ::CPU_ISET_65SC02)
lda (sp)
ldy #1
.else
ldy #0 ; Put left operand in place ldy #0 ; Put left operand in place
lda (sp),y lda (sp),y
sta ptr1
iny iny
.endif
sta ptr1
lda (sp),y lda (sp),y
sta ptr1+1 sta ptr1+1
iny iny

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 27.09.1998 ; Ullrich von Bassewitz, 27.09.1998
; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
; ;
; CC65 runtime: modulo operation for long unsigned ints ; CC65 runtime: modulo operation for long unsigned ints
; ;
@ -8,10 +9,17 @@
.import getlop, udiv32 .import getlop, udiv32
.importzp sreg, tmp3, tmp4, ptr2 .importzp sreg, tmp3, tmp4, ptr2
.macpack cpu
tosumod0ax: tosumod0ax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
stz sreg
stz sreg+1
.else
ldy #$00 ldy #$00
sty sreg sty sreg
sty sreg+1 sty sreg+1
.endif
tosumodeax: tosumodeax:
jsr getlop ; Get the paramameters jsr getlop ; Get the paramameters

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 06.08.1998 ; Ullrich von Bassewitz, 06.08.1998
; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
; ;
; CC65 runtime: xor on longs ; CC65 runtime: xor on longs
; ;
@ -8,16 +9,28 @@
.import addysp1 .import addysp1
.importzp sp, sreg, tmp1 .importzp sp, sreg, tmp1
.macpack cpu
tosxor0ax: tosxor0ax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
stz sreg
stz sreg+1
.else
ldy #$00 ldy #$00
sty sreg sty sreg
sty sreg+1 sty sreg+1
.endif
tosxoreax: tosxoreax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
eor (sp) ; byte 0
ldy #1
.else
ldy #0 ldy #0
eor (sp),y ; byte 0 eor (sp),y ; byte 0
sta tmp1
iny iny
.endif
sta tmp1
txa txa
eor (sp),y ; byte 1 eor (sp),y ; byte 1
tax tax

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 05.10.1998 ; Ullrich von Bassewitz, 05.10.1998
; Christian Krueger, 11-Mar-2017, optimization
; ;
; CC65 runtime: Make boolean according to flags ; CC65 runtime: Make boolean according to flags
; ;
@ -9,14 +10,14 @@
boolne: bne ret1 boolne: bne ret1
ldx #$00 ret0: ldx #$00
txa txa
rts rts
booleq: beq ret1 booleq: bne ret0
ldx #$00 ret1: ldx #$00
txa lda #$01
rts rts
@ -44,17 +45,9 @@ boolult:
boolugt: boolugt:
beq L1 beq ret0
booluge: booluge:
bcs ret1 ldx #$00
L1: ldx #$00
txa txa
rol a
rts rts
ret1: ldx #$00
lda #$01
rts

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 05.08.1998 ; Ullrich von Bassewitz, 05.08.1998
; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
; ;
; CC65 runtime: or on ints ; CC65 runtime: or on ints
; ;
@ -8,13 +9,20 @@
.import addysp1 .import addysp1
.importzp sp, tmp1 .importzp sp, tmp1
.macpack cpu
tosora0: tosora0:
ldx #$00 ldx #$00
tosorax: tosorax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
ora (sp)
ldy #1
.else
ldy #0 ldy #0
ora (sp),y ora (sp),y
sta tmp1
iny iny
.endif
sta tmp1
txa txa
ora (sp),y ora (sp),y
tax tax

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 05.08.1998 ; Ullrich von Bassewitz, 05.08.1998
; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
; ;
; CC65 runtime: sub ints reversed ; CC65 runtime: sub ints reversed
; ;
@ -8,6 +9,8 @@
.import addysp1 .import addysp1
.importzp sp, tmp1 .importzp sp, tmp1
.macpack cpu
; ;
; AX = AX - TOS ; AX = AX - TOS
; ;
@ -15,12 +18,17 @@
tosrsuba0: tosrsuba0:
ldx #0 ldx #0
tosrsubax: tosrsubax:
ldy #0
sec sec
.if (.cpu .bitand CPU_ISET_65SC02)
sbc (sp)
ldy #1
.else
ldy #0
sbc (sp),y ; lo byte sbc (sp),y ; lo byte
iny
.endif
sta tmp1 ; save lo byte sta tmp1 ; save lo byte
txa txa
iny
sbc (sp),y ; hi byte sbc (sp),y ; hi byte
tax tax
lda tmp1 lda tmp1

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 26.10.2000 ; Ullrich von Bassewitz, 26.10.2000
; Christian Krueger, 12-Mar-2017, added 65SC02 optimization
; ;
; CC65 runtime: Store a/x indirect into address at top of stack with index ; CC65 runtime: Store a/x indirect into address at top of stack with index
; ;
@ -8,6 +9,8 @@
.import incsp2 .import incsp2
.importzp sp, tmp1, ptr1 .importzp sp, tmp1, ptr1
.macpack cpu
.proc staxspidx .proc staxspidx
sty tmp1 ; Save Y sty tmp1 ; Save Y
@ -15,8 +18,12 @@
ldy #1 ldy #1
lda (sp),y lda (sp),y
sta ptr1+1 sta ptr1+1
.if (.cpu .bitand ::CPU_ISET_65SC02)
lda (sp)
.else
dey dey
lda (sp),y lda (sp),y
.endif
sta ptr1 ; Address now in ptr1 sta ptr1 ; Address now in ptr1
ldy tmp1 ; Restore Y ldy tmp1 ; Restore Y
iny ; Address high byte iny ; Address high byte

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 06.08.1998 ; Ullrich von Bassewitz, 06.08.1998
; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
; ;
; CC65 runtime: swap ax with TOS ; CC65 runtime: swap ax with TOS
; ;
@ -7,6 +8,8 @@
.export swapstk .export swapstk
.importzp sp, ptr4 .importzp sp, ptr4
.macpack cpu
swapstk: swapstk:
sta ptr4 sta ptr4
stx ptr4+1 stx ptr4+1
@ -15,11 +18,18 @@ swapstk:
tax tax
lda ptr4+1 lda ptr4+1
sta (sp),y sta (sp),y
.if (.cpu .bitand ::CPU_ISET_65SC02)
lda (sp)
tay
lda ptr4
sta (sp)
tya
.else
dey dey
lda (sp),y lda (sp),y
pha pha
lda ptr4 lda ptr4
sta (sp),y sta (sp),y
pla pla
.endif
rts ; whew! rts ; whew!

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 05.08.1998 ; Ullrich von Bassewitz, 05.08.1998
; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
; ;
; CC65 runtime: xor on ints ; CC65 runtime: xor on ints
; ;
@ -8,13 +9,20 @@
.import addysp1 .import addysp1
.importzp sp, tmp1 .importzp sp, tmp1
.macpack cpu
tosxora0: tosxora0:
ldx #$00 ldx #$00
tosxorax: tosxorax:
.if (.cpu .bitand CPU_ISET_65SC02)
eor (sp)
ldy #1
.else
ldy #0 ldy #0
eor (sp),y eor (sp),y
sta tmp1
iny iny
.endif
sta tmp1
txa txa
eor (sp),y eor (sp),y
tax tax