      PROGRAM METAD
C   
C
C     META ASSEMBLER DEFINITION PROGRAM
C     FOR AMD 2900, INTEL 3000, ETC.
C     COPYRIGHT 1977
C     MICROTEC
C     P.O. BOX 60337
C     SUNNYVALE, CALIFORNIA 94088
C
C
C
C     THE VARIABLES PASSED IN COMMON ARE DEFINED BELOW
C
C
C     FTYPE = FIELD TYPE FOR DEFS AND SUBS
C     IADDR = ARRAY TO HOLD HOLLERITH ADDRESS VALUES
C     IALPH = ALPHANUMERIC CHARACTER SET
C     IAST  = HOST REPRESENTATION OF AN ASTERISK
C     IATT  = LEGAL FIELD ATTRIBUTES OR MODIFIERS 
C     IBIT  = NUMBER OF BITS PER HOST COMPUTER WORD 
C     IBLNK = HOST REPRESENTATION OF A BLANK
C     IBUG  = DEBUG PARAMETER 
C     ICCNT = NUMBER OF CHARACTERS PER HOST COMPUTER WORD
C     ICNT  = LINE COUNT FOR SPACE DIRECTIVE
C     ICOL  = CURRENT COLUMN NUMBER FOR SCAN
C     ICOLN = HOST REPRESENTATION OF A COLON
C     ICOMM = HOST REPRESENTATION OF A COMMA
C     ICRD  = LOGICAL UNIT NUMBER OF DEFINITION FILE
C     ICTAB = HOST REPRESENTATION OF A TAB
C     IDFLE = LOGICAL UNIT NUMBER OF DEFINITION FILE
C     IDIV  = HOST REPRESENTATION OF A DIVIDE SIGN
C     IDOLR = HOST REPRESENTATION OF DOLOR SIGN 
C     IDREC = RECORD NUMBER FOR DIFINITION FILE 
C     IEND  = FLAG INDICATING END OF ASSEMBLY SOURCE
C     IERRS = TOTAL NUMBER OF ERRORS
C     IERRL = ERROR INDICATOR FOR LABELS
C     IERRI = ERROR INDICATOR FOR OPCODES AND OPERANDS
C     IERR  = ERROR INDICATOR 
C     IFBIT = MAXIMUM NUMBER OF BITS IN A FIELD 
C     IFCOL = FIRST COLUMN OF SCAN
C     IFLD  = FIELD DEFINITION TABLE
C     IFPAR = ARRAY FOR CONDITIONAL ASSEMBLY INFORMATION DURING NESTING 
C     ILEN  = EXPLICIT FIELD FENGTH FOR EXPRESSIONS AND DON"T CARES 
C     ILPAR = HOST COMPUTER REPRESENTATION OF A LEFT PARENTHESIS
C     IMIN  = HOST REPRESENTATION OF A MINUS SIGN 
C     IMULT = HOST REPRESENTATION OF A MULTIPLY SIGN
C     IN    = INPUT BUFFER (FOR SCAN) 
C     INB   = INPUT BUFFER (FOR CONTINUATION LINES) 
C     INDET = INDEX OF LABEL INTO SYMBOL TABLE
C     INDEX = INDEX OF CURRENT SYMBOL INTO SYMBOL TABLE 
C     IOLIN = NUMBER OF LINES PER OUTPUT PAGE 
C     IOPVA = OPCODE VALUE
C     IPAGE = CURRENT PAGE NUMBER 
C     IPLUS = HOST REPRESENTATION OF A PLUS SIGN
C     IPRT  = LOGICAL UNIT NUMBER OF OUTPUT LISTING DEVICE
C     IRPAR = HOST COMPUTER REPRESENTATION OF A RIGHT PARENTHESIS 
C     ISEMI = HOST REPRESENTATION OF A SEMICOLON
C     ISHRP = HOST REPRESENTATION OF A SHARP SIGN 
C     ISYM  = NUMBER OF SYMBOLS IN SYMBOL TABLE 
C     ITAB  = SYMBOL TABLE
C     ITABV = NUMERIC VALUE OF SYMBOL 
C     ITABS = SYMBOL TYPE, E.G. DEF,SUB,SET, OR ORDINARY SYMBOL 
C     ITYPE = OPCODE TYPE 
C     IXCNT = NUMBER OF CROSS REFERENCE PAGES 
C     IXPAG = CROSS REFERENCE TABLE PAGE NUMBER 
C     IXPNT = POINTER INTO CROSS REFERENCE TABLE
C     IXTAB = CORE RESIDENT CROSS REFERENCE ARRAY
C     IXT   = CROSS REFERENCE DISK RECORD
C     IYFLD = NEXT INDEX INTO FIELD TABLE
C     IZFLD = LENGTH OF FIELD TABLE
C     IWORD = NUMBER OF WORDS IN HOST COMPUTER PER LABEL
C     JATT  = FIELD ATTRIBUTES OR MODIFIERS PRESENT IN A FIELD
C     JBASE = DEFAULT BASE INDEX
C     JCOL  = COLUMN THAT A LABEL ENDS IN
C     JREAD = FLAG THAT INDICATES NEXT SOURCE LINE HAS ALREADY BEEN READ
C     JTYPE = SYMBOL TYPE
C     KLEN  = IMPLICIT FIELD LENGTH FOR CONSTANTS
C     KWORD = NUMBER OF BITS IN A WORD
C     LDEF  = FLAG TO INDICATE THAT DEFINITION FILE WILL BE PRODUCED
C     LIF   = FLAG TO INDICATE WHETHER IF STATEMENTS WILL BE EXPANDED
C     LINE  = OUTPUT PAGE LINE COUNT
C     LISN  = LINE NUMBER PRINTED ON LISTING
C     LLEN  = EXPLICIT FIELD LENGTH FOR CONSTANTS
C     LOCT  = OCTAL/HEXADECIMAL LIST FLAG
C     LREF  = FLAG TO INDICATE A CROSS REFERENCE TABLE WILL BE LISTED
C     LSOR  = FLAG TO INDICATE SOURCE WILL BE LISTED
C     LSYM  = FLAG TO INDICATE THAT A SYMBOL TABLE WILL BE LISTED
C     LTAB  = LENGTH OF SYMBOL TABLE
C     LTITL = TITLE ARRAY
C     MCFLE = LOGICAL UNIT NUMBER OF INTERMEDIATE FILE
C     MCOL  = LAST COLUMN OF SCAN
C     MCORE = BUFFER USED TO WRITE TO CROSS REFERENCE DISK FILE
C     MCREC = RECORD NUMBER FOR INTERMEDIATE FILE
C     MLAB  = MAXIMUM LABEL LENGTH
C     MLCOL = LAST COLUMN PRINTED ON OUTPUT LISTING
C     MOPC  = MAXIMUM OPCODE LENGTH
C     MXREF = SIZE OF CORE RESIDENT CROSS REFERENCE ARRAY
C     NAME  = BUFFER THAT HOLDS SYMBOL
C     NBASE = DEFAULT BASE FOR NUMBERS
C     ZVAL  = MAXIMUM VALUE OF ANY NUMBER OR CONSTANT
C   
C   
C     THE MAIN ROUTINE CALLS THE MAJOR SUBROUTINES
      INTEGER FTYPE
      REAL ITABV(249)
      COMMON ICRD,IPRT,MCFLE,IDFLE,MCREC,IDREC,IFORM,ITRUN,ILOUT,IXCOL
      COMMON MLAB,MOPC,IBIT,ICCNT,IWORD,IERRL,IERRI,IEND,IFRMC
      COMMON LSOR,LIF,LSYM,LREF,LDEF,LOCT,ITRMI,ITRMO
      COMMON ILEN,KLEN,LLEN,KWORD,IFLD(2400),IYFLD,IZFLD
      COMMON IFBIT,ZVAL,CVAL,JREAD,IN(80),INB(80),LINE,IPAGE,LISN
      COMMON IALPH(37),IAST,IDOLR,ISHRP
      COMMON ICOLN,IBLNK,ICTAB,ISEMI,ICOMM,IPLUS,IMIN,IMULT,IDIV
      COMMON IRPAR,ILPAR,IATT(9),JATT(5),LATT(9),IFPAR(16),NBASE,JBASE
      COMMON ICOL,IFCOL,MCOL,MLCOL,IOLIN,ICNT,LTITL(50),IADDR(4,12)
      COMMON ITYPE,JTYPE,FTYPE,IERR,IERRS,IOPVA,JCOL,IBUG
      COMMON ITAB(4,249),ITABS(249),ITABV,NAME(4),INDEX,INDET,ISYM,LTAB
      COMMON IXTAB(256),MXREF,IXT,IXPNT,IXCNT,IXPAG,MCORE(128)
