mirror of
https://github.com/cc65/cc65.git
synced 2024-12-27 00:29:31 +00:00
Fixed tolower() and toupper() to save high byte.
This commit is contained in:
parent
df015f4766
commit
411fe87f64
@ -12,16 +12,17 @@
|
||||
|
||||
.export _tolower
|
||||
.include "ctype.inc"
|
||||
.import ctype_preprocessor
|
||||
.import ctype_preprocessor_no_check
|
||||
|
||||
_tolower:
|
||||
tay ; save char
|
||||
jsr ctype_preprocessor ; (always clears X)
|
||||
bcc @L2 ; out of range?
|
||||
@L1: tya ; if so, return the argument unchanged
|
||||
rts
|
||||
@L2: and #CT_UPPER ; upper case char?
|
||||
beq @L1 ; jump if no
|
||||
tya ; restore char
|
||||
adc #<('a'-'A') ; make lower case char (ctype_preprocessor ensures carry clear)
|
||||
cpx #$00 ; out of range?
|
||||
bne @L2 ; if so, return the argument unchanged
|
||||
tay ; save char
|
||||
jsr ctype_preprocessor_no_check
|
||||
and #CT_UPPER ; upper case char?
|
||||
beq @L1 ; jump if no
|
||||
tya ; restore char
|
||||
adc #<('a'-'A') ; make lower case char (ctype_preprocessor_no_check ensures carry clear)
|
||||
rts
|
||||
@L1: tya ; restore char
|
||||
@L2: rts
|
||||
|
@ -12,16 +12,17 @@
|
||||
|
||||
.export _toupper
|
||||
.include "ctype.inc"
|
||||
.import ctype_preprocessor
|
||||
.import ctype_preprocessor_no_check
|
||||
|
||||
_toupper:
|
||||
tay ; save char
|
||||
jsr ctype_preprocessor ; (always clears X)
|
||||
bcc @L2 ; out of range?
|
||||
@L1: tya ; if so, return the argument unchanged
|
||||
rts
|
||||
@L2: and #CT_LOWER ; lower case char?
|
||||
beq @L1 ; jump if no
|
||||
tya ; restore char
|
||||
adc #<('A'-'a') ; make upper case char (ctype_preprocessor ensures carry clear)
|
||||
cpx #$00 ; out of range?
|
||||
bne @L2 ; if so, return the argument unchanged
|
||||
tay ; save char
|
||||
jsr ctype_preprocessor_no_check
|
||||
and #CT_LOWER ; lower case char?
|
||||
beq @L1 ; jump if no
|
||||
tya ; restore char
|
||||
adc #<('A'-'a') ; make upper case char (ctype_preprocessor_no_check ensures carry clear)
|
||||
rts
|
||||
@L1: tya ; restore char
|
||||
@L2: rts
|
||||
|
Loading…
Reference in New Issue
Block a user