From c72126e68fc879229b677baf6443ed242b0262f7 Mon Sep 17 00:00:00 2001 From: Kugel Fuhr <98353208+kugelfuhr@users.noreply.github.com> Date: Tue, 1 Jul 2025 07:25:32 +0200 Subject: [PATCH] Changed most of the library sources to use .CAP instead of .CPU. --- libsrc/cbm/clock.s | 3 +- libsrc/common/_directerrno.s | 4 +- libsrc/common/_heapblocksize.s | 3 +- libsrc/common/_mappederrno.s | 3 +- libsrc/common/_printf.s | 11 ++--- libsrc/common/_time_t_to_tm.s | 4 +- libsrc/common/asctime.s | 6 +-- libsrc/common/atexit.s | 10 ++-- libsrc/common/fgetc.s | 4 +- libsrc/common/fgets.s | 8 ++-- libsrc/common/fread.s | 15 +++--- libsrc/common/fwrite.s | 6 +-- libsrc/common/ltoa.s | 4 +- libsrc/common/strcat.s | 3 +- libsrc/common/strchr.s | 3 +- libsrc/common/strdup.s | 4 +- libsrc/common/strncat.s | 83 +++++++++++++++++----------------- libsrc/conio/cputs.s | 5 +- libsrc/conio/scrsize.s | 4 +- libsrc/conio/vcprintf.s | 3 +- libsrc/runtime/add.s | 4 +- libsrc/runtime/and.s | 4 +- libsrc/runtime/condes.s | 2 - libsrc/runtime/incax1.s | 3 +- libsrc/runtime/incsp2.s | 4 +- libsrc/runtime/ladd.s | 4 +- libsrc/runtime/laddeq.s | 4 +- libsrc/runtime/land.s | 6 +-- libsrc/runtime/ldau0sp.s | 4 +- libsrc/runtime/leave.s | 4 +- libsrc/runtime/lmod.s | 4 +- libsrc/runtime/lmul.s | 6 +-- libsrc/runtime/lor.s | 6 +-- libsrc/runtime/lpop.s | 4 +- libsrc/runtime/lpush.s | 6 +-- libsrc/runtime/lrsub.s | 6 +-- libsrc/runtime/lsub.s | 6 +-- libsrc/runtime/lsubeq.s | 4 +- libsrc/runtime/ludiv.s | 6 +-- libsrc/runtime/lumod.s | 4 +- libsrc/runtime/lxor.s | 6 +-- libsrc/runtime/or.s | 4 +- libsrc/runtime/popa.s | 4 +- libsrc/runtime/popptr1.s | 4 +- libsrc/runtime/popsreg.s | 4 +- libsrc/runtime/pusha.s | 2 - libsrc/runtime/pushax.s | 4 +- libsrc/runtime/pushb.s | 4 +- libsrc/runtime/rsub.s | 4 +- libsrc/runtime/shl.s | 4 +- libsrc/runtime/staxspi.s | 4 +- libsrc/runtime/stkchk.s | 3 +- libsrc/runtime/sub.s | 4 +- libsrc/runtime/swap.s | 4 +- libsrc/runtime/tosint.s | 4 +- libsrc/runtime/toslong.s | 6 +-- libsrc/runtime/umul8x16r24.s | 4 +- libsrc/runtime/xor.s | 4 +- libsrc/tgi/tgi_settextstyle.s | 4 +- 59 files changed, 122 insertions(+), 232 deletions(-) diff --git a/libsrc/cbm/clock.s b/libsrc/cbm/clock.s index 90e4263a8..91fde6f58 100644 --- a/libsrc/cbm/clock.s +++ b/libsrc/cbm/clock.s @@ -9,14 +9,13 @@ .importzp sreg .include "cbm.inc" - .macpack cpu .proc _clock ; Some accelerator adaptors have CMOS ICs. -.if (.cpu & ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_STZ) stz sreg + 1 .else lda #$00 ; Byte 3 always is zero diff --git a/libsrc/common/_directerrno.s b/libsrc/common/_directerrno.s index 20060bdd7..74e2f89cd 100644 --- a/libsrc/common/_directerrno.s +++ b/libsrc/common/_directerrno.s @@ -7,8 +7,6 @@ .include "errno.inc" - .macpack cpu - ; ---------------------------------------------------------------------------- ; int __fastcall__ __directerrno (unsigned char code); ; /* Set errno to a specific error code, clear __oserror, and return -1. Used @@ -18,7 +16,7 @@ ___directerrno: jsr ___seterrno ; Set errno (returns with .A = 0) sta ___oserror ; Clear ___oserror -.if (.cpu .bitand CPU_ISET_65SC02) +.if .cap(CPU_HAS_INA) dec a .else lda #$FF ; Return -1 diff --git a/libsrc/common/_heapblocksize.s b/libsrc/common/_heapblocksize.s index e9b0cdad9..774056032 100644 --- a/libsrc/common/_heapblocksize.s +++ b/libsrc/common/_heapblocksize.s @@ -12,7 +12,6 @@ .include "_heap.inc" .macpack generic - .macpack cpu ;----------------------------------------------------------------------------- ; Code @@ -39,7 +38,7 @@ ___heapblocksize: ldy #usedblock::size+1 lda (ptr2),y tax -.if (.cpu .bitand CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) lda (ptr2) .else dey diff --git a/libsrc/common/_mappederrno.s b/libsrc/common/_mappederrno.s index 83565b723..4ea3174b6 100644 --- a/libsrc/common/_mappederrno.s +++ b/libsrc/common/_mappederrno.s @@ -8,7 +8,6 @@ .include "errno.inc" .macpack generic - .macpack cpu ; ---------------------------------------------------------------------------- ; int __fastcall__ __mappederrno (unsigned char code); @@ -24,7 +23,7 @@ ___mappederrno: bze ok ; Branch if no jsr ___osmaperrno ; Map OS error into errno code jsr ___seterrno ; Save in errno (returns with .A = 0) -.if (.cpu .bitand CPU_ISET_65SC02) +.if .cap(CPU_HAS_INA) dec a .else lda #$FF ; Return -1 if error diff --git a/libsrc/common/_printf.s b/libsrc/common/_printf.s index 40ab0bc64..335485cc6 100644 --- a/libsrc/common/_printf.s +++ b/libsrc/common/_printf.s @@ -13,7 +13,6 @@ .import _strlower, _strlen .macpack generic - .macpack cpu ; ---------------------------------------------------------------------------- ; We will store variables into the register bank in the zeropage. Define @@ -38,7 +37,7 @@ FCount = ptr2 GetFormatChar: ldy #0 - .if (.cpu .bitand ::CPU_ISET_65SC02) + .if .cap(CPU_HAS_ZPIND) lda (Format) .else lda (Format),y @@ -115,7 +114,7 @@ GetIntArg: lda (ArgList),y tax dey - .if (.cpu .bitand ::CPU_ISET_65SC02) + .if .cap(CPU_HAS_ZPIND) lda (ArgList) .else lda (ArgList),y @@ -274,7 +273,7 @@ Save: lda regbank,y ; Initialize the output counter in the output descriptor to zero lda #0 - .if (.cpu .bitand ::CPU_ISET_65SC02) + .if .cap(CPU_HAS_ZPIND) sta (OutData) ldy #$01 sta (OutData),y @@ -353,7 +352,7 @@ MainLoop: sta (c_sp),y dey lda FCount - .if (.cpu .bitand ::CPU_ISET_65SC02) + .if .cap(CPU_HAS_ZPIND) sta (c_sp) .else sta (c_sp),y @@ -570,7 +569,7 @@ CheckCount: jsr GetIntArg sta ptr1 stx ptr1+1 ; Get user supplied pointer - .if (.cpu .bitand ::CPU_ISET_65SC02) + .if .cap(CPU_HAS_ZPIND) lda (OutData) ; Low byte of OutData->ccount sta (ptr1) ldy #1 diff --git a/libsrc/common/_time_t_to_tm.s b/libsrc/common/_time_t_to_tm.s index 9bcf84184..21e662384 100644 --- a/libsrc/common/_time_t_to_tm.s +++ b/libsrc/common/_time_t_to_tm.s @@ -16,8 +16,6 @@ .include "time.inc" - .macpack cpu - __time_t_to_tm: ; Divide number of seconds since epoch, in ptr1:sreg, ; by 86400 to get the number of days since epoch, and @@ -80,7 +78,7 @@ __time_t_to_tm: ; Zero the two high bytes of the divisor and the high byte ; of the dividend. - .if .cpu .bitand CPU_ISET_65SC02 + .if .cap(CPU_HAS_STZ) stz ptr4 stz ptr4+1 stz sreg+1 diff --git a/libsrc/common/asctime.s b/libsrc/common/asctime.s index efcf34b41..b56371594 100644 --- a/libsrc/common/asctime.s +++ b/libsrc/common/asctime.s @@ -9,8 +9,6 @@ .importzp ptr1 .include "time.inc" - .macpack cpu - ; ------------------------------------------------------------------------ ; Special values @@ -24,7 +22,7 @@ MAX_BUF_LEN = 38 _asctime: ; Backup timep - .if (.cpu .bitand ::CPU_ISET_65SC02) + .if .cap(CPU_HAS_PUSHXY) pha phx .else @@ -48,7 +46,7 @@ _asctime: jsr pushax ; Restore timep - .if (.cpu .bitand ::CPU_ISET_65SC02) + .if .cap(CPU_HAS_PUSHXY) plx pla .else diff --git a/libsrc/common/atexit.s b/libsrc/common/atexit.s index 47a1dfd4d..ccbc2e69f 100644 --- a/libsrc/common/atexit.s +++ b/libsrc/common/atexit.s @@ -10,8 +10,6 @@ .include "errno.inc" - .macpack cpu - ; --------------------------------------------------------------------------- .proc _atexit @@ -41,7 +39,7 @@ jsr ___seterrno ldx #$FF ; Return -1 txa - rts +Exit: rts .endproc @@ -54,7 +52,7 @@ .proc doatexit ldy exitfunc_index ; Get index - beq @L9 ; Jump if done + beq _atexit::Exit ; Jump if done dey lda exitfunc_table,y tax @@ -62,14 +60,12 @@ lda exitfunc_table,y sty exitfunc_index jsr callax ; Call the function -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_BRA8) bra doatexit .else jmp doatexit ; Next one .endif -@L9: rts - .endproc diff --git a/libsrc/common/fgetc.s b/libsrc/common/fgetc.s index 34d4df3aa..6d08f69a3 100644 --- a/libsrc/common/fgetc.s +++ b/libsrc/common/fgetc.s @@ -12,8 +12,6 @@ .include "stdio.inc" .include "_file.inc" - .macpack cpu - _fgetc: sta ptr1 stx ptr1+1 @@ -22,7 +20,7 @@ _fgetc: jsr checkferror bne ret_eof - .if (.cpu .bitand ::CPU_ISET_65SC02) + .if .cap(CPU_HAS_BITIMM) bit #_FPUSHBACK ; Check for pushed back char beq do_read .else diff --git a/libsrc/common/fgets.s b/libsrc/common/fgets.s index c25664f19..fde3a78a9 100644 --- a/libsrc/common/fgets.s +++ b/libsrc/common/fgets.s @@ -14,12 +14,10 @@ .include "stdio.inc" .include "_file.inc" - .macpack cpu - terminate_ptr: lda #$00 tax - .if (.cpu .bitand ::CPU_ISET_65SC02) + .if .cap(CPU_HAS_ZPIND) sta (ptr4) .else tay @@ -41,7 +39,7 @@ _fgets: sta buf stx buf+1 - .if (.cpu .bitand ::CPU_ISET_65SC02) + .if .cap(CPU_HAS_STZ) stz didread .else lda #$00 ; We have read nothing yet @@ -79,7 +77,7 @@ read_loop: ldy #$01 sty didread ; We read at least one char - .if (.cpu .bitand ::CPU_ISET_65SC02) + .if .cap(CPU_HAS_ZPIND) sta (ptr4) .else dey diff --git a/libsrc/common/fread.s b/libsrc/common/fread.s index be06c2a62..beb9e707e 100644 --- a/libsrc/common/fread.s +++ b/libsrc/common/fread.s @@ -20,7 +20,6 @@ .include "_file.inc" .macpack generic - .macpack cpu ; ------------------------------------------------------------------------ ; Code @@ -48,7 +47,7 @@ ldy #_FILE::f_flags lda (file),y - .if (.cpu .bitand ::CPU_ISET_65SC02) + .if .cap(CPU_HAS_BITIMM) bit #_FOPEN ; Is the file open? .else and #_FOPEN ; Is the file open? @@ -57,7 +56,7 @@ ; Check if the stream is in an error state - .if (.cpu .bitand ::CPU_ISET_65SC02) + .if .cap(CPU_HAS_BITIMM) bit #_FERROR .else lda (file),y ; get file->f_flags again @@ -74,17 +73,15 @@ ; Remember if we have a pushed back character and reset the flag. -@L2: .if (.cpu .bitand ::CPU_ISET_65SC02) +@L2: .if .cap(CPU_HAS_BITIMM) ldx #$00 bit #_FPUSHBACK + beq @L3 .else tax ; X = 0 lda (file),y and #_FPUSHBACK - .endif beq @L3 - - .if (.not .cpu .bitand ::CPU_ISET_65SC02) lda (file),y .endif and #<~_FPUSHBACK @@ -135,7 +132,7 @@ ; Copy the buffer pointer into ptr1, and increment the pointer value passed ; to read() by one, so read() starts to store data at buf+1. - .if (.cpu .bitand ::CPU_ISET_65SC02) + .if .cap(CPU_HAS_ZPIND) lda (c_sp) sta ptr1 add #1 @@ -159,7 +156,7 @@ ldy #_FILE::f_pushback lda (file),y - .if (.cpu .bitand ::CPU_ISET_65SC02) + .if .cap(CPU_HAS_ZPIND) sta (ptr1) ; *buf = file->f_pushback; .else ldy #0 diff --git a/libsrc/common/fwrite.s b/libsrc/common/fwrite.s index e7151da95..6f631b816 100644 --- a/libsrc/common/fwrite.s +++ b/libsrc/common/fwrite.s @@ -16,8 +16,6 @@ .include "errno.inc" .include "_file.inc" - .macpack cpu - ; ------------------------------------------------------------------------ ; Code @@ -34,7 +32,7 @@ ldy #_FILE::f_flags lda (ptr1),y - .if (.cpu .bitand ::CPU_ISET_65SC02) + .if .cap(CPU_HAS_BITIMM) bit #_FOPEN .else and #_FOPEN ; Is the file open? @@ -50,7 +48,7 @@ ; Check if the stream is in an error state -@L2: .if (.not .cpu .bitand ::CPU_ISET_65SC02) +@L2: .if .not .cap(CPU_HAS_BITIMM) lda (ptr1),y ; get file->f_flags again .endif and #_FERROR diff --git a/libsrc/common/ltoa.s b/libsrc/common/ltoa.s index 78e43e23f..7c31d471f 100644 --- a/libsrc/common/ltoa.s +++ b/libsrc/common/ltoa.s @@ -10,8 +10,6 @@ .import __hextab, __longminstr .importzp sreg, ptr1, ptr2, ptr3, tmp1 - .macpack cpu - .code ; @@ -64,7 +62,7 @@ L2: txa ; get high byte bpl ultoa lda #'-' -.if (.cpu .bitand CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) sta (ptr2) .else ldy #0 diff --git a/libsrc/common/strcat.s b/libsrc/common/strcat.s index f9cd94633..963b037b9 100644 --- a/libsrc/common/strcat.s +++ b/libsrc/common/strcat.s @@ -8,7 +8,6 @@ .export _strcat .import popax .importzp ptr1, ptr2, tmp3 - .macpack cpu _strcat: sta ptr1 ; Save src @@ -16,7 +15,7 @@ _strcat: jsr popax ; Get dest sta tmp3 ; Remember for function return tay -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_STZ) stz ptr2 .else lda #0 diff --git a/libsrc/common/strchr.s b/libsrc/common/strchr.s index 206b5160e..ac7f5397a 100644 --- a/libsrc/common/strchr.s +++ b/libsrc/common/strchr.s @@ -8,14 +8,13 @@ .export _strchr .import popax .importzp ptr1, tmp1 - .macpack cpu _strchr: sta tmp1 ; Save c jsr popax ; get s tay ; low byte of pointer to y stx ptr1+1 -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_STZ) stz ptr1 .else lda #0 diff --git a/libsrc/common/strdup.s b/libsrc/common/strdup.s index 94f2cd338..4cf643614 100644 --- a/libsrc/common/strdup.s +++ b/libsrc/common/strdup.s @@ -12,8 +12,6 @@ .import _strlen_ptr4, _malloc, _memcpy, pushax .export _strdup - .macpack cpu - _strdup: ; Get length (and store source in ptr4) sta ptr4 @@ -22,7 +20,7 @@ _strdup: jsr _strlen_ptr4 ; strlen may increment ; Add null byte for terminator -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_INA) inc a .else clc diff --git a/libsrc/common/strncat.s b/libsrc/common/strncat.s index 75572db7c..e4e321591 100644 --- a/libsrc/common/strncat.s +++ b/libsrc/common/strncat.s @@ -8,64 +8,63 @@ .export _strncat .import popax, popptr1 .importzp ptr1, ptr2, ptr3, tmp1, tmp2 -.macpack cpu _strncat: - inx - stx tmp2 - tax - inx - stx tmp1 ; save count with each byte incremented separately + inx + stx tmp2 + tax + inx + stx tmp1 ; save count with each byte incremented separately - jsr popptr1 ; get src + jsr popptr1 ; get src - jsr popax ; get dest - sta ptr3 ; remember for function return - stx ptr3+1 - stx ptr2+1 - tay ; low byte as offset in Y -.if (.cpu .bitand ::CPU_ISET_65SC02) - stz ptr2 + jsr popax ; get dest + sta ptr3 ; remember for function return + stx ptr3+1 + stx ptr2+1 + tay ; low byte as offset in Y +.if .cap(CPU_HAS_STZ) + stz ptr2 .else - ldx #0 - stx ptr2 ; destination on page boundary + ldx #0 + stx ptr2 ; destination on page boundary .endif ; find end of dest -L1: lda (ptr2),y - beq L2 - iny - bne L1 - inc ptr2+1 - bne L1 +L1: lda (ptr2),y + beq L2 + iny + bne L1 + inc ptr2+1 + bne L1 ; end found, apply offset to dest ptr and reset y -L2: sty ptr2 +L2: sty ptr2 ; copy src. We've put the ones complement of the count into the counter, so ; we'll increment the counter on top of the loop -L3: ldy #0 - ldx tmp1 ; low counter byte +L3: ldy #0 + ldx tmp1 ; low counter byte -L4: dex - bne L5 - dec tmp2 - beq L6 ; jump if done -L5: lda (ptr1),y - sta (ptr2),y - beq L7 - iny - bne L4 - inc ptr1+1 - inc ptr2+1 - bne L4 +L4: dex + bne L5 + dec tmp2 + beq L6 ; jump if done +L5: lda (ptr1),y + sta (ptr2),y + beq L7 + iny + bne L4 + inc ptr1+1 + inc ptr2+1 + bne L4 ; done, set the trailing zero and return pointer to dest -L6: lda #0 - sta (ptr2),y -L7: lda ptr3 - ldx ptr3+1 - rts +L6: lda #0 + sta (ptr2),y +L7: lda ptr3 + ldx ptr3+1 + rts diff --git a/libsrc/conio/cputs.s b/libsrc/conio/cputs.s index b822fddee..d6024c0e5 100644 --- a/libsrc/conio/cputs.s +++ b/libsrc/conio/cputs.s @@ -8,13 +8,12 @@ .export _cputsxy, _cputs .import gotoxy, _cputc .importzp ptr1, tmp1 - .macpack cpu _cputsxy: sta ptr1 ; Save s for later stx ptr1+1 jsr gotoxy ; Set cursor, pop x and y -.if (.cpu .bitand CPU_ISET_65SC02) +.if .cap(CPU_HAS_BRA8) bra L0 ; Same as cputs... .else jmp L0 ; Same as cputs... @@ -24,7 +23,7 @@ _cputs: sta ptr1 ; Save s stx ptr1+1 L0: -.if (.cpu .bitand CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) lda (ptr1) ; (5) .else ldy #0 ; (2) diff --git a/libsrc/conio/scrsize.s b/libsrc/conio/scrsize.s index 834c14820..fc1691b87 100644 --- a/libsrc/conio/scrsize.s +++ b/libsrc/conio/scrsize.s @@ -10,8 +10,6 @@ .import screensize .importzp ptr1, ptr2 - .macpack cpu - .proc _screensize sta ptr2 ; Store the y pointer @@ -20,7 +18,7 @@ jsr screensize ; Get screensize into X/Y tya ; Get Y size into A -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) sta (ptr2) txa sta (ptr1) diff --git a/libsrc/conio/vcprintf.s b/libsrc/conio/vcprintf.s index c6371f00e..aa7b6aa07 100644 --- a/libsrc/conio/vcprintf.s +++ b/libsrc/conio/vcprintf.s @@ -10,7 +10,6 @@ .importzp c_sp, ptr1, ptr2, ptr3, tmp1 .macpack generic - .macpack cpu .data @@ -74,7 +73,7 @@ out: jsr popax ; count ; Loop outputting characters -.if (.cpu .bitand CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND, CPU_HAS_BRA8) @L1: dec outdesc+6 beq @L4 diff --git a/libsrc/runtime/add.s b/libsrc/runtime/add.s index 85ddd0f25..b841f829d 100644 --- a/libsrc/runtime/add.s +++ b/libsrc/runtime/add.s @@ -11,14 +11,12 @@ .export tosadda0, tosaddax .importzp c_sp, tmp1 - .macpack cpu - tosadda0: ldx #0 tosaddax: clc ; (2) -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) adc (c_sp) ; (7) tay ; (9) diff --git a/libsrc/runtime/and.s b/libsrc/runtime/and.s index 8411660ab..303d4e010 100644 --- a/libsrc/runtime/and.s +++ b/libsrc/runtime/and.s @@ -8,12 +8,10 @@ .import addysp1 .importzp c_sp, ptr4 - .macpack cpu - tosanda0: ldx #$00 tosandax: -.if (.cpu .bitand CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) and (c_sp) ; 65SC02 version, saves 2 cycles and 1 byte ldy #1 .else diff --git a/libsrc/runtime/condes.s b/libsrc/runtime/condes.s index a99b713f5..fc187040e 100644 --- a/libsrc/runtime/condes.s +++ b/libsrc/runtime/condes.s @@ -18,8 +18,6 @@ .import __CONSTRUCTOR_TABLE__, __CONSTRUCTOR_COUNT__ .import __DESTRUCTOR_TABLE__, __DESTRUCTOR_COUNT__ - .macpack cpu - ; -------------------------------------------------------------------------- ; Initialize library modules diff --git a/libsrc/runtime/incax1.s b/libsrc/runtime/incax1.s index 19c1d0c60..bff94b019 100644 --- a/libsrc/runtime/incax1.s +++ b/libsrc/runtime/incax1.s @@ -7,11 +7,10 @@ .export incax1 .macpack generic - .macpack cpu .proc incax1 -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_INA) ina ; 65C02 version bne @L9 .else diff --git a/libsrc/runtime/incsp2.s b/libsrc/runtime/incsp2.s index c3260c19d..395ea52cb 100644 --- a/libsrc/runtime/incsp2.s +++ b/libsrc/runtime/incsp2.s @@ -7,8 +7,6 @@ .export popax, incsp2 .importzp c_sp - .macpack cpu - ; Pop a/x from stack. This function will run directly into incsp2 .proc popax @@ -16,7 +14,7 @@ ldy #1 lda (c_sp),y ; get hi byte tax ; into x -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) lda (c_sp) ; get lo byte .else dey diff --git a/libsrc/runtime/ladd.s b/libsrc/runtime/ladd.s index 6c187f32d..6991e4a7e 100644 --- a/libsrc/runtime/ladd.s +++ b/libsrc/runtime/ladd.s @@ -8,8 +8,6 @@ .import addysp1 .importzp c_sp, sreg, tmp1 - .macpack cpu - ; EAX = TOS + EAX tosadd0ax: @@ -19,7 +17,7 @@ tosadd0ax: tosaddeax: clc -.if (.cpu .bitand CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) adc (c_sp) ; 65SC02 version - saves 2 cycles ldy #1 .else diff --git a/libsrc/runtime/laddeq.s b/libsrc/runtime/laddeq.s index 57bec0629..e5afac9cc 100644 --- a/libsrc/runtime/laddeq.s +++ b/libsrc/runtime/laddeq.s @@ -11,8 +11,6 @@ .export laddeq1, laddeqa, laddeq .importzp sreg, ptr1, tmp1 - .macpack cpu - laddeq1: lda #$01 @@ -24,7 +22,7 @@ laddeqa: laddeq: sty ptr1+1 ; Store high byte of address clc -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) adc (ptr1) sta (ptr1) ldy #$01 ; Address byte 1 diff --git a/libsrc/runtime/land.s b/libsrc/runtime/land.s index 400fede3b..2ad4ae4d7 100644 --- a/libsrc/runtime/land.s +++ b/libsrc/runtime/land.s @@ -9,10 +9,8 @@ .import addysp1 .importzp c_sp, sreg, tmp1 - .macpack cpu - tosand0ax: -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_STZ) stz sreg stz sreg+1 .else @@ -22,7 +20,7 @@ tosand0ax: .endif tosandeax: -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) and (c_sp) ; byte 0 ldy #1 .else diff --git a/libsrc/runtime/ldau0sp.s b/libsrc/runtime/ldau0sp.s index a808f6f84..5fbde5b62 100644 --- a/libsrc/runtime/ldau0sp.s +++ b/libsrc/runtime/ldau0sp.s @@ -7,8 +7,6 @@ .export ldau00sp, ldau0ysp .importzp c_sp, ptr1 - .macpack cpu - ldau00sp: ldy #1 ldau0ysp: @@ -18,7 +16,7 @@ ldau0ysp: lda (c_sp),y sta ptr1 ldx #0 -.if (.cpu .bitand CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) lda (ptr1) ; Save one cycle for the C02 .else lda (ptr1,x) diff --git a/libsrc/runtime/leave.s b/libsrc/runtime/leave.s index 408fdd159..afb069b1c 100644 --- a/libsrc/runtime/leave.s +++ b/libsrc/runtime/leave.s @@ -14,8 +14,6 @@ .import addysp .importzp c_sp - .macpack cpu - leave00: lda #0 leave0: ldx #0 @@ -28,7 +26,7 @@ leavey0: leavey: jsr addysp ; drop stack frame -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) leave: tay ; save A a sec lda (c_sp) ; that's the pushed arg size diff --git a/libsrc/runtime/lmod.s b/libsrc/runtime/lmod.s index b8e796dea..1cff216f3 100644 --- a/libsrc/runtime/lmod.s +++ b/libsrc/runtime/lmod.s @@ -11,10 +11,8 @@ .import poplsargs, udiv32, negeax .importzp sreg, ptr1, ptr2, tmp1, tmp3, tmp4 - .macpack cpu - tosmod0ax: -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_STZ) stz sreg stz sreg+1 .else diff --git a/libsrc/runtime/lmul.s b/libsrc/runtime/lmul.s index a68c3e5c1..7124d6abd 100644 --- a/libsrc/runtime/lmul.s +++ b/libsrc/runtime/lmul.s @@ -9,11 +9,9 @@ .import addysp1 .importzp c_sp, sreg, tmp1, tmp2, tmp3, tmp4, ptr1, ptr3, ptr4 - .macpack cpu - tosmul0ax: tosumul0ax: -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_STZ) stz sreg stz sreg+1 .else @@ -26,7 +24,7 @@ tosmuleax: tosumuleax: mul32: sta ptr1 stx ptr1+1 ; op2 now in ptr1/sreg -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) lda (c_sp) ldy #1 .else diff --git a/libsrc/runtime/lor.s b/libsrc/runtime/lor.s index 888a0c611..fa87aa63d 100644 --- a/libsrc/runtime/lor.s +++ b/libsrc/runtime/lor.s @@ -9,10 +9,8 @@ .import addysp1 .importzp c_sp, sreg, tmp1 - .macpack cpu - tosor0ax: -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_STZ) stz sreg stz sreg+1 .else @@ -22,7 +20,7 @@ tosor0ax: .endif tosoreax: -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) ora (c_sp) ldy #1 .else diff --git a/libsrc/runtime/lpop.s b/libsrc/runtime/lpop.s index 9690aff24..81dde42d3 100644 --- a/libsrc/runtime/lpop.s +++ b/libsrc/runtime/lpop.s @@ -9,8 +9,6 @@ .import incsp4 .importzp c_sp, sreg - .macpack cpu - popeax: ldy #3 lda (c_sp),y sta sreg+1 @@ -20,7 +18,7 @@ popeax: ldy #3 dey lda (c_sp),y tax -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) lda (c_sp) .else dey diff --git a/libsrc/runtime/lpush.s b/libsrc/runtime/lpush.s index ec2c865af..fbc37b78c 100644 --- a/libsrc/runtime/lpush.s +++ b/libsrc/runtime/lpush.s @@ -12,13 +12,11 @@ .import decsp4 .importzp c_sp, sreg - .macpack cpu - pushl0: lda #0 tax push0ax: -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_STZ) stz sreg stz sreg+1 .else @@ -39,7 +37,7 @@ pusheax: txa sta (c_sp),y pla -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) sta (c_sp) .else dey diff --git a/libsrc/runtime/lrsub.s b/libsrc/runtime/lrsub.s index 456d8d8d5..b88d44f1a 100644 --- a/libsrc/runtime/lrsub.s +++ b/libsrc/runtime/lrsub.s @@ -12,10 +12,8 @@ .import addysp1 .importzp c_sp, sreg, tmp1 - .macpack cpu - tosrsub0ax: -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_STZ) stz sreg stz sreg+1 .else @@ -26,7 +24,7 @@ tosrsub0ax: tosrsubeax: sec -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) sbc (c_sp) ldy #1 .else diff --git a/libsrc/runtime/lsub.s b/libsrc/runtime/lsub.s index 17b225404..f0d34cd5b 100644 --- a/libsrc/runtime/lsub.s +++ b/libsrc/runtime/lsub.s @@ -11,10 +11,8 @@ .import addysp1 .importzp c_sp, sreg - .macpack cpu - tossub0ax: -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_STZ) stz sreg stz sreg+1 .else @@ -26,7 +24,7 @@ tossub0ax: tossubeax: sec eor #$FF -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) adc (c_sp) ; 65SC02 version - saves 2 cycles ldy #1 .else diff --git a/libsrc/runtime/lsubeq.s b/libsrc/runtime/lsubeq.s index b16ab18e1..d2d4ede7f 100644 --- a/libsrc/runtime/lsubeq.s +++ b/libsrc/runtime/lsubeq.s @@ -11,8 +11,6 @@ .export lsubeq1, lsubeqa, lsubeq .importzp sreg, ptr1 - .macpack cpu - lsubeq1: lda #$01 @@ -25,7 +23,7 @@ lsubeq: sty ptr1+1 ; Store high byte of address sec eor #$FF - .if (.cpu .bitand ::CPU_ISET_65SC02) + .if .cap(CPU_HAS_ZPIND) adc (ptr1) ; Subtract byte 0 sta (ptr1) ldy #$01 ; Address byte 1 diff --git a/libsrc/runtime/ludiv.s b/libsrc/runtime/ludiv.s index b47207222..53651c789 100644 --- a/libsrc/runtime/ludiv.s +++ b/libsrc/runtime/ludiv.s @@ -9,10 +9,8 @@ .import addysp1 .importzp c_sp, sreg, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4 - .macpack cpu - tosudiv0ax: -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_STZ) stz sreg stz sreg+1 .else @@ -38,7 +36,7 @@ getlop: sta ptr3 ; Put right operand in place lda sreg+1 sta ptr4+1 -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) lda (c_sp) ldy #1 .else diff --git a/libsrc/runtime/lumod.s b/libsrc/runtime/lumod.s index eb6176b35..a43c6d287 100644 --- a/libsrc/runtime/lumod.s +++ b/libsrc/runtime/lumod.s @@ -9,10 +9,8 @@ .import getlop, udiv32 .importzp sreg, tmp3, tmp4, ptr2 - .macpack cpu - tosumod0ax: -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_STZ) stz sreg stz sreg+1 .else diff --git a/libsrc/runtime/lxor.s b/libsrc/runtime/lxor.s index 6d9f7db3a..abf341e63 100644 --- a/libsrc/runtime/lxor.s +++ b/libsrc/runtime/lxor.s @@ -9,10 +9,8 @@ .import addysp1 .importzp c_sp, sreg, tmp1 - .macpack cpu - tosxor0ax: -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_STZ) stz sreg stz sreg+1 .else @@ -22,7 +20,7 @@ tosxor0ax: .endif tosxoreax: -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) eor (c_sp) ; byte 0 ldy #1 .else diff --git a/libsrc/runtime/or.s b/libsrc/runtime/or.s index 04389be5f..09aa93e79 100644 --- a/libsrc/runtime/or.s +++ b/libsrc/runtime/or.s @@ -9,12 +9,10 @@ .import addysp1 .importzp c_sp, tmp1 - .macpack cpu - tosora0: ldx #$00 tosorax: -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) ora (c_sp) ldy #1 .else diff --git a/libsrc/runtime/popa.s b/libsrc/runtime/popa.s index c1700071d..bc490312e 100644 --- a/libsrc/runtime/popa.s +++ b/libsrc/runtime/popa.s @@ -7,11 +7,9 @@ .export popa .importzp c_sp - .macpack cpu - .proc popa -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) lda (c_sp) .else ldy #0 ; (2) diff --git a/libsrc/runtime/popptr1.s b/libsrc/runtime/popptr1.s index 45043dd27..90dca5e22 100644 --- a/libsrc/runtime/popptr1.s +++ b/libsrc/runtime/popptr1.s @@ -8,14 +8,12 @@ .import incsp2 .importzp c_sp, ptr1 - .macpack cpu - .proc popptr1 ; 14 bytes (four usages = at least 2 bytes saved) ldy #1 lda (c_sp),y ; get hi byte sta ptr1+1 ; into ptr hi dey ; dey even for for 65C02 here to have Y=0 at exit! -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) lda (c_sp) ; get lo byte .else lda (c_sp),y ; get lo byte diff --git a/libsrc/runtime/popsreg.s b/libsrc/runtime/popsreg.s index c7f667246..0f6e5701d 100644 --- a/libsrc/runtime/popsreg.s +++ b/libsrc/runtime/popsreg.s @@ -8,14 +8,12 @@ .import incsp2 .importzp c_sp, sreg - .macpack cpu - popsreg: pha ; save A ldy #1 lda (c_sp),y ; get hi byte sta sreg+1 ; store it -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) lda (c_sp) ; get lo byte .else dey diff --git a/libsrc/runtime/pusha.s b/libsrc/runtime/pusha.s index 399423077..6c715afb7 100644 --- a/libsrc/runtime/pusha.s +++ b/libsrc/runtime/pusha.s @@ -7,8 +7,6 @@ .export pusha0sp, pushaysp, pusha .importzp c_sp - .macpack cpu - ; Beware: The optimizer knows about this function! pusha0sp: diff --git a/libsrc/runtime/pushax.s b/libsrc/runtime/pushax.s index f77a9bcc3..5177f77b5 100644 --- a/libsrc/runtime/pushax.s +++ b/libsrc/runtime/pushax.s @@ -7,8 +7,6 @@ .export push0, pusha0, pushax .importzp c_sp - .macpack cpu - push0: lda #0 pusha0: ldx #0 @@ -31,7 +29,7 @@ pusha0: ldx #0 sta (c_sp),y ; (27) pla ; (31) dey ; (33) -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) sta (c_sp) ; (37) .else sta (c_sp),y ; (38) diff --git a/libsrc/runtime/pushb.s b/libsrc/runtime/pushb.s index 7507ff21a..02d91b156 100644 --- a/libsrc/runtime/pushb.s +++ b/libsrc/runtime/pushb.s @@ -8,8 +8,6 @@ .import pushax .importzp ptr1 - .macpack cpu - pushbidx: sty ptr1 clc @@ -19,7 +17,7 @@ pushbidx: pushb: sta ptr1 stx ptr1+1 ldx #0 ; Load index/high byte -.if (.cpu .bitand CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) lda (ptr1) ; Save one cycle for the C02 .else lda (ptr1,x) diff --git a/libsrc/runtime/rsub.s b/libsrc/runtime/rsub.s index bacb3c7fc..1eedee53e 100644 --- a/libsrc/runtime/rsub.s +++ b/libsrc/runtime/rsub.s @@ -9,8 +9,6 @@ .import addysp1 .importzp c_sp, tmp1 - .macpack cpu - ; ; AX = AX - TOS ; @@ -19,7 +17,7 @@ tosrsuba0: ldx #0 tosrsubax: sec -.if (.cpu .bitand CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) sbc (c_sp) ldy #1 .else diff --git a/libsrc/runtime/shl.s b/libsrc/runtime/shl.s index c1a4b6ef8..1f11eb5c0 100644 --- a/libsrc/runtime/shl.s +++ b/libsrc/runtime/shl.s @@ -15,8 +15,6 @@ .import popax .importzp tmp1 - .macpack cpu - tosshlax: tosaslax: sta tmp1 ; Save shift count @@ -55,7 +53,7 @@ L2: pla ; Shift count is exactly 8 -.if (.cpu .bitand CPU_ISET_65SC02) +.if .cap(CPU_HAS_PUSHXY) L3: plx ; Low byte from stack into X rts ; A is already zero .else diff --git a/libsrc/runtime/staxspi.s b/libsrc/runtime/staxspi.s index aefed428f..e1542881f 100644 --- a/libsrc/runtime/staxspi.s +++ b/libsrc/runtime/staxspi.s @@ -9,8 +9,6 @@ .import incsp2 .importzp c_sp, tmp1, ptr1 - .macpack cpu - .proc staxspidx sty tmp1 ; Save Y @@ -18,7 +16,7 @@ ldy #1 lda (c_sp),y sta ptr1+1 -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) lda (c_sp) .else dey diff --git a/libsrc/runtime/stkchk.s b/libsrc/runtime/stkchk.s index a7ca39f21..f6ab28ea6 100644 --- a/libsrc/runtime/stkchk.s +++ b/libsrc/runtime/stkchk.s @@ -21,7 +21,6 @@ ; Use macros for better readability .macpack generic - .macpack cpu ; ---------------------------------------------------------------------------- @@ -39,7 +38,7 @@ lda c_sp+1 sta initialsp+1 sbc #>__STACKSIZE__ -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_INA) ina ; Add 256 bytes safety area .else add #1 ; Add 256 bytes safety area diff --git a/libsrc/runtime/sub.s b/libsrc/runtime/sub.s index 58ffb4c91..7129e2147 100644 --- a/libsrc/runtime/sub.s +++ b/libsrc/runtime/sub.s @@ -8,8 +8,6 @@ .import addysp1 .importzp c_sp - .macpack cpu - ; AX = TOS - AX tossuba0: @@ -17,7 +15,7 @@ tossuba0: tossubax: sec eor #$FF -.if (.cpu .bitand CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) adc (c_sp) ldy #1 .else diff --git a/libsrc/runtime/swap.s b/libsrc/runtime/swap.s index 3796b0a97..72adaa90b 100644 --- a/libsrc/runtime/swap.s +++ b/libsrc/runtime/swap.s @@ -8,8 +8,6 @@ .export swapstk .importzp c_sp, ptr4 - .macpack cpu - swapstk: sta ptr4 stx ptr4+1 @@ -18,7 +16,7 @@ swapstk: tax lda ptr4+1 sta (c_sp),y -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) lda (c_sp) tay lda ptr4 diff --git a/libsrc/runtime/tosint.s b/libsrc/runtime/tosint.s index 2aaa19ccc..e879fe11f 100644 --- a/libsrc/runtime/tosint.s +++ b/libsrc/runtime/tosint.s @@ -8,14 +8,12 @@ .import incsp2 .importzp c_sp - .macpack cpu - ; Convert TOS from long to int by cutting of the high 16bit .proc tosint pha -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) lda (c_sp) .else ldy #0 diff --git a/libsrc/runtime/toslong.s b/libsrc/runtime/toslong.s index cf8eff031..c8b34d8b0 100644 --- a/libsrc/runtime/toslong.s +++ b/libsrc/runtime/toslong.s @@ -8,8 +8,6 @@ .import decsp2 .importzp c_sp - .macpack cpu - ; Convert TOS from int to long tosulong: @@ -17,7 +15,7 @@ tosulong: jsr decsp2 ; Make room ldy #2 lda (c_sp),y -.if (.cpu .bitand CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) sta (c_sp) ; 65C02 version iny ; Y = 3 .else @@ -43,7 +41,7 @@ toslong: jsr decsp2 ; Make room ldy #2 lda (c_sp),y -.if (.cpu .bitand CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) sta (c_sp) ; 65C02 version iny ; Y = 3 .else diff --git a/libsrc/runtime/umul8x16r24.s b/libsrc/runtime/umul8x16r24.s index 54d730558..115a3e1a4 100644 --- a/libsrc/runtime/umul8x16r24.s +++ b/libsrc/runtime/umul8x16r24.s @@ -9,8 +9,6 @@ .include "zeropage.inc" - .macpack cpu - ;--------------------------------------------------------------------------- ; 8x16 => 24 unsigned multiplication routine. Because the overhead for a ; 8x16 => 16 unsigned multiplication routine is small, we will tag it with @@ -31,7 +29,7 @@ umul8x16r16: umul8x16r24m: umul8x16r16m: -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_STZ) stz ptr1+1 stz sreg .else diff --git a/libsrc/runtime/xor.s b/libsrc/runtime/xor.s index 15394413c..1236b2c37 100644 --- a/libsrc/runtime/xor.s +++ b/libsrc/runtime/xor.s @@ -9,12 +9,10 @@ .import addysp1 .importzp c_sp, tmp1 - .macpack cpu - tosxora0: ldx #$00 tosxorax: -.if (.cpu .bitand CPU_ISET_65SC02) +.if .cap(CPU_HAS_ZPIND) eor (c_sp) ldy #1 .else diff --git a/libsrc/tgi/tgi_settextstyle.s b/libsrc/tgi/tgi_settextstyle.s index b62d6904c..bb924c048 100644 --- a/libsrc/tgi/tgi_settextstyle.s +++ b/libsrc/tgi/tgi_settextstyle.s @@ -9,8 +9,6 @@ .import umul8x16r24 .import popa, popax - .macpack cpu - ;----------------------------------------------------------------------------- ; void __fastcall__ tgi_settextstyle (unsigned width, unsigned height, ; unsigned char dir, unsigned char font); @@ -82,7 +80,7 @@ process_onedim: ; Disallowing characters larger than 256 pixels, we just drop the high byte ; and remember the low 16 bit as size in 8.8 format. -.if (.cpu .bitand ::CPU_ISET_65SC02) +.if .cap(CPU_HAS_PUSHXY) phy ; Save Y jsr umul8x16r24 ply ; Restore Y