.import __ctype
.importzp sreg, ptr1, ptr2, tmp1
+ .include "ctype.inc"
+
;
; Conversion routine (32 bit)
;
L1: lda (ptr1),y
tax
lda __ctype,x ; get character classification
- and #$80 ; tab or space?
+ and #CT_SPACE_TAB ; tab or space?
beq L2 ; jump if no
iny
bne L1
.import __ctype
.importzp ptr1, ptr2, tmp1
+ .include "ctype.inc"
_stricmp:
_strcasecmp:
loop: lda (ptr2),y ; get char from second string
tax
lda __ctype,x ; get character classification
- and #$01 ; lower case char?
+ and #CT_LOWER ; lower case char?
beq L1 ; jump if no
txa ; get character back
clc
lda (ptr1),y ; get character from first string
tax
lda __ctype,x ; get character classification
- and #$01 ; lower case char?
+ and #CT_LOWER ; lower case char?
beq L2 ; jump if no
txa ; get character back
clc
adc #<('A'-'a') ; make upper case char
tax
-
+
L2: cpx tmp1 ; compare characters
bne L3
txa ; end of strings?
.import __ctype
.importzp ptr1, ptr2
+ .include "ctype.inc"
+
_strlower:
_strlwr:
sta ptr1 ; Save s (working copy)
beq L9 ; jump if done
tax
lda __ctype,x ; get character classification
- and #$02 ; upper case char?
+ and #CT_UPPER ; upper case char?
beq L1 ; jump if no
txa ; get character back into accu
sec
.import popax, __ctype
.importzp ptr1, ptr2, ptr3, tmp1
+ .include "ctype.inc"
_strnicmp:
_strncasecmp:
Comp: lda (ptr2),y
tax
lda __ctype,x ; get character classification
- and #$01 ; lower case char?
+ and #CT_LOWER ; lower case char?
beq L1 ; jump if no
txa ; get character back
sec
sbc #<('a'-'A') ; make upper case char
- tax ;
+ tax ;
L1: stx tmp1 ; remember upper case equivalent
- lda (ptr1),y ; get character from first string
+ lda (ptr1),y ; get character from first string
tax
lda __ctype,x ; get character classification
- and #$01 ; lower case char?
- beq L2 ; jump if no
- txa ; get character back
+ and #CT_LOWER ; lower case char?
+ beq L2 ; jump if no
+ txa ; get character back
sec
sbc #<('a'-'A') ; make upper case char
tax
-L2: cpx tmp1 ; compare characters
- bne NotEqual ; Jump if strings different
- txa ; End of strings?
+L2: cpx tmp1 ; compare characters
+ bne NotEqual ; Jump if strings different
+ txa ; End of strings?
beq Equal1 ; Jump if EOS reached, a/x == 0
; Increment the pointers
.import __ctype
.importzp ptr1, ptr2
+ .include "ctype.inc"
+
_strupper:
_strupr:
sta ptr1 ; Save s (working copy)
beq L9 ; jump if done
tax
lda __ctype,x ; get character classification
- and #$01 ; lower case char?
+ and #CT_LOWER ; lower case char?
beq L1 ; jump if no
txa ; get character back into accu
clc