(***  ASSMHD.PAS -- MAIN LINE GLOGAL DECLARATIONS AREA   ***)
 
CONST	NAMELEN=6;    STMLN=80;   COMDELIM=';';
	LABDELIM=':'; STRLEN=60;  OPNO=21;  TTLEN=30;
	ASSMID  ='INTEL 8086 CROSS ASSEMBLER  V2.1';
  
 
TYPE	NAME = ARRAY [1 .. NAMELEN] OF CHAR;   (* ONE SYMBOLIC NAME *)
	STMT = ARRAY [1 .. STMLN  ] OF CHAR;   (* ONE INPUT CARD IMAGE *)
	TTLTP= ARRAY [1 .. TTLEN  ] OF CHAR;   (* TITLE AND SUBTITLE   *)
	WORD = ARRAY [1 .. 4      ] OF CHAR;
	
	INSTR = (AAA,AAD,AAM,AAS,ADC,ADD,ANDD,CALL,CBW,CLC,CLD,CLI,CMC,CMP,
		 CMPB,CMPW,CWD,DAA,DAS,DEC,DB,DIVV,DSB,DSW,DW,EJECT,ELSEE,ENDD,
		 ENDIF,EQU,ESC,HLT,IDIV,IFF,IMUL,INN,INC,INTT,INTO,INW,IRET,
		 JA,JAE,JB,JBE,JC,JCXZ,JE,JG,JGE,JL,JLE,JMP,JNA,JNAE,JNB,
		 JNBE,JNC,JNE,JNG,JNGE,JNL,JNLE,JNO,JNP,JNS,JNZ,JO,JP,JPE,
		 JPO,JS,JZ,LAHF,LDS,LEA,LES,LOCK,LODB,LODW,LON,LOFF,LOOPP,LOOPE,
		 LOOPNE,LOOPNZ,LOOPZ,MOV,MOVB,MOVW,MUL,NEG,NOTT,ORR,ORG,NOP,
		 OUT,OUTW,POP,POPF,PUSH,PUSHF,RCL,RCR,REP,REPZ,RET,RETI,ROL,ROR,
		 SAHF,SAL,SAR,SBB,SCAB,SCAW,SETT,SHL,SHR,STC,STD,STI,STITL,
		 STOB,STOW,SUB,TEST,TITL,WAIT,XCHG,XLAT,GEN,NOG,GLBL,EQW,
		 DSEG,CSEG,XTRNL,MCR,XOR);
 
	INSTP = (PSEUD,CMPLX,ONEMOP,NOOPS,TWOB,DISPL);	(*  INSTRUCTION OP CODE TYPE  *)
 
	TWOCHAR = ARRAY [1..2] OF CHAR;
 
	OPNDTP = (REG,CNST,OFFS,INDB,INDX,INDBX,FREF,SGNM);  (* OPERAND TYPE *)
 
	SYMTYP = (PERM,PERW,CHBL,MEMR,REGNM,MBYTE,MWORD,XTLB,XTLW,XTLS,SEGNM);	(*  SYMBOL TYPE  *)
 
	SYMPTR = ^SYMBOL;
 
	OPERATION = RECORD		(* OPERATION CHARACTERISTICS  *)
		OPNAME : NAME;		(*  OP CODE NAME  *)
		OPTYP  : INSTP;		(*  OP CODE TYPE  *)
		OPCODE : TWOCHAR	(*  HEX OPERATION CODE  *)
		END;
 
	STATEMENT = RECORD		(*  EACH STATEMENTS CHARACTERISTICS  *)
		STMNT : STMT;		(*   CARD IMAGE  *)
		STMLEN: 1..STMLN;	(*   STATEMENT LEN *)
		ADDR  : INTEGER;	(*   ADDRESS  *)
		HASLBL: BOOLEAN;	(*   STATEMENT HAS LABEL -- TRUE  *)
		LABSTR: INTEGER;	(*   LABEL STARTING COLUMN  *)
		OPRSTR: INTEGER;	(*   OPERATION CODE COLUMN START  *)
		OPDSTR: INTEGER;	(*   OPERAND FIELD COLUMN START  *)
		ST    : INSTR;		(*   INSTRUCTION OP CODE  *)
		MRLN  : INTEGER;	(*   ASSUMED # BYTES IN M/R *)
		ERRCNT: INTEGER;	(*   NUMBER ERRS IN LINE *)
		ERRS  : TWOCHAR;	(*   ERROR FLAGS  *)
		STPRNT: BOOLEAN;	(*   PRINT LINE   *)
		COMMNT: BOOLEAN		(*   COMMENT INDICATOR TO PASS2  *)
		END;
  
	FILENAME = RECORD		(**  FILE NAME ATTRIBUTES  **)
		FNAME : NAME;
		SUFFX : NAME;
		DEV   : NAME
		END;
 
	SYMBOL = RECORD			(* SYMBOL TABLE ENTRY  *)
		SNAME : NAME;		(*   SYMBOL NAME -- 6 CHARS  *)
		SVAL  : INTEGER;	(*   SYMBOL VALUE  *)
		STYP  : SYMTYP;		(*   SYMBOL TYPE   *)
		SNXT  : SYMPTR		(*   NEXT ONE IN LIST, NIL=END *)
		END;
 
	OPERAND = RECORD
		OPTP : OPNDTP;		(* OPERAND TYPE *)
		OPV  : INTEGER;		(* OPERAND VALUE *)
		RB,RX: INTEGER;		(* BASE, INDEX REGS *)
		OPLN : 1..3;		(* NUMBER BYTES IN OPEAND *)
		OTP  : 0..2;		(* BYTE OR WORD INDICATOR *)
		OSR  : INTEGER		(* SEGMENT REGISTER NUMBER *)
		END;
 
	XTLPTR = ^XTLREF;
 
	XTLREF = RECORD
		XN  	: NAME;		(*  XTL REF NAME  **)
		XA  	: INTEGER;	(*  OFFSET IN SEGMENT  *)
		XOP,XTP : CHAR;		(*  OPERATION AND REFERENCE TYPE  *)
		XNXT    : XTLPTR
		END;
 
 
VAR	OPERATIONS : ARRAY [AAA .. XOR] OF OPERATION;
 
	SYMTOP,GS  : SYMPTR;			(* SYMBOL POINTERS *)
 
	LIST       : TEXT;			(* LISTING FILE *)
	STATEMENTS : FILE OF STATEMENT;
	SOURCE,OBJ : TEXT;			(* FILES SOURCE AND OBJECT  *)
	MACF	   : FILE OF STMT;		(* MACRO TEXT FILE *)
 
	SFN,OFN,LFN : FILENAME;			(* FILE NAMES *)
	GSYM 	    : NAME;
 
	FIRSTSEG : BOOLEAN;  CURSEG : SYMPTR;	(***  SEGMENT STUFF  ***)
	DUM1STSEG: INTEGER;
 
	STRING  : ARRAY [1..STRLEN] OF CHAR;	(* STRING CONTROLS  *)
	SL      : 0..STRLEN;
 
	EXPTERM,LABCH,OP1,OP2 : SET OF CHAR;	(*  FOR SCANNING EASE  *)
	PASS1   : BOOLEAN;			(* WHICH PASS INDICATOR *)
	TTL,STTL: TTLTP;			(* TITLE AND SUBTITLE *)
	NRC,ISEGD,STIME : INTEGER;
	ISEGJ,ERRINPROG : BOOLEAN;
	EC : INTEGER;				(** ERROR COUNT  **)
 
	HASSBTL : BOOLEAN;  
 
	IFCUR,IFLEV : 0..8;			(* CONDITIONAL ASSEMBLY CONTROLS *)
	IFLEVS: ARRAY[1..8] OF RECORD
		HASELSE,ISGEN : BOOLEAN
		END;
 
	EXOPS : ARRAY[1..OPNO] OF RECORD	(* EXPR OPERATIONS *)
		OPTR  : TWOCHAR;
		OPREC : INTEGER
		END;
 
	NSYMBS : INTEGER;			(* NUMBER SYMBOLS DEFINED *)
	TFN    : ARRAY [1 .. 12] OF CHAR;	(* RSX FILE NAMES *)
 
	XREFS,NX1,NX2,XD,XLAST : XTLPTR;	(* EXTERNAL REF CONTROLS  *)
	OPNDS : INTEGER;
	HASXTL: BOOLEAN;	(**  TRUE IF EXTERNAL REF PENDING  **)