C INCLUDE(:F1:METAD.COM)
C   
C     IF POSSIBLE, THE META ASSEMBLER DEFINITION FILE PRODUCED BY
C     THE DEFINITION PROGRAM SHOULD BE A SEQUENTIAL FILE.
C     THIS WILL CONSERVE DISK STORAGE.  HOWEVER, IF NECESSARY
C     THE FILE CAN BE RANDOM ACCESS.  THE FOLLOWING DEFINE FILE
C     STATEMENT DEFINES THE META ASSEMBLER DEFINITION FILE AND IS
C     INCLUDED FOR INFORMATION PURPOSES ONLY.  NOTE THE STATEMENT
C     IS A COMMENT.
C     THE DEFINITION FILE (SYMBOLIC FILE NUMBER 9) CONSISTS OF
C     500 128-WORD RECORDS.  U INDICATES A BINARY FILE.  THE NAME
C     IDREC IS THE RECORD INDEX.
C     VARIOUS COMPUTERS DEFINE FILES IN DIFFERENT WAYS.  THIS FILE
C     MIGHT HAVE TO BE DEFINED DIFFERENTLY ON  YOUR COMPUTER.
C     THIS FILE MUST BE SAVED AS A PERMANENT FILE, SO IT CAN
C     BE READ BY THE META ASSEMBLER ASSEMBLY PROGRAM. 
C 
C     DEFINE FILE 9(500,128,U,IDREC)
C   
C     THE FOLLOWING DEFINE FILE STATEMENT DEFINES AN INTERMEDIATE FILE
C     USED TO ACCUMULATE REFERENCES FOR THE CROSS REFERENCE TABLE.
C     IF THE USER WISHES TO ACCUMULATE A LIMITED NUMBER OF REFERENCES
C     IN MEMORY, THIS FILE IS NOT REQUIRED.  THIS FILE IS TEMPORARY
C     AND CAN BE DELETED AFTER PROGRAM EXECUTION.
C     THE FILE CONSISTS OF 100 128 WORD RECORDS.  U INDICATES
C     A BINARY FILE.  THIS FILE MAY ALSO BE SEQUENTIAL.
C   
C     CALL OPEN (8,'SCRATXRF   ',0)
C   
C     INITIALIZE PROGRAM VARIABLES
      CALL INIT
