diff --git a/libsrc/common/tolower.s b/libsrc/common/tolower.s index e672f077e..bebac3c57 100644 --- a/libsrc/common/tolower.s +++ b/libsrc/common/tolower.s @@ -12,16 +12,17 @@ .export _tolower .include "ctype.inc" - .import ctype_preprocessor + .import ctype_preprocessor_no_check _tolower: - tay ; save char - jsr ctype_preprocessor ; (always clears X) - bcc @L2 ; out of range? -@L1: tya ; if so, return the argument unchanged - rts -@L2: and #CT_UPPER ; upper case char? - beq @L1 ; jump if no - tya ; restore char - adc #<('a'-'A') ; make lower case char (ctype_preprocessor ensures carry clear) + cpx #$00 ; out of range? + bne @L2 ; if so, return the argument unchanged + tay ; save char + jsr ctype_preprocessor_no_check + 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) rts +@L1: tya ; restore char +@L2: rts diff --git a/libsrc/common/toupper.s b/libsrc/common/toupper.s index 5b3a4c22d..ed3dd9b07 100644 --- a/libsrc/common/toupper.s +++ b/libsrc/common/toupper.s @@ -12,16 +12,17 @@ .export _toupper .include "ctype.inc" - .import ctype_preprocessor + .import ctype_preprocessor_no_check _toupper: - tay ; save char - jsr ctype_preprocessor ; (always clears X) - bcc @L2 ; out of range? -@L1: tya ; if so, return the argument unchanged - rts -@L2: and #CT_LOWER ; lower case char? - beq @L1 ; jump if no - tya ; restore char - adc #<('A'-'a') ; make upper case char (ctype_preprocessor ensures carry clear) + cpx #$00 ; out of range? + bne @L2 ; if so, return the argument unchanged + tay ; save char + jsr ctype_preprocessor_no_check + 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) rts +@L1: tya ; restore char +@L2: rts