
chks()
	{
#asm
	PUSH	BC	;save calling routine stk frame ptr
	LD	HL,4	;get arg off stack
	ADD	HL,SP
	LD	E,(HL)
	INC	HL
	LD	D,(HL)	;string s
	LD	HL,(lptr?) ;parsing buffer
?chk1:	LD	A,(DE)	;current character in s
	OR	A	;end of string s?
	JR	Z,?asan ;parsing buffer matches to end of s
	CP	(HL)	;compare s to parsing buffer
	JR	NZ,?stne ;mismatch
	INC	DE	;next character in s
	INC	HL	;	and parsing buffer
	JR	?chk1	;loop
#endasm
	}
streq()
	{
#asm
	PUSH	BC	;save calling routine stk frame ptr
	LD	HL,4	;get args off stack
	ADD	HL,SP
	LD	E,(HL)	;s1
	INC	HL
	LD	D,(HL)
	INC	HL
	LD	A,(HL)	;s2
	INC	HL
	LD	H,(HL)
	LD	L,A
	LD	C,0	;init match length counter
?stlp:	LD	A,(DE)	;current char of s2
	OR	A	;is this end-of-string?
	JR	Z,?steq ;they match to end-to-string
	CP	(HL)	;compare to current char of s1
	JR	NZ,?stne ;they don't match here
	INC	DE	;get to next char of s2
	INC	HL	;same for s1
	INC	C	;count one more char matched
	JR	?stlp	;loop
#endasm
	}
astreq()
	{
#asm
	PUSH	BC	;save calling routine stk frame ptr
	LD	HL,4	;get args off stack
	ADD	HL,SP
	LD	B,(HL)	;len
	INC	HL
	INC	HL
	LD	E,(HL)	;s2
	INC	HL
	LD	D,(HL)
	INC	HL
	LD	A,(HL)	;s1
	INC	HL
	LD	H,(HL)
	LD	L,A
	LD	C,0	;init match length counter (max = 255)
?aslp:	LD	A,(DE)	;current char of s2
	OR	A	;is this end-of-string (0)?
	JR	Z,?asan ;they match to end-to-string
	CP	(HL)	;compare to current char of s1
	JR	NZ,?stne ;they don't match here
	INC	DE	;get to next char of s2
	INC	HL	;same for s1
	INC	C	;count one more char matched
	DJNZ	?aslp	;loop if more to match
?asan:	LD	A,(HL)	;is next char in s1 alphanumeric?
	CP	95	;'_'
	JR	Z,?stne
	CP	48	;'1'
	JR	C,?steq ;< 1
	CP	58	;'9' + 1
	JR	C,?stne ;numeric
	OR	32	;convert upper case to lower
	CP	97	;'a'
	JR	C,?steq
	CP	123	;'z' + 1
	JR	C,?stne ;lower case alpha
?steq:	LD	L,C	;set return value to matched length
	LD	H,0
	OR	1	;set Z flag to indicate TRUE
	POP	BC	;restore calling routine stk frame ptr
	RET
?stne:	LD	HL,0	;set FALSE
	XOR	A	;set Z flag to indicate FALSE
	POP	BC
#endasm
	}
isletnum()
	{
#asm
	LD	HL,2
	ADD	HL,SP
	LD	A,(HL)
	CP	48	;'1'
	JR	C,?lett
	CP	58	;'9'+1
	JR	NC,?lett
	OR	H	;set Z flag
#endasm
	}
isletter()
	{
#asm
	LD	HL,2
	ADD	HL,SP
	LD	A,(HL)
?lett:	CP	95	;'_'
	JR	Z,?islet
	OR	32	;upper to lower case
	CP	97	;'a'
	JR	C,?notlet
	CP	123	;'z'+1
	JR	C,?islet
?notlet: XOR	A	;set Z flag
	LD	H,A	;return FALSE
	LD	L,A
	RET
?islet: OR     H
#endasm
	}
/* Skip over token in parse line */
skip()
	{
#asm
	LD	HL,(lptr?)
?skip1: LD	E,(HL)	;next character in parse line
	PUSH	DE
	CALL	isletnum?
	POP	DE
	RET	Z	;end of alphanumerics
	LD	HL,(lptr?)
	INC	HL
	LD	(lptr?),HL
	JR	?skip1
#endasm
	}
