Use named constants from ctype.inc instead of hard coded numeric values.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3929 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -9,6 +9,8 @@
|
|||||||
.import __ctype
|
.import __ctype
|
||||||
.importzp sreg, ptr1, ptr2, tmp1
|
.importzp sreg, ptr1, ptr2, tmp1
|
||||||
|
|
||||||
|
.include "ctype.inc"
|
||||||
|
|
||||||
;
|
;
|
||||||
; Conversion routine (32 bit)
|
; Conversion routine (32 bit)
|
||||||
;
|
;
|
||||||
@@ -27,7 +29,7 @@ _atol: sta ptr1 ; Store s
|
|||||||
L1: lda (ptr1),y
|
L1: lda (ptr1),y
|
||||||
tax
|
tax
|
||||||
lda __ctype,x ; get character classification
|
lda __ctype,x ; get character classification
|
||||||
and #$80 ; tab or space?
|
and #CT_SPACE_TAB ; tab or space?
|
||||||
beq L2 ; jump if no
|
beq L2 ; jump if no
|
||||||
iny
|
iny
|
||||||
bne L1
|
bne L1
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
.import __ctype
|
.import __ctype
|
||||||
.importzp ptr1, ptr2, tmp1
|
.importzp ptr1, ptr2, tmp1
|
||||||
|
|
||||||
|
.include "ctype.inc"
|
||||||
|
|
||||||
_stricmp:
|
_stricmp:
|
||||||
_strcasecmp:
|
_strcasecmp:
|
||||||
@@ -23,7 +24,7 @@ _strcasecmp:
|
|||||||
loop: lda (ptr2),y ; get char from second string
|
loop: lda (ptr2),y ; get char from second string
|
||||||
tax
|
tax
|
||||||
lda __ctype,x ; get character classification
|
lda __ctype,x ; get character classification
|
||||||
and #$01 ; lower case char?
|
and #CT_LOWER ; lower case char?
|
||||||
beq L1 ; jump if no
|
beq L1 ; jump if no
|
||||||
txa ; get character back
|
txa ; get character back
|
||||||
clc
|
clc
|
||||||
@@ -34,7 +35,7 @@ L1: stx tmp1 ; remember upper case equivalent
|
|||||||
lda (ptr1),y ; get character from first string
|
lda (ptr1),y ; get character from first string
|
||||||
tax
|
tax
|
||||||
lda __ctype,x ; get character classification
|
lda __ctype,x ; get character classification
|
||||||
and #$01 ; lower case char?
|
and #CT_LOWER ; lower case char?
|
||||||
beq L2 ; jump if no
|
beq L2 ; jump if no
|
||||||
txa ; get character back
|
txa ; get character back
|
||||||
clc
|
clc
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
.import __ctype
|
.import __ctype
|
||||||
.importzp ptr1, ptr2
|
.importzp ptr1, ptr2
|
||||||
|
|
||||||
|
.include "ctype.inc"
|
||||||
|
|
||||||
_strlower:
|
_strlower:
|
||||||
_strlwr:
|
_strlwr:
|
||||||
sta ptr1 ; Save s (working copy)
|
sta ptr1 ; Save s (working copy)
|
||||||
@@ -24,7 +26,7 @@ loop: lda (ptr1),y ; get character
|
|||||||
beq L9 ; jump if done
|
beq L9 ; jump if done
|
||||||
tax
|
tax
|
||||||
lda __ctype,x ; get character classification
|
lda __ctype,x ; get character classification
|
||||||
and #$02 ; upper case char?
|
and #CT_UPPER ; upper case char?
|
||||||
beq L1 ; jump if no
|
beq L1 ; jump if no
|
||||||
txa ; get character back into accu
|
txa ; get character back into accu
|
||||||
sec
|
sec
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
.import popax, __ctype
|
.import popax, __ctype
|
||||||
.importzp ptr1, ptr2, ptr3, tmp1
|
.importzp ptr1, ptr2, ptr3, tmp1
|
||||||
|
|
||||||
|
.include "ctype.inc"
|
||||||
|
|
||||||
_strnicmp:
|
_strnicmp:
|
||||||
_strncasecmp:
|
_strncasecmp:
|
||||||
@@ -49,27 +50,27 @@ Loop: inc ptr3
|
|||||||
Comp: lda (ptr2),y
|
Comp: lda (ptr2),y
|
||||||
tax
|
tax
|
||||||
lda __ctype,x ; get character classification
|
lda __ctype,x ; get character classification
|
||||||
and #$01 ; lower case char?
|
and #CT_LOWER ; lower case char?
|
||||||
beq L1 ; jump if no
|
beq L1 ; jump if no
|
||||||
txa ; get character back
|
txa ; get character back
|
||||||
sec
|
sec
|
||||||
sbc #<('a'-'A') ; make upper case char
|
sbc #<('a'-'A') ; make upper case char
|
||||||
tax ;
|
tax ;
|
||||||
L1: stx tmp1 ; remember upper case equivalent
|
L1: stx tmp1 ; remember upper case equivalent
|
||||||
|
|
||||||
lda (ptr1),y ; get character from first string
|
lda (ptr1),y ; get character from first string
|
||||||
tax
|
tax
|
||||||
lda __ctype,x ; get character classification
|
lda __ctype,x ; get character classification
|
||||||
and #$01 ; lower case char?
|
and #CT_LOWER ; lower case char?
|
||||||
beq L2 ; jump if no
|
beq L2 ; jump if no
|
||||||
txa ; get character back
|
txa ; get character back
|
||||||
sec
|
sec
|
||||||
sbc #<('a'-'A') ; make upper case char
|
sbc #<('a'-'A') ; make upper case char
|
||||||
tax
|
tax
|
||||||
|
|
||||||
L2: cpx tmp1 ; compare characters
|
L2: cpx tmp1 ; compare characters
|
||||||
bne NotEqual ; Jump if strings different
|
bne NotEqual ; Jump if strings different
|
||||||
txa ; End of strings?
|
txa ; End of strings?
|
||||||
beq Equal1 ; Jump if EOS reached, a/x == 0
|
beq Equal1 ; Jump if EOS reached, a/x == 0
|
||||||
|
|
||||||
; Increment the pointers
|
; Increment the pointers
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
.import __ctype
|
.import __ctype
|
||||||
.importzp ptr1, ptr2
|
.importzp ptr1, ptr2
|
||||||
|
|
||||||
|
.include "ctype.inc"
|
||||||
|
|
||||||
_strupper:
|
_strupper:
|
||||||
_strupr:
|
_strupr:
|
||||||
sta ptr1 ; Save s (working copy)
|
sta ptr1 ; Save s (working copy)
|
||||||
@@ -24,7 +26,7 @@ loop: lda (ptr1),y ; get character
|
|||||||
beq L9 ; jump if done
|
beq L9 ; jump if done
|
||||||
tax
|
tax
|
||||||
lda __ctype,x ; get character classification
|
lda __ctype,x ; get character classification
|
||||||
and #$01 ; lower case char?
|
and #CT_LOWER ; lower case char?
|
||||||
beq L1 ; jump if no
|
beq L1 ; jump if no
|
||||||
txa ; get character back into accu
|
txa ; get character back into accu
|
||||||
clc
|
clc
|
||||||
|
|||||||
Reference in New Issue
Block a user