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,6 +11,8 @@
.include "errno.inc" .include "errno.inc"
.macpack cpu
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
.proc _atexit .proc _atexit
@ -63,7 +65,7 @@
lda exitfunc_table,y lda exitfunc_table,y
sty exitfunc_index sty exitfunc_index
jsr callax ; Call the function jsr callax ; Call the function
.ifpc02 .if (.cpu .bitand ::CPU_ISET_65SC02)
bra doatexit bra doatexit
.else .else
jmp doatexit ; Next one jmp doatexit ; Next one

View file

@ -11,6 +11,7 @@
.import _strlen, _malloc, _memcpy .import _strlen, _malloc, _memcpy
.export _strdup .export _strdup
.macpack cpu
.macpack generic .macpack generic
_strdup: _strdup:
@ -28,7 +29,7 @@ _strdup:
txa txa
sta (sp),y sta (sp),y
pla pla
.ifpc02 .if (.cpu .bitand CPU_ISET_65SC02)
sta (sp) sta (sp)
.else .else
dey dey

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -8,6 +8,8 @@
.import pushax .import pushax
.importzp ptr1 .importzp ptr1
.macpack cpu
pushbidx: pushbidx:
sty ptr1 sty ptr1
clc clc
@ -17,7 +19,7 @@ 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
.ifpc02 .if (.cpu .bitand CPU_ISET_65SC02)
lda (ptr1) ; Save one cycle for the C02 lda (ptr1) ; Save one cycle for the C02
.else .else
lda (ptr1,x) lda (ptr1,x)

View file

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

View file

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

View file

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