From: cuz Date: Mon, 11 Nov 2002 11:58:20 +0000 (+0000) Subject: Handle arguments outside char range correctly X-Git-Tag: V2.12.0~2131 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bafba1d673cecd1b884765bddb405ab8e66b5045;p=cc65 Handle arguments outside char range correctly git-svn-id: svn://svn.cc65.org/cc65/trunk@1501 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- 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