]> wirehaze git hosting - MS-DOS.git/blob - v4.0/src/CMD/FC/STRING.ASM

wirehaze git hosting

MZ is back!
[MS-DOS.git] / v4.0 / src / CMD / FC / STRING.ASM
1 ;
2 ; string functions for lattice C
3 ;
4
5 .xlist
6 include version.inc
7 include cmacros.inc
8 .list
9
10 sBegin data
11 assumes ds,data
12
13 externB XLTab
14 externB XUTab
15
16 sEnd
17
18 sBegin code
19 assumes cs,code
20
21 externP strlen
22
23 ;
24 ; strbscan (string, set) returns pointer to 1st char in set or end
25 ;
26 cProc strbscan,<PUBLIC>,<SI,DI>
27 parmW str
28 parmW set
29 cBegin
30 push ds
31 pop es
32 cCall strlen,<set>
33 inc ax
34 mov bx, ax
35 mov si,str
36 cld
37 bscan:
38 lodsb
39 mov cx,bx
40 mov di,set
41 ;
42 ; While not in the set
43 ;
44 repnz scasb
45 jnz bscan
46 lea ax,[si-1]
47 cEnd
48
49 ;
50 ; strbskip ( string, set ) returns pointer to 1st char not in set
51 ;
52 cProc strbskip,<PUBLIC>,<SI,DI>
53 parmW str
54 parmW set
55 cBegin
56 push ds
57 pop es
58 cCall strlen,<set>
59 inc ax
60 mov bx, ax
61 mov si,str
62 cld
63 bskip:
64 lodsb
65 or al,al
66 jz eskip
67 mov cx,bx
68 mov di,set
69 ;
70 ; While not in the set
71 ;
72 repnz scasb
73 jz bskip
74 eskip:
75 lea ax,[si-1]
76 cEnd
77
78 ;
79 ; strpre (s1, s2) returns -1 if s1 is a prefix of s2, 0 otherwise. Ignores
80 ; case.
81 ;
82 cProc strpre,<PUBLIC>,<si,di>
83 parmW pref
84 parmW str
85 cBegin
86 cld
87 mov si,pref
88 mov di,str
89 mov bx,dataOFFSET xltab
90 preCompare:
91 lodsb
92 mov ah,[di]
93 inc di
94
95 xlat
96 xchg ah,al
97 xlat
98
99 cmp ah,al
100 jnz preDif
101 or ah,ah
102 jnz preCompare
103 preYes:
104 mov ax,-1
105 jmp short preDone
106 preDif:
107 or ah,ah
108 jz preYes
109 xor ax,ax
110 preDone:
111 cEnd
112
113 sEnd
114
115 end