diff --git a/asminc/ctype.inc b/asminc/ctype.inc index 18a290fbe..4d9ae7986 100644 --- a/asminc/ctype.inc +++ b/asminc/ctype.inc @@ -14,15 +14,15 @@ ; Define bitmapped constants for the table entries -CT_NONE = $00 ; Nothing special -CT_LOWER = $01 ; 0 - Lower case char -CT_UPPER = $02 ; 1 - Upper case char -CT_DIGIT = $04 ; 2 - Numeric digit -CT_XDIGIT = $08 ; 3 - Hex digit (both, lower and upper) -CT_CTRL = $10 ; 4 - Control character -CT_SPACE = $20 ; 5 - The space character itself -CT_OTHER_WS = $40 ; 6 - Other whitespace ('\f', '\n', '\r', '\t' and '\v') -CT_SPACE_TAB = $80 ; 7 - Space or tab character +CT_NONE = %00000000 ; Nothing special +CT_LOWER = %00000001 ; 0 - Lower case char +CT_UPPER = %00000010 ; 1 - Upper case char +CT_DIGIT = %00000100 ; 2 - Numeric digit +CT_XDIGIT = %00001000 ; 3 - Hex digit (both, lower and upper) +CT_CTRL = %00010000 ; 4 - Control character +CT_SPACE = %00100000 ; 5 - The space character itself +CT_OTHER_WS = %01000000 ; 6 - Other whitespace ('\f', '\n', '\r', '\t' and '\v') +CT_SPACE_TAB = %10000000 ; 7 - Space or tab character ; Combined stuff CT_ALNUM = (CT_LOWER | CT_UPPER | CT_DIGIT) diff --git a/asminc/ctype_common.inc b/asminc/ctype_common.inc index 04aaa8f95..044c2834f 100644 --- a/asminc/ctype_common.inc +++ b/asminc/ctype_common.inc @@ -11,13 +11,13 @@ ; .include "ctypetable.inc" - .export __ctypeIdx + .export __ctypeidx ; The tables are readonly, put them into the rodata segment .rodata -__ctypeIdx: +__ctypeidx: ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 0/00 ___ctrl_@___, 1/01 ___ctrl_A___ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 2/02 ___ctrl_B___, 3/03 ___ctrl_C___ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 4/04 ___ctrl_D___, 5/05 ___ctrl_E___ diff --git a/libsrc/atari/ctype.s b/libsrc/atari/ctype.s index 7903dc2a3..2f219f8c3 100644 --- a/libsrc/atari/ctype.s +++ b/libsrc/atari/ctype.s @@ -11,13 +11,13 @@ ; .include "ctypetable.inc" - .export __ctypeIdx + .export __ctypeidx ; The tables are readonly, put them into the rodata segment .rodata -__ctypeIdx: +__ctypeidx: ct_mix CT_NONE_IDX, CT_NONE_IDX ; 0/00 ___heart____, 1/01 ___l_tee____ ct_mix CT_NONE_IDX, CT_NONE_IDX ; 2/02 ___ctrl_B___, 3/03 ___ctrl_C___ ct_mix CT_NONE_IDX, CT_NONE_IDX ; 4/04 ___r_tee____, 5/05 ___ctrl_E___ diff --git a/libsrc/atmos/ctype.s b/libsrc/atmos/ctype.s index 7ca01b32a..90a3baa6e 100644 --- a/libsrc/atmos/ctype.s +++ b/libsrc/atmos/ctype.s @@ -11,13 +11,13 @@ ; .include "ctypetable.inc" - .export __ctypeIdx + .export __ctypeidx ; The tables are readonly, put them into the rodata segment .rodata -__ctypeIdx: +__ctypeidx: ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 0/00 ___ctrl_@___, 1/01 ___ctrl_A___ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 2/02 ___ctrl_B___, 3/03 ___ctrl_C___ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 4/04 ___ctrl_D___, 5/05 ___ctrl_E___ diff --git a/libsrc/cbm/ctype.s b/libsrc/cbm/ctype.s index 77a37431d..7388f68b8 100644 --- a/libsrc/cbm/ctype.s +++ b/libsrc/cbm/ctype.s @@ -12,13 +12,13 @@ ; This table is taken from Craig S. Bruce's technical docs. for the ACE OS. .include "ctypetable.inc" - .export __ctypeIdx + .export __ctypeidx ; The tables are readonly, put them into the rodata segment .rodata -__ctypeIdx: +__ctypeidx: ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 0/00 ___rvs_@___, 1/01 ___rvs_a___ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 2/02 ___rvs_b___, 3/03 ___rvs_c___ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 4/04 ___rvs_d___, 5/05 ___rvs_e___ diff --git a/libsrc/common/atoi.s b/libsrc/common/atoi.s index 10f917f86..0236b77f2 100644 --- a/libsrc/common/atoi.s +++ b/libsrc/common/atoi.s @@ -8,7 +8,7 @@ .export _atoi, _atol .import negeax, __ctype .importzp sreg, ptr1, ptr2, tmp1 - .import ctype_preprocessor_no_check + .import ctypemaskdirect .include "ctype.inc" ; ; Conversion routine (32 bit) @@ -26,9 +26,7 @@ _atol: sta ptr1 ; store s ; Skip whitespace L1: lda (ptr1),y - ; get character classification - jsr ctype_preprocessor_no_check - + jsr ctypemaskdirect ; get character classification and #CT_SPACE_TAB ; tab or space? beq L2 ; jump if no iny diff --git a/libsrc/common/ctype.s b/libsrc/common/ctype.s index 15f115e7d..220ad79c1 100644 --- a/libsrc/common/ctype.s +++ b/libsrc/common/ctype.s @@ -11,13 +11,13 @@ ; .include "ctypetable.inc" - .export __ctypeIdx + .export __ctypeidx ; The tables are readonly, put them into the rodata segment .rodata -__ctypeIdx: +__ctypeidx: .repeat 2 ; 2 times for normal and inverted diff --git a/libsrc/common/ctype_preprocessor.s b/libsrc/common/ctypemask.s similarity index 80% rename from libsrc/common/ctype_preprocessor.s rename to libsrc/common/ctypemask.s index 79d93860f..b518a10c0 100644 --- a/libsrc/common/ctype_preprocessor.s +++ b/libsrc/common/ctypemask.s @@ -1,4 +1,4 @@ -; ctype_preprocessor.s +; ctypemask.s ; ; This file is part of ; cc65 - a freeware C compiler for 6502 based systems @@ -7,7 +7,7 @@ ; ; See "LICENSE" file for legal information. ; -; ctype_preprocessor(int c) +; ctypemask(int c) ; ; converts a character to test via the is*-functions to the matching ctype-masks ; If c is out of the 8-bit range, the function returns with carry set and accu cleared. @@ -18,18 +18,18 @@ ; while calling this function! ; - .export ctype_preprocessor - .export ctype_preprocessor_no_check + .export ctypemask + .export ctypemaskdirect .import __ctype - .import __ctypeIdx + .import __ctypeidx -ctype_preprocessor: +ctypemask: cpx #$00 ; char range ok? bne SC ; branch if not -ctype_preprocessor_no_check: +ctypemaskdirect: lsr a tax - lda __ctypeIdx,x + lda __ctypeidx,x bcc @lowerNibble @upperNibble: lsr a diff --git a/libsrc/common/isalnum.s b/libsrc/common/isalnum.s index 2a05e32ee..ec2c9de1f 100644 --- a/libsrc/common/isalnum.s +++ b/libsrc/common/isalnum.s @@ -12,10 +12,10 @@ .export _isalnum .include "ctype.inc" - .import ctype_preprocessor + .import ctypemask _isalnum: - jsr ctype_preprocessor ; (always clears X) + jsr ctypemask ; (always clears X) bcs @L1 ; out of range? (everything already clear -> false) and #CT_ALNUM ; mask character/digit bits @L1: rts diff --git a/libsrc/common/isalpha.s b/libsrc/common/isalpha.s index 7a1f79d20..2d1f4b584 100644 --- a/libsrc/common/isalpha.s +++ b/libsrc/common/isalpha.s @@ -12,10 +12,10 @@ .export _isalpha .include "ctype.inc" - .import ctype_preprocessor + .import ctypemask _isalpha: - jsr ctype_preprocessor ; (always clears X) + jsr ctypemask ; (always clears X) bcs @L1 ; out of range? (everything already clear -> false) and #CT_ALPHA ; mask character bits @L1: rts diff --git a/libsrc/common/isblank.s b/libsrc/common/isblank.s index cc5b9e5ab..a9788daac 100644 --- a/libsrc/common/isblank.s +++ b/libsrc/common/isblank.s @@ -14,10 +14,10 @@ .export _isblank .include "ctype.inc" - .import ctype_preprocessor + .import ctypemask _isblank: - jsr ctype_preprocessor ; (always clears X) + jsr ctypemask ; (always clears X) bcs @L1 ; out of range? (everything already clear -> false) and #CT_SPACE_TAB ; mask blank bit @L1: rts diff --git a/libsrc/common/iscntrl.s b/libsrc/common/iscntrl.s index 65e2111be..7a4879017 100644 --- a/libsrc/common/iscntrl.s +++ b/libsrc/common/iscntrl.s @@ -12,10 +12,10 @@ .export _iscntrl .include "ctype.inc" - .import ctype_preprocessor + .import ctypemask _iscntrl: - jsr ctype_preprocessor ; (always clears X) + jsr ctypemask ; (always clears X) bcs @L1 ; out of range? (everything already clear -> false) and #CT_CTRL ; mask control character bit @L1: rts diff --git a/libsrc/common/isdigit.s b/libsrc/common/isdigit.s index 76b2d1b27..ae3f8d12f 100644 --- a/libsrc/common/isdigit.s +++ b/libsrc/common/isdigit.s @@ -12,10 +12,10 @@ .export _isdigit .include "ctype.inc" - .import ctype_preprocessor + .import ctypemask _isdigit: - jsr ctype_preprocessor ; (always clears X) + jsr ctypemask ; (always clears X) bcs @L1 ; out of range? (everything already clear -> false) and #CT_DIGIT ; mask digit bit @L1: rts diff --git a/libsrc/common/isgraph.s b/libsrc/common/isgraph.s index 6dd91ed35..8b97780b9 100644 --- a/libsrc/common/isgraph.s +++ b/libsrc/common/isgraph.s @@ -12,10 +12,10 @@ .export _isgraph .include "ctype.inc" - .import ctype_preprocessor + .import ctypemask _isgraph: - jsr ctype_preprocessor ; (always clears X) + jsr ctypemask ; (always clears X) bcs @L1 ; out of range? (everything already clear -> false) and #CT_CTRL_SPACE ; mask character bits cmp #1 ; if false, then set "borrow" flag diff --git a/libsrc/common/islower.s b/libsrc/common/islower.s index a11ee129c..b19c16825 100644 --- a/libsrc/common/islower.s +++ b/libsrc/common/islower.s @@ -12,12 +12,12 @@ .export _islower .include "ctype.inc" - .import ctype_preprocessor + .import ctypemask _islower: - jsr ctype_preprocessor ; (always clears X) - bcs @L1 ; out of range? (everything already clear -> false) - and #CT_LOWER ; mask lower char bit + jsr ctypemask ; (always clears X) + bcs @L1 ; out of range? (everything already clear -> false) + and #CT_LOWER ; mask lower char bit @L1: rts diff --git a/libsrc/common/isprint.s b/libsrc/common/isprint.s index e1d63bc6b..c62bd784f 100644 --- a/libsrc/common/isprint.s +++ b/libsrc/common/isprint.s @@ -12,11 +12,11 @@ .export _isprint .include "ctype.inc" - .import ctype_preprocessor + .import ctypemask _isprint: - jsr ctype_preprocessor ; (always clears X) - bcs @L1 ; out of range? (everything already clear -> false) - eor #CT_CTRL ; NOT a control char - and #CT_CTRL ; mask control char bit + jsr ctypemask ; (always clears X) + bcs @L1 ; out of range? (everything already clear -> false) + eor #CT_CTRL ; NOT a control char + and #CT_CTRL ; mask control char bit @L1: rts diff --git a/libsrc/common/ispunct.s b/libsrc/common/ispunct.s index ac4ab7f1d..df47322fb 100644 --- a/libsrc/common/ispunct.s +++ b/libsrc/common/ispunct.s @@ -12,13 +12,13 @@ .export _ispunct .include "ctype.inc" - .import ctype_preprocessor + .import ctypemask _ispunct: - jsr ctype_preprocessor ; (always clears X) - bcs @L1 ; out of range? (everything already clear -> false) - and #CT_NOT_PUNCT ; mask relevant bits - cmp #1 ; if false, then set "borrow" flag + jsr ctypemask ; (always clears X) + bcs @L1 ; out of range? (everything already clear -> false) + and #CT_NOT_PUNCT ; mask relevant bits + cmp #1 ; if false, then set "borrow" flag lda #0 - sbc #0 ; invert logic (return NOT (space | control | digit | alpha)) + sbc #0 ; invert logic (return NOT (space | control | digit | alpha)) @L1: rts diff --git a/libsrc/common/isspace.s b/libsrc/common/isspace.s index c37023449..b234febfa 100644 --- a/libsrc/common/isspace.s +++ b/libsrc/common/isspace.s @@ -12,10 +12,10 @@ .export _isspace .include "ctype.inc" - .import ctype_preprocessor + .import ctypemask _isspace: - jsr ctype_preprocessor ; (always clears X) - bcs @L1 ; out of range? (everything already clear -> false) - and #(CT_SPACE | CT_OTHER_WS) ; mask space bits + jsr ctypemask ; (always clears X) + bcs @L1 ; out of range? (everything already clear -> false) + and #(CT_SPACE | CT_OTHER_WS) ; mask space bits @L1: rts diff --git a/libsrc/common/isupper.s b/libsrc/common/isupper.s index 175fb872b..45f48d871 100644 --- a/libsrc/common/isupper.s +++ b/libsrc/common/isupper.s @@ -12,10 +12,10 @@ .export _isupper .include "ctype.inc" - .import ctype_preprocessor + .import ctypemask _isupper: - jsr ctype_preprocessor ; (always clears X) - bcs @L1 ; out of range? (everything already clear -> false) - and #CT_UPPER ; mask upper char bit + jsr ctypemask ; (always clears X) + bcs @L1 ; out of range? (everything already clear -> false) + and #CT_UPPER ; mask upper char bit @L1: rts diff --git a/libsrc/common/isxdigit.s b/libsrc/common/isxdigit.s index e8a12a10e..6d59e2ac8 100644 --- a/libsrc/common/isxdigit.s +++ b/libsrc/common/isxdigit.s @@ -12,10 +12,10 @@ .export _isxdigit .include "ctype.inc" - .import ctype_preprocessor + .import ctypemask _isxdigit: - jsr ctype_preprocessor ; (always clears X) - bcs @L1 ; out of range? (everything already clear -> false) - and #CT_XDIGIT ; mask xdigit bit + jsr ctypemask ; (always clears X) + bcs @L1 ; out of range? (everything already clear -> false) + and #CT_XDIGIT ; mask xdigit bit @L1: rts diff --git a/libsrc/common/stricmp.s b/libsrc/common/stricmp.s index 3a03258bd..494350b06 100644 --- a/libsrc/common/stricmp.s +++ b/libsrc/common/stricmp.s @@ -14,7 +14,7 @@ .export _stricmp, _strcasecmp .import popptr1 .importzp ptr1, ptr2, tmp1, tmp2 - .import ctype_preprocessor_no_check + .import ctypemaskdirect .include "ctype.inc" _stricmp: @@ -26,22 +26,20 @@ _strcasecmp: loop: lda (ptr2),y ; get char from second string sta tmp2 ; and save it - ; get character classification - jsr ctype_preprocessor_no_check + jsr ctypemaskdirect ; get character classification and #CT_LOWER ; lower case char? beq L1 ; jump if no lda #<('A'-'a') ; make upper case char - adc tmp2 ; ctype_preprocessor_no_check ensures carry clear! + adc tmp2 ; ctypemaskdirect ensures carry clear! sta tmp2 ; remember upper case equivalent L1: lda (ptr1),y ; get character from first string sta tmp1 - ; get character classification - jsr ctype_preprocessor_no_check + jsr ctypemaskdirect ; get character classification and #CT_LOWER ; lower case char? beq L2 ; jump if no lda #<('A'-'a') ; make upper case char - adc tmp1 ; ctype_preprocessor_no_check ensures carry clear! + adc tmp1 ; ctypemaskdirect ensures carry clear! sta tmp1 ; remember upper case equivalent L2: ldx tmp1 diff --git a/libsrc/common/strlower.s b/libsrc/common/strlower.s index 479d852e8..b7c1a289b 100644 --- a/libsrc/common/strlower.s +++ b/libsrc/common/strlower.s @@ -11,7 +11,7 @@ .export _strlower, _strlwr .import popax .importzp ptr1, ptr2 - .import ctype_preprocessor_no_check + .import ctypemaskdirect .include "ctype.inc" _strlower: @@ -24,12 +24,11 @@ _strlwr: loop: lda (ptr1),y ; get character beq L9 ; jump if done - ; get character classification - jsr ctype_preprocessor_no_check + jsr ctypemaskdirect ; get character classification and #CT_UPPER ; upper case char? beq L1 ; jump if no lda (ptr1),y ; fetch character again - adc #<('a'-'A') ; make lower case char (ctype_preprocessor_no_check ensures carry clear) + adc #<('a'-'A') ; make lower case char (ctypemaskdirect ensures carry clear) sta (ptr1),y ; store back L1: iny ; next char bne loop diff --git a/libsrc/common/strnicmp.s b/libsrc/common/strnicmp.s index c4cc272d9..43d6d0d50 100644 --- a/libsrc/common/strnicmp.s +++ b/libsrc/common/strnicmp.s @@ -9,7 +9,7 @@ .export _strnicmp, _strncasecmp .import popax, popptr1 .importzp ptr1, ptr2, ptr3, tmp1, tmp2 - .import ctype_preprocessor_no_check + .import ctypemaskdirect .include "ctype.inc" _strnicmp: @@ -47,22 +47,20 @@ Loop: inc ptr3 Comp: lda (ptr2),y sta tmp2 ; remember original char - ; get character classification - jsr ctype_preprocessor_no_check + jsr ctypemaskdirect ; get character classification and #CT_LOWER ; lower case char? beq L1 ; jump if no lda #<('A'-'a') ; make upper case char - adc tmp2 ; ctype_preprocessor_no_check ensures carry clear! + adc tmp2 ; ctypemaskdirect ensures carry clear! sta tmp2 ; remember upper case equivalent L1: lda (ptr1),y ; get character from first string sta tmp1 ; remember original char - ; get character classification - jsr ctype_preprocessor_no_check + jsr ctypemaskdirect ; get character classification and #CT_LOWER ; lower case char? beq L2 ; jump if no lda #<('A'-'a') ; make upper case char - adc tmp1 ; ctype_preprocessor_no_check ensures carry clear! + adc tmp1 ; ctypemaskdirect ensures carry clear! sta tmp1 ; remember upper case equivalent L2: ldx tmp1 diff --git a/libsrc/common/strupper.s b/libsrc/common/strupper.s index e2160d4da..3af0d8d98 100644 --- a/libsrc/common/strupper.s +++ b/libsrc/common/strupper.s @@ -11,7 +11,7 @@ .export _strupper, _strupr .import popax .importzp ptr1, ptr2 - .import ctype_preprocessor_no_check + .import ctypemaskdirect .include "ctype.inc" _strupper: @@ -24,11 +24,11 @@ _strupr: loop: lda (ptr1),y ; get character beq L9 ; jump if done - jsr ctype_preprocessor_no_check + jsr ctypemaskdirect ; get character classification and #CT_LOWER ; lower case char? beq L1 ; jump if no lda (ptr1),y ; fetch character again - adc #<('A'-'a') ; make upper case char (ctype_preprocessor_no_check ensures carry clear) + adc #<('A'-'a') ; make upper case char (ctypemaskdirect ensures carry clear) sta (ptr1),y ; store back L1: iny ; next char bne loop diff --git a/libsrc/common/tolower.s b/libsrc/common/tolower.s index bebac3c57..828be1cb1 100644 --- a/libsrc/common/tolower.s +++ b/libsrc/common/tolower.s @@ -12,17 +12,17 @@ .export _tolower .include "ctype.inc" - .import ctype_preprocessor_no_check + .import ctypemaskdirect _tolower: cpx #$00 ; out of range? bne @L2 ; if so, return the argument unchanged tay ; save char - jsr ctype_preprocessor_no_check + jsr ctypemaskdirect ; get character classification and #CT_UPPER ; upper case char? beq @L1 ; jump if no tya ; restore char - adc #<('a'-'A') ; make lower case char (ctype_preprocessor_no_check ensures carry clear) + adc #<('a'-'A') ; make lower case char (ctypemaskdirect ensures carry clear) rts @L1: tya ; restore char @L2: rts diff --git a/libsrc/common/toupper.s b/libsrc/common/toupper.s index ed3dd9b07..d0465f64f 100644 --- a/libsrc/common/toupper.s +++ b/libsrc/common/toupper.s @@ -12,17 +12,17 @@ .export _toupper .include "ctype.inc" - .import ctype_preprocessor_no_check + .import ctypemaskdirect _toupper: cpx #$00 ; out of range? bne @L2 ; if so, return the argument unchanged tay ; save char - jsr ctype_preprocessor_no_check + jsr ctypemaskdirect ; get character classification and #CT_LOWER ; lower case char? beq @L1 ; jump if no tya ; restore char - adc #<('A'-'a') ; make upper case char (ctype_preprocessor_no_check ensures carry clear) + adc #<('A'-'a') ; make upper case char (ctypemaskdirect ensures carry clear) rts @L1: tya ; restore char @L2: rts diff --git a/libsrc/geos-common/system/ctype.s b/libsrc/geos-common/system/ctype.s index 013a1ba99..b34f68470 100644 --- a/libsrc/geos-common/system/ctype.s +++ b/libsrc/geos-common/system/ctype.s @@ -13,13 +13,13 @@ ; http://lyonlabs.org/commodore/onrequest/geos-manuals/The_Hitchhikers_Guide_to_GEOS.pdf .include "ctypetable.inc" - .export __ctypeIdx + .export __ctypeidx ; The tables are readonly, put them into the rodata segment .rodata -__ctypeIdx: +__ctypeidx: ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 0/00 ____NULL___, 1/01 ____N/A____ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 2/02 ____N/A____, 3/03 ____N/A____ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 4/04 ____N/A____, 5/05 ____N/A____