
/*  Operator precedence values:  */

#define	UOP1	0	/*  Unary +, unary -.				*/
#define	MULT	1	/*  *, /, MOD, SHL, SHR.			*/
#define	ADDIT	2	/*  Binary +, binary -.				*/
#define	RELAT	3	/*  >, =, <, >=, <>, <=.			*/
#define	UOP2	4	/*  NOT.					*/
#define	LOG1	5	/*  AND.					*/
#define	LOG2	6	/*  OR, XOR.					*/
#define	UOP3	7	/*  HIGH, LOW.					*/
#define	RPREN	8	/*  ).						*/
#define	LPREN	9	/*  (.						*/
#define	ENDEX	10	/*  CR, ;, ,.					*/
#define	START	11	/*  Start of expression.			*/

/*  Bits of opcode attribute byte.  */

#define	PSOP	0x80	/*  Pseudo-op.					*/
#define	DIROK	0x40	/*  Non-pseudo-op is OK for direct addressing.	*/
#define	IFGROUP	0x40	/*  Pseudo-op is IF, ELSE, ENDI.		*/
#define	REL	0x20	/*  Relative addressing required.		*/
#define	REGREQ	0x10	/*  A, B must be specified.			*/
#define	IMM16	0x08	/*  16-bit immediate addressing OK.		*/
#define	IMM8	0x04	/*  8-bit immediate addressing OK.		*/
#define	INDEX	0x02	/*  Indexed or extended addressing OK.		*/
#defi	DAD	D
	MOV	E,L
	MOV	D,H
;
	LXI	H, OPCODE	;FIND OPCODE RETURN AREA.
	DAD	SP
	MOV	A,M
	INX	H
	MOV	H,M
	MOV	L,A
;
	PUSH	B		;MOVE OPCODE OUT TO RETURN AREA.
	MVI	C, 4
MOVOPC:	LDAX	D
	INX	D
	MOV	M,A
	INX	H
	DCR	C
	RELOC	JNZ,MOVOPC
	POP	B
;
	MVI	M, 0		;TERMINATE OPCODE.
;
	LXI	H, ATTRIB	;FIND ATTRIBUTE RETURN AREA.
	DAD	SP
	MOV	A,M
	INX	H
	MOV	H,M
	MOV	L,A
;
	LDAX	D		;MOVE ATTRIBUTE TO RETURN AREA.
	INX	D
	MOV	M,A
;
	LXI	H, VALUE	;FIND VALUE RETURN AREA.
	DAD	SP
	MOV	A,M
	INX	H
	MOV	H,M
	MOV	L,A
;
	LDAX	D		;MOVE VALUE TO RETURN AREA.
	MOV	M,A
;
	LXI	H, 1		;RETURN 1 FOR SUCCESSFUL GET.
	RET
