$PAGELENGTH(66) XREF DEBUG PRINT(:LP:)

;
	NAME	BASIC3

;	REVISED CHARLES CHERNACK 12/11/77


	PUBLIC	SYMSRT


MEMST	EQU	3200H
LEN	EQU	MEMST+141Q


;	ROUTINE TO LOCATE COMMANDS, KEY WORDS, OPERATORS, AND FUNCTION.
;	HL CONTAINS ADDRESS OF FIRST CHARACTER.
;	C CONTAINS LENGTH OF LINE.
;	SYMBOL NUMBER, IF FOUND, RETURNED IN A, ELSE 0FFH IN A.

	CSEG

$EJECT TITLE('SYMBOL LOCATE 12/11/77')
SYMSRT:	PUSH	D
	PUSH	B
	PUSH	H
	PUSH	H
	LXI	H,LEN		;SAVE C IN LEN
	MOV	M,C
	LXI	H,KDATA		;LOCATE TYPE OF SYMBOL SOUGHT.
	MVI	E,0		;REG A CONTAINS: <ON ENTRY!>
	ADD	A		; 
	MOV	C,A		; INCR IN BC
	MVI	B,0		;
	DAD	B		; SET START ADDRESS FOR LIST
	MOV	D,M		; LOW ADDRESS
	INX	H		; 
	MOV	H,M		; HIGH ADDRESS
	MOV	L,D		; LOW ADDRESS
	MOV	C,M		; LENGTH OF STRING
S3:	INX	H		;
	MOV	B,M		; B <= CHARACTER FROM INTERNAL TABLE
	MOV	A,B
	ANI	7FH		; MASK OUT PARITY BIT
	MOV	B,A		; RESTORE
	XTHL
	MOV	A,M		; A <= CHARACTER FROM OUTSIDE
	ANI	7FH		; MASK OUT PARITY BIT
	CMP	B		; COMPARE CHARACTERS
	JNZ	S4
	DCR	C
	JZ	S5
	PUSH	H
	LXI	H,LEN
	DCR	M
	POP	H
	JZ	S4A
	INX	H
	XTHL
	JMP	S3
S4A:	 INR	C
S4:	POP	H
	MVI	B,0
	DAD	B
	MOV	A,L
	MOV	D,H
	POP	H
	POP	B
	PUSH	B
	PUSH	H
	PUSH	H
	LXI	H,LEN
	MOV	M,C
	MOV	L,A
	MOV	H,D
	MOV	A,M
	INR	E
	MOV	C,A
	INR	A
	JNZ	S3
	LXI	H,LEN
	INR	M
	MVI	E,0FFH
S5:	MOV	A,E		; MOVE SYMBOL NUMBER INTO REG A
	LXI	H,LEN
	MOV	E,M
	DCR	E
	POP	H
	POP	H
	POP	B
	MOV	C,E		;MOVE NUMBER OF CHAR. LEFT IN LINE INT
	POP	D
	RET
$EJECT
;*****************************************************
; THE CODE FROM HERE TO THE NEXT LINE OF *'S MUST BE ON ONE PAGE

KDATA:	DW	KDAT1
	DW	KDAT2
	DW	KDAT3
	DW	KDAT4

KDAT1:	DB	3,'RUN'		;    RUN	<0>
	DB	4,'HELP'	;    HELP	<1>
	DB	3,'LIS'		;    LIS	<2>
	DB	3,'SCR'		;    SCR	<3>
	DB	4,'EXIT'	;    EXIT	<4>
	DB	4,'LOAD'	;    LOAD	<5>
	DB	0FFH




KDAT2:	DB	3,'LET'	; LET	<0>
	DB	3,'PRI'	; PRI	<1>
	DB	3,'REM'	; REM	<2>
	DB	3,'STO'	; STO	<3>
	DB	3,'END'	; END	<4>
	DB	3,'GOT'	; GOTO	<5>
	DB	2,'IF'	; IF	<6>
	DB	3,'INP'	; INPUT	<7>
	DB	3,'DIM'	; DIM	<8>
	DB	3,'CAL'	; CALL	<9>
	DB	4,'GOSU'; GOSUB	<10>
	DB	3,'RET'	; RET	<11>
	DB	3,'FOR'	; FOR	<12>
	DB	4,'NEXT'; NEXT	<13>
	DB	0FFH

$EJECT

KDAT3:	DB	1,'<'	; <	<0>
	DB	1,'>'	; >	<1>
	DB	1,','	; ,	<2>
	DB	1,'='	; =	<3>
	DB	1,')'	; )	<4>
	DB	1,';'	; ;	<5>
	DB	4,'THEN'; THEN	<6>
	DB	2,'TO'	; TO	<7>
	DB	4,'STEP'; STEP	<8>
	DB	1,'*'	; *	<9>
	DB	1,'/'	; /	<10>
	DB	1,'+'	; +	<11>
	DB	1,'-'	; -	<12>
	DB	0FFH

KDAT4:	DB	3,'GET'	; GET	<0>
	DB	3,'PUT'	; PUT	<1>
	DB	0FFH

	END
