1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-25 02:29:52 +00:00

Improved 65c02 support

git-svn-id: svn://svn.cc65.org/cc65/trunk@2507 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2003-10-10 17:52:12 +00:00
parent 02d7d8faa7
commit 23c35f27f8
14 changed files with 51 additions and 29 deletions

View File

@ -11,13 +11,15 @@
.include "errno.inc"
.macpack cpu
; ---------------------------------------------------------------------------
.proc _atexit
ldy exitfunc_index
cpy #exitfunc_max ; Slot available?
beq @Error ; Jump if no
beq @Error ; Jump if no
; Enter the function into the table
@ -63,7 +65,7 @@
lda exitfunc_table,y
sty exitfunc_index
jsr callax ; Call the function
.ifpc02
.if (.cpu .bitand ::CPU_ISET_65SC02)
bra doatexit
.else
jmp doatexit ; Next one
@ -71,7 +73,7 @@
@L9: rts
.endproc
.endproc

View File

@ -11,6 +11,7 @@
.import _strlen, _malloc, _memcpy
.export _strdup
.macpack cpu
.macpack generic
_strdup:
@ -18,7 +19,7 @@ _strdup:
; Since we need some place to store the intermediate results, allocate a
; stack frame. To make this somewhat more efficient, create the stackframe
; as needed for the final call to the memcpy function.
pha ; decsp will destroy A (but not X)
jsr decsp4 ; Target/source
@ -27,8 +28,8 @@ _strdup:
ldy #1
txa
sta (sp),y
pla
.ifpc02
pla
.if (.cpu .bitand CPU_ISET_65SC02)
sta (sp)
.else
dey

View File

@ -10,12 +10,14 @@
.export tosadda0, tosaddax
.importzp sp
.macpack cpu
tosadda0:
ldx #0
tosaddax:
clc
.ifpc02
adc (sp) ; 65C02 version - saves 2 cycles
.if (.cpu .bitand CPU_ISET_65SC02)
adc (sp) ; 65SC02 version - saves 2 cycles
ldy #1
.else
ldy #0

View File

@ -8,11 +8,13 @@
.import addysp1
.importzp sp, ptr4
.macpack cpu
tosanda0:
ldx #$00
tosandax:
.ifpc02
and (sp) ; 65C02 version, saves 2 cycles and 1 byte
.if (.cpu .bitand CPU_ISET_65SC02)
and (sp) ; 65SC02 version, saves 2 cycles and 1 byte
ldy #1
.else
ldy #0

View File

@ -19,7 +19,7 @@
.import __CONSTRUCTOR_TABLE__, __CONSTRUCTOR_COUNT__
.import __DESTRUCTOR_TABLE__, __DESTRUCTOR_COUNT__
.macpack cpu
.code
@ -58,7 +58,7 @@
sta getbyt+1
stx getbyt+2
sty index
sty index
loop: ldy index
beq done
@ -69,7 +69,7 @@ loop: ldy index
jsr getbyt
sty index
jsr callax
.ifpc02
.if (.cpu .bitand ::CPU_ISET_65SC02)
bra loop
.else
jmp loop

View File

@ -7,10 +7,11 @@
.export incax1
.macpack generic
.macpack cpu
.proc incax1
.ifpc02
.if (.cpu .bitand ::CPU_ISET_65SC02)
ina ; 65C02 version
bne @L9
.else

View File

@ -7,14 +7,16 @@
.export popax, incsp2
.importzp sp
.macpack cpu
; Pop a/x from stack. This function will run directly into incsp2
.proc popax
ldy #1
lda (sp),y ; get hi byte
tax ; into x
.ifpc02
lda (sp),y ; get hi byte
tax ; into x
.if (.cpu .bitand ::CPU_ISET_65SC02)
lda (sp) ; get lo byte
.else
dey

View File

@ -7,6 +7,8 @@
.export ldau00sp, ldau0ysp
.importzp sp, ptr1
.macpack cpu
ldau00sp:
ldy #1
ldau0ysp:
@ -16,7 +18,7 @@ ldau0ysp:
lda (sp),y
sta ptr1
ldx #0
.ifpc02
.if (.cpu .bitand CPU_ISET_65SC02)
lda (ptr1) ; Save one cycle for the C02
.else
lda (ptr1,x)

View File

@ -7,9 +7,11 @@
.export popa
.importzp sp
.macpack cpu
.proc popa
.ifpc02
.if (.cpu .bitand ::CPU_ISET_65SC02)
lda (sp)
.else
ldy #0 ; (2)

View File

@ -7,6 +7,8 @@
.export pusha0sp, pushaysp, pusha
.importzp sp
.macpack cpu
; Beware: The optimizer knows about this function!
pusha0sp:
@ -16,7 +18,7 @@ pushaysp:
pusha: ldy sp ; (3)
beq @L1 ; (6)
dec sp ; (11)
.ifpc02
.if (.cpu .bitand CPU_ISET_65SC02)
sta (sp)
.else
ldy #0 ; (13)

View File

@ -8,6 +8,8 @@
.import pushax
.importzp ptr1
.macpack cpu
pushbidx:
sty ptr1
clc
@ -16,9 +18,9 @@ pushbidx:
inx
pushb: sta ptr1
stx ptr1+1
ldx #0 ; Load index/high byte
.ifpc02
lda (ptr1) ; Save one cycle for the C02
ldx #0 ; Load index/high byte
.if (.cpu .bitand CPU_ISET_65SC02)
lda (ptr1) ; Save one cycle for the C02
.else
lda (ptr1,x)
.endif

View File

@ -8,16 +8,16 @@
.import addysp1
.importzp sp
;
.macpack cpu
; AX = TOS - AX
;
tossuba0:
ldx #0
tossubax:
sec
eor #$FF
.ifpc02
.if (.cpu .bitand CPU_ISET_65SC02)
adc (sp)
ldy #1
.else

View File

@ -8,12 +8,14 @@
.import incsp2
.importzp sp
.macpack cpu
; Convert TOS from long to int by cutting of the high 16bit
.proc tosint
pha
.ifpc02
.if (.cpu .bitand ::CPU_ISET_65SC02)
lda (sp)
.else
ldy #0

View File

@ -8,6 +8,8 @@
.import decsp2
.importzp sp
.macpack cpu
; Convert TOS from int to long
tosulong:
@ -15,7 +17,7 @@ tosulong:
jsr decsp2 ; Make room
ldy #2
lda (sp),y
.ifpc02
.if (.cpu .bitand CPU_ISET_65SC02)
sta (sp) ; 65C02 version
iny ; Y = 3
.else
@ -41,7 +43,7 @@ toslong:
jsr decsp2 ; Make room
ldy #2
lda (sp),y
.ifpc02
.if (.cpu .bitand CPU_ISET_65SC02)
sta (sp) ; 65C02 version
iny ; Y = 3
.else