2020-04-02 11:15:53 +02:00
|
|
|
; toupper.s
|
2000-05-28 13:40:48 +00:00
|
|
|
;
|
2020-04-02 11:15:53 +02: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 13:56:54 +02:00
|
|
|
.export _toupper
|
2020-04-02 11:15:53 +02:00
|
|
|
.include "ctype.inc"
|
|
|
|
.import ctype_preprocessor
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
_toupper:
|
2020-04-02 11:15:53 +02:00
|
|
|
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)
|
|
|
|
rts
|