2000-05-28 13:40:48 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 02.06.1998
|
|
|
|
;
|
|
|
|
; char* strupper (char* s);
|
|
|
|
; char* strupr (char* s);
|
|
|
|
;
|
|
|
|
; Non-ANSI
|
|
|
|
;
|
|
|
|
|
|
|
|
.export _strupper, _strupr
|
|
|
|
.import popax
|
2002-11-22 00:53:46 +00:00
|
|
|
.import __ctype
|
2000-05-28 13:40:48 +00:00
|
|
|
.importzp ptr1, ptr2
|
|
|
|
|
2009-02-10 22:11:56 +00:00
|
|
|
.include "ctype.inc"
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
_strupper:
|
|
|
|
_strupr:
|
|
|
|
sta ptr1 ; Save s (working copy)
|
2002-11-22 00:53:46 +00:00
|
|
|
stx ptr1+1
|
2000-05-28 13:40:48 +00:00
|
|
|
sta ptr2
|
2012-03-25 13:14:13 +00:00
|
|
|
sta ptr2+1 ; save function result
|
2000-05-28 13:40:48 +00:00
|
|
|
ldy #0
|
|
|
|
|
|
|
|
loop: lda (ptr1),y ; get character
|
|
|
|
beq L9 ; jump if done
|
|
|
|
tax
|
|
|
|
lda __ctype,x ; get character classification
|
2009-02-10 22:11:56 +00:00
|
|
|
and #CT_LOWER ; lower case char?
|
2000-05-28 13:40:48 +00:00
|
|
|
beq L1 ; jump if no
|
|
|
|
txa ; get character back into accu
|
|
|
|
clc
|
2002-11-22 00:53:46 +00:00
|
|
|
adc #<('A'-'a') ; make upper case char
|
2000-05-28 13:40:48 +00:00
|
|
|
sta (ptr1),y ; store back
|
|
|
|
L1: iny ; next char
|
|
|
|
bne loop
|
|
|
|
inc ptr1+1 ; handle offset overflow
|
|
|
|
bne loop ; branch always
|
|
|
|
|
|
|
|
; Done, return the argument string
|
|
|
|
|
|
|
|
L9: lda ptr2
|
|
|
|
ldx ptr2+1
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
|