]> git.sur5r.net Git - cc65/commitdiff
Squeezed a few cycles/bytes out of tolower and toupper.
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Thu, 19 Apr 2001 06:46:01 +0000 (06:46 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Thu, 19 Apr 2001 06:46:01 +0000 (06:46 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@690 b7a2c559-68d2-44c3-8de9-860c34a00d81

libsrc/common/tolower.s
libsrc/common/toupper.s

index 5ecc92f09cc1c6b07127b2526d764fdcbe04afaa..fa03146b0b8816be4c68427828aedfa28d3672f4 100644 (file)
 _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
 
index 43ff0812d5cb54bb7c01f8452052a9c1f067e7b9..ab7711cb214ed252803342d814c741c972243296 100644 (file)
 _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