2020-04-02 09:15:53 +00:00
|
|
|
; toupper.s
|
2000-05-28 13:40:48 +00:00
|
|
|
;
|
2020-04-02 09:15:53 +00:00
|
|
|
; This file is part of
|
|
|
|
; cc65 - a freeware C compiler for 6502 based systems
|
|
|
|
;
|
|
|
|
; https://cc65.github.io
|
|
|
|
;
|
|
|
|
; See "LICENSE" file for legal information.
|
2000-05-28 13:40:48 +00:00
|
|
|
;
|
|
|
|
; int toupper (int c);
|
|
|
|
;
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export _toupper
|
2020-04-02 09:15:53 +00:00
|
|
|
.include "ctype.inc"
|
2020-04-02 20:58:16 +00:00
|
|
|
.import ctypemaskdirect
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
_toupper:
|
2020-04-02 20:14:22 +00:00
|
|
|
cpx #$00 ; out of range?
|
|
|
|
bne @L2 ; if so, return the argument unchanged
|
|
|
|
tay ; save char
|
2020-04-02 20:58:16 +00:00
|
|
|
jsr ctypemaskdirect ; get character classification
|
2020-04-02 20:14:22 +00:00
|
|
|
and #CT_LOWER ; lower case char?
|
|
|
|
beq @L1 ; jump if no
|
|
|
|
tya ; restore char
|
2020-04-02 20:58:16 +00:00
|
|
|
adc #<('A'-'a') ; make upper case char (ctypemaskdirect ensures carry clear)
|
2020-04-02 09:15:53 +00:00
|
|
|
rts
|
2020-04-02 20:14:22 +00:00
|
|
|
@L1: tya ; restore char
|
|
|
|
@L2: rts
|