1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-23 19:29:37 +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:
ldx #0
tosaddax:
ldy #0
clc
adc (sp),y ; lo byte
clc
.ifpc02
adc (sp) ; 65C02 version - saves 2 cycles
ldy #1
.else
ldy #0
adc (sp),y ; lo byte
iny
.endif
pha ; save it
txa
iny
adc (sp),y ; hi byte
txa
adc (sp),y ; hi byte
tax
clc
lda sp

View File

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

View File

@ -11,6 +11,7 @@
; libinit and libdone call condes with the predefined module constructor and
; destructor tables, they must be called from the platform specific startup
; code.
;
; 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.
@ -73,7 +74,11 @@ loop: ldy index
sta jmpvec+1
sty index
jsr jmpvec
jmp loop
.ifpc02
bra loop
.else
jmp loop
.endif
done: rts

View File

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

View File

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

View File

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

View File

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

View File

@ -6,7 +6,7 @@
.export pushb, pushbidx
.import pushax
.importzp ptr1
.importzp ptr1
pushbidx:
sty ptr1
@ -17,7 +17,11 @@ pushbidx:
pushb: sta ptr1
stx ptr1+1
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
dex ; Make high byte FF
L1: jmp pushax

View File

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

View File

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

View File

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