diff --git a/libsrc/apple2/ctype.s b/libsrc/apple2/ctype.s index 007e2cdd2..f54d50abe 100644 --- a/libsrc/apple2/ctype.s +++ b/libsrc/apple2/ctype.s @@ -8,16 +8,6 @@ .rodata -; Value that must be added to an upper case char to make it lower case -; char (example: for ASCII, this must be $E0). - - - .export __cdiff - -__cdiff: - .byte $E0 - - ; The following 256 byte wide table specifies attributes for the isxxx type ; of functions. Doing it by a table means some overhead in space, but it ; has major advantages: diff --git a/libsrc/atari/ctype.s b/libsrc/atari/ctype.s index 26658679e..8dbed2700 100644 --- a/libsrc/atari/ctype.s +++ b/libsrc/atari/ctype.s @@ -10,16 +10,6 @@ .rodata -; Value that must be added to an upper case char to make it lower case -; char (example: for ASCII, this must be $E0). - - - .export __cdiff - -__cdiff: - .byte $E0 - - ; The following 256 byte wide table specifies attributes for the isxxx type ; of functions. Doing it by a table means some overhead in space, but it ; has major advantages: diff --git a/libsrc/cbm/ctype.s b/libsrc/cbm/ctype.s index 4c50e09c1..5044ec9dc 100644 --- a/libsrc/cbm/ctype.s +++ b/libsrc/cbm/ctype.s @@ -8,16 +8,6 @@ .rodata -; Value that must be added to a lower case char to make it an upper case -; char (example: for ASCII, this must be $E0). - - - .export __cdiff - -__cdiff: - .byte $80 - - ; The following 256 byte wide table specifies attributes for the isxxx type ; of functions. Doing it by a table means some overhead in space, but it ; has major advantages: diff --git a/libsrc/common/stricmp.s b/libsrc/common/stricmp.s index 62e2f847c..73cb580cb 100644 --- a/libsrc/common/stricmp.s +++ b/libsrc/common/stricmp.s @@ -7,27 +7,27 @@ .export _stricmp, _strcasecmp .import popax - .import __ctype, __cdiff + .import __ctype .importzp ptr1, ptr2, tmp1 _stricmp: _strcasecmp: - sta ptr2 ; Save s2 + sta ptr2 ; Save s2 stx ptr2+1 - jsr popax ; get s1 + jsr popax ; get s1 sta ptr1 stx ptr1+1 ldy #0 -loop: lda (ptr2),y ; get char from second string +loop: lda (ptr2),y ; get char from second string tax - lda __ctype,x ; get character classification - and #$01 ; lower case char? - beq L1 ; jump if no - txa ; get character back + lda __ctype,x ; get character classification + and #$01 ; lower case char? + beq L1 ; jump if no + txa ; get character back clc - adc __cdiff ; make upper case char + adc #<('A'-'a') ; make upper case char tax ; L1: stx tmp1 ; remember upper case equivalent @@ -38,7 +38,7 @@ L1: stx tmp1 ; remember upper case equivalent beq L2 ; jump if no txa ; get character back clc - adc __cdiff ; make upper case char + adc #<('A'-'a') ; make upper case char tax L2: cpx tmp1 ; compare characters diff --git a/libsrc/common/strlower.s b/libsrc/common/strlower.s index 49e906bea..858b8e181 100644 --- a/libsrc/common/strlower.s +++ b/libsrc/common/strlower.s @@ -9,27 +9,27 @@ .export _strlower, _strlwr .import popax - .import __ctype, __cdiff + .import __ctype .importzp ptr1, ptr2 _strlower: _strlwr: - sta ptr1 ; Save s (working copy) - stx ptr1+1 + sta ptr1 ; Save s (working copy) + stx ptr1+1 sta ptr2 - sta ptr2+2 ; save function result + sta ptr2+2 ; save function result ldy #0 -loop: lda (ptr1),y ; get character - beq L9 ; jump if done +loop: lda (ptr1),y ; get character + beq L9 ; jump if done tax - lda __ctype,x ; get character classification - and #$02 ; upper case char? - beq L1 ; jump if no - txa ; get character back into accu + lda __ctype,x ; get character classification + and #$02 ; upper case char? + beq L1 ; jump if no + txa ; get character back into accu sec - sbc __cdiff ; make lower case char - sta (ptr1),y ; store back + sbc #<('A'-'a') ; make lower case char + sta (ptr1),y ; store back L1: iny ; next char bne loop inc ptr1+1 ; handle offset overflow diff --git a/libsrc/common/strupper.s b/libsrc/common/strupper.s index 80019ac9a..b330ab8c1 100644 --- a/libsrc/common/strupper.s +++ b/libsrc/common/strupper.s @@ -9,13 +9,13 @@ .export _strupper, _strupr .import popax - .import __ctype, __cdiff + .import __ctype .importzp ptr1, ptr2 _strupper: _strupr: sta ptr1 ; Save s (working copy) - stx ptr1+1 + stx ptr1+1 sta ptr2 sta ptr2+2 ; save function result ldy #0 @@ -28,7 +28,7 @@ loop: lda (ptr1),y ; get character beq L1 ; jump if no txa ; get character back into accu clc - adc __cdiff ; make upper case char + adc #<('A'-'a') ; make upper case char sta (ptr1),y ; store back L1: iny ; next char bne loop diff --git a/libsrc/common/tolower.s b/libsrc/common/tolower.s index 0c67199a3..f44aa9cad 100644 --- a/libsrc/common/tolower.s +++ b/libsrc/common/tolower.s @@ -5,7 +5,7 @@ ; .export _tolower - .import __ctype, __cdiff + .import __ctype _tolower: cpx #$00 ; Outside valid range? @@ -16,6 +16,6 @@ _tolower: lsr a ; Get bit 1 (upper case char) into carry tya ; Get char back into A bcc L9 ; Jump if no upper case char - sbc __cdiff ; Make lower case char (carry already set) + sbc #<('A'-'a') ; Make lower case char (carry already set) L9: rts diff --git a/libsrc/common/toupper.s b/libsrc/common/toupper.s index 5561eb7d4..adc3d4a33 100644 --- a/libsrc/common/toupper.s +++ b/libsrc/common/toupper.s @@ -5,7 +5,7 @@ ; .export _toupper - .import __ctype, __cdiff + .import __ctype _toupper: cpx #$00 ; Outside valid range? @@ -16,6 +16,6 @@ _toupper: tya ; Get C back into A bcc L9 ; Jump if not lower char clc - adc __cdiff ; make upper case char + adc #<('A'-'a') ; make upper case char L9: rts ; CC are set