1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-11 11:30:13 +00:00

Added some 65C02 code.

git-svn-id: svn://svn.cc65.org/cc65/trunk@484 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2000-11-27 22:59:03 +00:00
parent 5be5b3763b
commit b4163d0e4e
11 changed files with 149 additions and 80 deletions

View File

@ -13,13 +13,18 @@
tosadda0: tosadda0:
ldx #0 ldx #0
tosaddax: tosaddax:
ldy #0 clc
clc .ifpc02
adc (sp),y ; lo byte adc (sp) ; 65C02 version - saves 2 cycles
ldy #1
.else
ldy #0
adc (sp),y ; lo byte
iny
.endif
pha ; save it pha ; save it
txa txa
iny adc (sp),y ; hi byte
adc (sp),y ; hi byte
tax tax
clc clc
lda sp lda sp

View File

@ -11,13 +11,18 @@
tosanda0: tosanda0:
ldx #$00 ldx #$00
tosandax: tosandax:
ldy #0 .ifpc02
and (sp) ; 65C02 version, saves 2 cycles and 1 byte
ldy #1
.else
ldy #0
and (sp),y and (sp),y
sta ptr4 iny
iny .endif
txa pha
and (sp),y txa
and (sp),y
tax tax
lda ptr4 pla
jmp addysp1 ; drop TOS, set condition codes jmp addysp1 ; drop TOS, set condition codes

View File

@ -11,6 +11,7 @@
; libinit and libdone call condes with the predefined module constructor and ; libinit and libdone call condes with the predefined module constructor and
; destructor tables, they must be called from the platform specific startup ; destructor tables, they must be called from the platform specific startup
; code. ; code.
; ;
; The function does also export jmpvec as general purpose jump vector that ; The function does also export jmpvec as general purpose jump vector that
; lies in the data segment so it's address may be patched at runtime. ; lies in the data segment so it's address may be patched at runtime.
@ -73,7 +74,11 @@ loop: ldy index
sta jmpvec+1 sta jmpvec+1
sty index sty index
jsr jmpvec jsr jmpvec
jmp loop .ifpc02
bra loop
.else
jmp loop
.endif
done: rts done: rts

View File

@ -10,8 +10,13 @@
.proc incax1 .proc incax1
add #1 .ifpc02
bcc @L9 ina ; 65C02 version
bne @L9
.else
add #1
bcc @L9
.endif
inx inx
@L9: rts @L9: rts

View File

@ -16,6 +16,10 @@ ldau0ysp:
lda (sp),y lda (sp),y
sta ptr1 sta ptr1
ldx #0 ldx #0
lda (ptr1,x) .ifpc02
lda (ptr1) ; Save one cycle for the C02
.else
lda (ptr1,x)
.endif
rts rts

View File

@ -7,16 +7,18 @@
.export inceaxy .export inceaxy
.importzp ptr4, sreg .importzp ptr4, sreg
inceaxy: .proc inceaxy
sty ptr4 sty ptr4
clc clc
adc ptr4 adc ptr4
bcc inceax9 bcc @L9
inx inx
bne inceax9 bne @L9
inc sreg inc sreg
bne inceax9 bne @L9
inc sreg+1 inc sreg+1
inceax9: @L9: rts
rts
.endproc

View File

@ -21,11 +21,16 @@ pushax: ldy sp
beq @L2 beq @L2
dey dey
@L0: sty sp @L0: sty sp
ldy #0 ; get index .ifpc02
sta (sp),y ; store lo byte sta (sp) ; 65C02 version - saves 2 cycles and one byte
pha ; save it ldy #1 ; get hi index
txa ; get hi byte .else
iny ; bump idx ldy #0 ; get index
sta (sp),y ; store lo byte
iny ; bump idx
.endif
pha ; save it
txa ; get hi byte
sta (sp),y ; store hi byte sta (sp),y ; store hi byte
pla ; get A back pla ; get A back
rts ; done rts ; done
@ -33,6 +38,10 @@ pushax: ldy sp
@L1: dey @L1: dey
@L2: dey @L2: dey
dec sp+1 dec sp+1
.ifpc02
bra @L0
.else
jmp @L0 jmp @L0
.endif

