1
0
mirror of https://github.com/cc65/cc65.git synced 2025-08-13 08:25:28 +00:00

Fixed tolower() and toupper() to save high byte.

This commit is contained in:
Oliver Schmidt
2020-04-02 22:14:22 +02:00
parent df015f4766
commit 411fe87f64
2 changed files with 22 additions and 20 deletions

View File

@@ -12,16 +12,17 @@
.export _tolower .export _tolower
.include "ctype.inc" .include "ctype.inc"
.import ctype_preprocessor .import ctype_preprocessor_no_check
_tolower: _tolower:
tay ; save char cpx #$00 ; out of range?
jsr ctype_preprocessor ; (always clears X) bne @L2 ; if so, return the argument unchanged
bcc @L2 ; out of range? tay ; save char
@L1: tya ; if so, return the argument unchanged jsr ctype_preprocessor_no_check
rts and #CT_UPPER ; upper case char?
@L2: and #CT_UPPER ; upper case char? beq @L1 ; jump if no
beq @L1 ; jump if no tya ; restore char
tya ; restore char adc #<('a'-'A') ; make lower case char (ctype_preprocessor_no_check ensures carry clear)
adc #<('a'-'A') ; make lower case char (ctype_preprocessor ensures carry clear)
rts rts
@L1: tya ; restore char
@L2: rts

View File

@@ -12,16 +12,17 @@
.export _toupper .export _toupper
.include "ctype.inc" .include "ctype.inc"
.import ctype_preprocessor .import ctype_preprocessor_no_check
_toupper: _toupper:
tay ; save char cpx #$00 ; out of range?
jsr ctype_preprocessor ; (always clears X) bne @L2 ; if so, return the argument unchanged
bcc @L2 ; out of range? tay ; save char
@L1: tya ; if so, return the argument unchanged jsr ctype_preprocessor_no_check
rts and #CT_LOWER ; lower case char?
@L2: and #CT_LOWER ; lower case char? beq @L1 ; jump if no
beq @L1 ; jump if no tya ; restore char
tya ; restore char adc #<('A'-'a') ; make upper case char (ctype_preprocessor_no_check ensures carry clear)
adc #<('A'-'a') ; make upper case char (ctype_preprocessor ensures carry clear)
rts rts
@L1: tya ; restore char
@L2: rts