From bafba1d673cecd1b884765bddb405ab8e66b5045 Mon Sep 17 00:00:00 2001 From: cuz Date: Mon, 11 Nov 2002 11:58:20 +0000 Subject: [PATCH] Handle arguments outside char range correctly git-svn-id: svn://svn.cc65.org/cc65/trunk@1501 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- libsrc/common/tolower.s | 6 ++++-- libsrc/common/toupper.s | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libsrc/common/tolower.s b/libsrc/common/tolower.s index fa03146b0..0c67199a3 100644 --- a/libsrc/common/tolower.s +++ b/libsrc/common/tolower.s @@ -8,12 +8,14 @@ .import __ctype, __cdiff _tolower: + cpx #$00 ; Outside valid range? + bne L9 ; If so, return the argument unchanged tay ; Get C into Y lda __ctype,y ; Get character classification lsr a 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) -L9: rts ; CC are set + sbc __cdiff ; Make lower case char (carry already set) +L9: rts diff --git a/libsrc/common/toupper.s b/libsrc/common/toupper.s index ab7711cb2..5561eb7d4 100644 --- a/libsrc/common/toupper.s +++ b/libsrc/common/toupper.s @@ -8,6 +8,8 @@ .import __ctype, __cdiff _toupper: + cpx #$00 ; Outside valid range? + bne L9 ; If so, return the argument unchanged tay ; Get c into Y lda __ctype,y ; Get character classification lsr a ; Get bit 0 (lower char) into carry -- 2.39.5