;
;THE OPCODE TABLE ITSELF:
;
;	EACH ENTRY HAS A FOUR-BYTE NAME, A ONE-BYTE ATTRIBUTE,
;	AND A ONE-BYTE VALUE.  THE VALUE IS THE LOWEST
;	NUMBERED OPCODE HAVING THAT NAME.
;
;	THE ATTRIBUTE BYTE BITS ARE ALLOCATED AS FOLLOWS:
;
;		7 = PSEUDO-OP.
;		6 = IF NOT PSEUDO-OP, DIRECT ADDRESSING ALLOWED.
;		    IF PSEUDO-OP, IF GROUP (NO LABEL ALLOWED).
;		5 = RELATIVE ADDRESSING.
;		4 = REGISTER (A,B) MUST BE SPECIFIED.
;		3 = 16-BIT IMMEDIATE ADDRESSING ALLOWED.
;		2 = 8-BIT IMMEDIATE ADDRESSING ALLOWED.
;		1 = INDEXED OR EXTENDED ADDRESSING ALLOWED.
;		0 = REGISTER (A,B) MAY BE SPECIFIED.
;
OPCTBL:	DB	'ABA', 0,	0,	1BH
	DB	'ADC', 0,	56H,	89H
	DB	'ADD', 0,	56H,	8BH
	DB	'AND', 0,	56H,	84H
	DB	'ASL', 0,	03H,	48H
	DB	'ASR', 0,	03H,	47H
	DB	'BCC', 0,	20H,	24H
	DB	'BCS', 0,	20H,	25H
	DB	'BEQ', 0,	20H,	27H
	DB	'BGE', 0,	20H,	2CH
	DB	'BGT', 0,	20H,	2EH
	DB	'BHI', 0,	20H,	22H
	DB	'BIT', 0,	56H,	85H
	DB	'BLE', 0,	20H,	2FH
	DB	'BLS', 0,	20H,	23H
	DB	'BLT', 0,	20H,	2DH
	DB	'BMI', 0,	20H,	2BH
	DB	'BNE', 0,	20H,	26H
	DB	'BPL', 0,	20H,	2AH
	DB	'BRA', 0,	20H,	20H
	DB	'BSR', 0,	20H,	8DH
	DB	'BVC', 0,	20H,	28H
	DB	'BVS', 0,	20H,	29H
	DB	'CBA', 0,	0,	11H
	DB	'CLC', 0,	0,	0CH
	DB	'CLI', 0,	0,	0EH
	DB	'CLR', 0,	03H,	4FH
	DB	'CLV', 0,	0,	0AH
	DB	'CMP', 0,	56H,	81H
	DB	'COM', 0,	03H,	43H
	DB	'CPX', 0,	4AH,	8CH
	DB	'DAA', 0,	0,	19H
	DB	'DEC', 0,	03H,	4AH
	DB	'DES', 0,	0,	34H
	DB	'DEX', 0,	0,	09H
	DB	'ELSE', 	0C0H,	07H
	DB	'END', 0,	80H,	06H
	DB	'ENDI',		0C0H,	08H
	DB	'EOR', 0,	56H,	88H
	DB	'EQU', 0,	80H,	01H
	DB	'FCB', 0,	80H,	02H
	DB	'FCC', 0,	80H,	04H
	DB	'FDB', 0,	80H,	03H
	DB	'IF', 0, 0,	0C0H,	09H
	DB	'INC', 0,	03H,	4CH
	DB	'INS', 0,	0,	31H
	DB	'INX', 0,	0,	08H
	DB	'JMP', 0,	02H,	4EH
	DB	'JSR', 0,	02H,	8DH
	DB	'LDA', 0,	56H,	86H
	DB	'LDS', 0,	4AH,	8EH
	DB	'LDX', 0,	4AH,	0CEH
	DB	'LSR', 0,	03H,	44H
	DB	'NEG', 0,	03H,	40H
	DB	'NOP', 0,	0,	01H
	DB	'ORA', 0,	56H,	8AH
	DB	'ORG', 0,	80H,	00H
	DB	'PSH', 0,	10H,	36H
	DB	'PUL', 0,	10H,	32H
	DB	'RMB', 0,	80H,	05H
	DB	'ROL', 0,	03H,	49H
	DB	'ROR', 0,	03H,	46H
	DB	'RTI', 0,	0,	3BH
	DB	'RTS', 0,	0,	39H
	DB	'SBA', 0,	0,	10H
	DB	'SBC', 0,	56H,	82H
	DB	'SEC', 0,	0,	0DH
	DB	'SEI', 0,	0,	0FH
	DB	'SET', 0,	80H,	0AH
	DB	'SEV', 0,	0,	0BH
	DB	'STA', 0,	52H,	87H
	DB	'STS', 0,	42H,	08FH
	DB	'STX', 0,	42H,	0CFH
	DB	'SUB', 0,	56H,	80H
	DB	'SWI', 0,	0,	3FH
	DB	'TAB', 0,	0,	16H
	DB	'TAP', 0,	0,	06H
	DB	'TBA', 0,	0,	17H
	DB	'TPA', 0,	0,	07H
	DB	'TST', 0,	03H,	4DH
	DB	'TSX', 0,	0,	30H
	DB	'TXS', 0,	0,	35H
	DB	'WAI', 0,	0,	3EH
;
OPTBLL	EQU	($-OPCTBL)/6	;CALCULATE LENGTH OF TABLE.
;
	POSTLUDE GETOPC
;
	PAGE
;
;THIS FUNCTION RETURNS THE NUMBER OF OPCODES IN THE OPCODE TABLE
;FOR THE BENEFIT OF THE BINARY SEARCHING ROUTINE (WRITTEN IN C).
;
;THIS FUNCTION IS CALLED AS FOLLOWS:
;
;	NUMOPCS();
;
	PRELUDE	NUMOPCS
;
	LXI	H, OPTBLL	;RETURN NUMBER OF OPCODES.
	RET
;
	POSTLUDE NUMOPCS
;
	PAGE
;
;THIS FUNCTION REMOVES THE PARITY BIT FROM ITS ARGUMENT AND LOOKS IT UP IN
;A TABLE.  THE TABLE CLASSIFIES THE CHARACTER INTO ONE OF THE FOLLOWING BINS
;RETURNING THE APPROPRIATE CODE.
;
ALPHA	EQU	0	;ALPHABETIC.
NUMERC	EQU	1	;NUMERIC (0-9).
ENDLIN	EQU	2	;END OF LINE MARKERS (CR ;).
COMMA	EQU	3	;FIELD SEPARATORS (,).
OPERAT	EQU	4	;OPERATORS (* + / - > < = ( )).
BASDES	EQU	5	;BASE DESIGNATORS ($ @ %).
QUOTE	EQU	6	;STRING DELIMITERS (' ").
IMMED	EQU	7	;IMMEDIATE MODE DESIGNATOR (#).
BLANK	