View File

@ -6,7 +6,7 @@
.export pushb, pushbidx .export pushb, pushbidx
.import pushax .import pushax
.importzp ptr1 .importzp ptr1
pushbidx: pushbidx:
sty ptr1 sty ptr1
@ -17,7 +17,11 @@ pushbidx:
pushb: sta ptr1 pushb: sta ptr1
stx ptr1+1 stx ptr1+1
ldx #0 ; Load index/high byte ldx #0 ; Load index/high byte
lda (ptr1,x) .ifpc02
lda (ptr1) ; Save one cycle for the C02
.else
lda (ptr1,x)
.endif
bpl L1 bpl L1
dex ; Make high byte FF dex ; Make high byte FF
L1: jmp pushax L1: jmp pushax

View File

@ -1,4 +1,4 @@
; ;
; Ullrich von Bassewitz, 25.10.2000 ; Ullrich von Bassewitz, 25.10.2000
; ;
; CC65 runtime: Store a/x indirect into address at top of stack ; CC65 runtime: Store a/x indirect into address at top of stack
@ -10,18 +10,31 @@
.proc staxspp .proc staxspp
ldy #0 .ifpc02
pha pha
lda (sp),y lda (sp)
sta ptr1 sta ptr1
iny ldy #1
lda (sp),y lda (sp),y
sta ptr1+1 sta ptr1+1
txa txa
sta (ptr1),y sta (ptr1),y
pla pla
dey sta (ptr1)
sta (ptr1),y .else
pha
ldy #0
lda (sp),y
sta ptr1
iny
lda (sp),y
sta ptr1+1
txa
sta (ptr1),y
pla
dey
sta (ptr1),y
.endif
jmp incsp2 ; Drop address jmp incsp2 ; Drop address
.endproc .endproc

View File

@ -10,15 +10,22 @@
; Convert TOS from long to int by cutting of the high 16bit ; Convert TOS from long to int by cutting of the high 16bit
tosint: pha .proc tosint
ldy #0
lda (sp),y ; sp+1 pha
ldy #2 .ifpc02
sta (sp),y lda (sp)
ldy #1 .else
lda (sp),y ldy #0
ldy #3 lda (sp),y ; sp+1
sta (sp),y .endif
ldy #2
sta (sp),y
dey
lda (sp),y
ldy #3
sta (sp),y
pla pla
jmp incsp2 ; Drop 16 bit jmp incsp2 ; Drop 16 bit
.endproc

View File

@ -13,40 +13,50 @@
tosulong: tosulong:
pha pha
jsr decsp2 ; Make room jsr decsp2 ; Make room
ldy #2 ldy #2
lda (sp),y lda (sp),y
ldy #0 .ifpc02
sta (sp) ; 65C02 version
iny ; Y = 3
.else
ldy #0
sta (sp),y sta (sp),y
ldy #3 ldy #3
lda (sp),y .endif
ldy #1 lda (sp),y
sta (sp),y ldy #1
lda #0 ; Zero extend sta (sp),y
lda #0 ; Zero extend
toslong2: toslong2:
iny iny
sta (sp),y sta (sp),y
iny iny
sta (sp),y sta (sp),y
pla pla
rts rts
toslong: toslong:
pha pha
jsr decsp2 ; Make room jsr decsp2 ; Make room
ldy #2 ldy #2
lda (sp),y lda (sp),y
ldy #0 .ifpc02
sta (sp) ; 65C02 version
iny ; Y = 3
.else
ldy #0
sta (sp),y sta (sp),y
ldy #3 ldy #3
lda (sp),y .endif
bmi toslong1 lda (sp),y
ldy #1 bmi toslong1
sta (sp),y ldy #1
lda #$00 ; Positive, high word is zero sta (sp),y
bne toslong2 lda #$00 ; Positive, high word is zero
bne toslong2
toslong1: toslong1:
ldy #1 ldy #1
sta (sp),y sta (sp),y
lda #$FF lda #$FF
bne toslong2 bne toslong2