1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-25 02:29:52 +00:00
cc65/libsrc/common/strupper.s

43 lines
1.2 KiB
ArmAsm
Raw Normal View History

;
; 1998-06-02, Ullrich von Bassewitz
; 2013-08-28, Greg King
;
; char* __fastcall__ strupper (char* s);
; char* __fastcall__ strupr (char* s);
;
; Non-ANSI
;
.export _strupper, _strupr
.import popax
.importzp ptr1, ptr2
2020-04-02 20:58:16 +00:00
.import ctypemaskdirect
.include "ctype.inc"
_strupper:
_strupr:
2020-04-02 08:03:01 +00:00
sta ptr1 ; save s (working copy)
stx ptr1+1
sta ptr2
stx ptr2+1 ; save function result
ldy #0
loop: lda (ptr1),y ; get character
beq L9 ; jump if done
2020-04-02 20:58:16 +00:00
jsr ctypemaskdirect ; get character classification
and #CT_LOWER ; lower case char?
beq L1 ; jump if no
2020-01-02 17:57:03 +00:00
lda (ptr1),y ; fetch character again
2020-04-02 20:58:16 +00:00
adc #<('A'-'a') ; make upper case char (ctypemaskdirect ensures carry clear)
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