From: cuz Date: Fri, 10 Oct 2003 17:52:12 +0000 (+0000) Subject: Improved 65c02 support X-Git-Tag: V2.12.0~1269 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=23c35f27f8e1adb5d8811c64ad58ea593c875d3f;p=cc65 Improved 65c02 support git-svn-id: svn://svn.cc65.org/cc65/trunk@2507 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/libsrc/common/atexit.s b/libsrc/common/atexit.s index 940023300..40f392a67 100644 --- a/libsrc/common/atexit.s +++ b/libsrc/common/atexit.s @@ -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 diff --git a/libsrc/common/strdup.s b/libsrc/common/strdup.s index ed49ba485..57cf91488 100644 --- a/libsrc/common/strdup.s +++ b/libsrc/common/strdup.s @@ -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 diff --git a/libsrc/runtime/add.s b/libsrc/runtime/add.s index b22e16ecc..a4a058ddf 100644 --- a/libsrc/runtime/add.s +++ b/libsrc/runtime/add.s @@ -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 diff --git a/libsrc/runtime/and.s b/libsrc/runtime/and.s index 2b52c552c..c38b47bb2 100644 --- a/libsrc/runtime/and.s +++ b/libsrc/runtime/and.s @@ -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 diff --git a/libsrc/runtime/condes.s b/libsrc/runtime/condes.s index feffeaf35..77d0b1c00 100644 --- a/libsrc/runtime/condes.s +++ b/libsrc/runtime/condes.s @@ -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 diff --git a/libsrc/runtime/incax1.s b/libsrc/runtime/incax1.s index 8b8b1079a..2d57b3981 100644 --- a/libsrc/runtime/incax1.s +++ b/libsrc/runtime/incax1.s @@ -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 diff --git a/libsrc/runtime/incsp2.s b/libsrc/runtime/incsp2.s index deb298631..639f8a44f 100644 --- a/libsrc/runtime/incsp2.s +++ b/libsrc/runtime/incsp2.s @@ -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 diff --git a/libsrc/runtime/ldau0sp.s b/libsrc/runtime/ldau0sp.s index ff91261c2..0be99d320 100644 --- a/libsrc/runtime/ldau0sp.s +++ b/libsrc/runtime/ldau0sp.s @@ -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) diff --git a/libsrc/runtime/popa.s b/libsrc/runtime/popa.s index 81e18089c..0534b24e5 100644 --- a/libsrc/runtime/popa.s +++ b/libsrc/runtime/popa.s @@ -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) diff --git a/libsrc/runtime/pusha.s b/libsrc/runtime/pusha.s index e3d2ba2ee..c1f1e3160 100644 --- a/libsrc/runtime/pusha.s +++ b/libsrc/runtime/pusha.s @@ -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) diff --git a/libsrc/runtime/pushb.s b/libsrc/runtime/pushb.s index e5a44c777..d32c1c930 100644 --- a/libsrc/runtime/pushb.s +++ b/libsrc/runtime/pushb.s @@ -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 diff --git a/libsrc/runtime/sub.s b/libsrc/runtime/sub.s index 1240737ad..c9d427efd 100644 --- a/libsrc/runtime/sub.s +++ b/libsrc/runtime/sub.s @@ -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 diff --git a/libsrc/runtime/tosint.s b/libsrc/runtime/tosint.s index 7bbab986e..d29fa2e8b 100644 --- a/libsrc/runtime/tosint.s +++ b/libsrc/runtime/tosint.s @@ -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 diff --git a/libsrc/runtime/toslong.s b/libsrc/runtime/toslong.s index a65a2cff2..9bf66a321 100644 --- a/libsrc/runtime/toslong.s +++ b/libsrc/runtime/toslong.s @@ -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