]> git.sur5r.net Git - cc65/blobdiff - libsrc/common/tolower.s
The spans do now contain the size of a span, no longer the end offset.
[cc65] / libsrc / common / tolower.s
index 5ecc92f09cc1c6b07127b2526d764fdcbe04afaa..f44aa9cad2778be6f40788339dbc5ef9e9e4cff5 100644 (file)
@@ -5,18 +5,17 @@
 ;
 
        .export         _tolower
-       .import         __ctype, __cdiff
+       .import         __ctype
 
 _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
-       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     #<('A'-'a')     ; Make lower case char (carry already set)
+L9:            rts