C     OPEN DEFINITION SOURCE, AND DEFINITION OUTPUT FILES
      CALL FOPEN
C     READ LANGUAGE DEFINITION AND PRODUCE DEFINITION FILE
      CALL PASS
      IF(LDEF) 92,95,92
C     CREATE DEFINITION FILE
92    CALL INOUT(4)
C     CHECK TO SEE IF SYMBOL OR CROSS REFERENCE TABLE IS TO BE CREATED
95    IF(LSYM+LREF) 400,400,100
100   IF(IFORM.NE.0) GO TO 105
      WRITE(IPRT,1002)
      GO TO 110
105   WRITE(IPRT,1001) IFRMC
110   WRITE(IPRT,1000) LTITL,IPAGE
1000  FORMAT(9X,50A1,4X,5HPAGE ,I3,/,/)
      IF(LREF) 200,200,250
200   WRITE(IPRT,1010)
1010  FORMAT(32X,12HSYMBOL TABLE,//)
      LINE = 5
      GO TO 300
250   WRITE(IPRT,1011)
1011  FORMAT(24X,21HCROSS REFERENCE TABLE,//,
     1  6H LABEL,4X,4HTYPE,3X,5HVALUE,10X,10HREFERENCES)
      LINE = 6
300   CALL SYMTA
400   IF(IFORM.NE.0) GO TO 410
      WRITE(IPRT,1002)
1002  FORMAT(////)
      GO TO 500
410   WRITE(IPRT,1001) IFRMC
1001  FORMAT (A1)
500   CONTINUE
C     ENDFILE MCFLE
       END
