From dccc89edaebdf39d8a3f16a96f2816dee472a5fb Mon Sep 17 00:00:00 2001 From: cuz Date: Thu, 19 Apr 2001 06:46:01 +0000 Subject: [PATCH] Squeezed a few cycles/bytes out of tolower and toupper. git-svn-id: svn://svn.cc65.org/cc65/trunk@690 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- libsrc/common/tolower.s | 13 +++++-------- libsrc/common/toupper.s | 9 +++------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/libsrc/common/tolower.s b/libsrc/common/tolower.s index 5ecc92f09..fa03146b0 100644 --- a/libsrc/common/tolower.s +++ b/libsrc/common/tolower.s @@ -10,13 +10,10 @@ _tolower: tay ; Get C into Y lda __ctype,y ; Get character classification - and #$02 ; Is this an upper case char? - beq L1 ; Jump if no + lsr a + lsr a ; Get bit 1 (upper case char) into carry tya ; Get char back into A - sec - sbc __cdiff ; make lower case char - rts ; CC are set - -L1: tya ; Get char back into A - rts ; CC are set + bcc L9 ; Jump if no upper case char + sbc __cdiff ; make lower case char (carry already set) +L9: rts ; CC are set diff --git a/libsrc/common/toupper.s b/libsrc/common/toupper.s index 43ff0812d..ab7711cb2 100644 --- a/libsrc/common/toupper.s +++ b/libsrc/common/toupper.s @@ -10,13 +10,10 @@ _toupper: tay ; Get c into Y lda __ctype,y ; Get character classification - and #$01 ; Mask lower char bit - beq L1 ; Jump if not lower char + lsr a ; Get bit 0 (lower char) into carry tya ; Get C back into A + bcc L9 ; Jump if not lower char clc adc __cdiff ; make upper case char - rts ; CC are set - -L1: tya ; Get C back - rts ; CC are set +L9: rts ; CC are set -- 2.39.5