*********************************************************************
*M*      LYNX     A USER INTERFACE TO THE OVERLAY LOADER
*********************************************************************
*P*      NAME:    LYNX
*P*      PURPOSE: TO PROVIDE A CONVENIENT USER INTERFACE TO THE
*P*               OVERLAY LOADER FOR BOTH BATCH AND ONLINE USERS.
*P*      DESCRIPTION: LYNX ACCEPTS AND SCANS THE '!LYNX' AND :TREE
*P*               COMMANDS, BUILDS CORRESPONDING LOCCT, ROM, AND
*P*               TREE TABLES IN COMMON MEMORY PAGES, AND LINKS
*P*               TO THE OVERLAY LOADER TO PERFORM THE ACTUAL
*P*               LOADING OPERATIONS.
*P*      REFERENCE: THE CP-V BATCH PROCESSING AND TIMESHARING REFERENCE
*P*               MANUALS.
*********************************************************************
         SYSTEM   SIG7D
         SYSTEM   BPM
         PCC      0
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
SR1      EQU      8
SR2      EQU      9
SR3      EQU      10
SR4      EQU      11
D1       EQU      12
D2       EQU      13
D3       EQU      14
D4       EQU      15
         SPACE    2
         REF      M:SI
         REF      M:LL
         REF      M:LM
         REF      M:BI
         REF      J:JIT
         REF      J:CCBUF
         REF      JB:CCARS          RECORD SIZE IN J:CCBUF
         REF      J:ACCN
         DEF      LYNX00
         DEF      LYNX01
         DEF      LYNXPP
         DEF      OPNAMES
         DEF      OPMASKS
         DEF      OPNXTFLD
         DEF      OPSUBRS
         DEF      LOCCT
         DEF      TREET
         DEF      ROMT
         DEF      PATCH
         SPACE    4
LOCCT    EQU      X'B000'           PAGE FOR INITIAL BUILDING OF LOCCT
LOCCT0   EQU      LOCCT+1           START OF ACTUAL LOCCT TABLE
TREET    EQU      LOCCT+X'200'      PAGE FOR BUILDING INITIAL TREE TABLE
ROMT     EQU      X'C000'           PAGE FOR START OF ROM TABLES
TESTPAGE EQU      X'14000'          CLEAR PAGE PLACE
DELIMITERS SET    C'  .(),;-'  - MUST BE LAST AND EIGHTH
DELCHARS SET      S:UT(DELIMITERS)
#DELIMS  SET      S:NUMC(DELCHARS)
MAXFLDSIZ EQU     48                MAXIMUM # OF CHARS IN CMD FIELD
BIASVALU EQU      X'A000'           DEFAULT LOAD BIAS FOR CPV B00
SEVLEV   EQU      4                 DEFAULT SEVERITY LEVEL FOR LOADER
TSTACK   EQU      BIASVALU          POINTER TO TSTACK IN XLOAD'S TCB
         PAGE
*
*        OPTION   'OPTION NAME', BIT(S) IN LOCCT, SETTING(S) IF
*                 OPTION FOUND, DEFAULT VALUE(S),(FLAG=1 IF
*                 MANDATORY ARG., =0 IF NO ARG., =-1 IF OPTIONAL ARG.,
*                 ADDRESS OF SPECIAL ACTION ROUTINE (IF ANY)
*
*   BUILDS ALL TABLES NECESSARY TO DRIVE OPTION PARSER
*
OPNAMES  CSECT    1
         DATA     0
OPMASKS  CSECT    1
         DATA,8   0
OPNXTFLD CSECT    1
         DATA,1   0
OPSUBRS  CSECT    1
         DATA     0
LOCCTWD  SET      SEVLEV**16+X'200' SEVERITY LEV. + ASSIGNS READ
OPTBIT   SET      1                 NON LOCCTWD BITS
OPTCOUNT SET      0                 WILL BE COUNT OF # OF POSSIBLE OPTIONS
OPTION   CNAME
         PROC
         LOCAL    HERE,I,MSK,VAL
         ERROR,7,S:NUMC(AF(1))>4 'OPTION MUST BE < 4 CHARS.'
OPTCOUNT SET      OPTCOUNT+1
HERE     EQU      %
         USECT    OPNAMES
         TEXT     AF(1)             BUILD NAME TABLE
         DO       NUM(AF(2))>0
VAL      SET      NUM(AF(3))*(NUM(AF(2))-NUM(AF(3)))
MSK      SET      NUM(AF(4))*(NUM(AF(2))-NUM(AF(4)))
         DO       MSK=0&VAL=0
I        DO       NUM(AF(2))
MSK      SET      MSK|1**(31-AF(2,I))  BUILD MASK INTO LOCCTWD FOR OPTION
VAL      SET      VAL|AF(3,I)**(31-AF(2,I)) AND CORRESP. BIT VALUES
LOCCTWD  SET      LOCCTWD|AF(4,I)**(31-AF(2,I)) BUILD INIT. WD1 OF LOCCT
         FIN
         USECT    OPMASKS
         DATA     VAL,MSK           BUILD MASK,VAL TBL (FOR STS)
         ELSE
         ERROR,7,1 '#OF BITS AFFECTED BY OPTION NOT CONSISTANT'
         FIN
         ELSE
         USECT    OPMASKS
         DATA     OPTBIT,0          ZERO MASK IF NO SET BITS
OPTBIT   SET      OPTBIT**1         SHIFT TO NEXT POSITION
         FIN
         USECT    OPNXTFLD
         DATA,1   AF(5)             FLAG WHETHER OR NOT ARG ASSOCIATED
         USECT    OPSUBRS
         DATA     AF(6)             TABLE OF PTRS TO SPECIAL ROUTINES
         USECT    HERE              ...BACK TO WHERE WE CAME FROM
         PEND
         PAGE
*
*   DEFINE ALL OPTION KEYWORDS FOR XLOAD
*
         OPTION   'L',30,0,0
         OPTION   'NL',30,1,0
         OPTION   'FDP'             NOP
         OPTION   'NP'              NOP
         OPTION   'D'               DISPLAY UNDEFINED SYMBOLS - DEFAULT
         OPTION   'ND'              DON'T DISPLAY 'EM - NOP
         OPTION   'C'               DISPLAY DOUBLE DEFS - DEFAULT
         OPTION   'NC'              DON'T - NOP
         OPTION   'I',4,0,1         INCLUDE ROM SYMBOL TABLES
         OPTION   'NI',4,1,1        DON'T INCLUDE 'EM
         OPTION   'BI',20,1,0,,OPTBI
         OPTION   'G',5,1,0         BUILD GLOBAL SYMBOL TABLE
         OPTION   'NG',5,0,1        NO GLOBALS
         OPTION   'SS',6,0,1        OUTPUT SIZE SUMMARY
         OPTION   'T',28,0,1        MAKE LMN A TFILE (=NOT SAYING PERM)
         OPTION   'LIB',(23,27),(0,1),(1,0),-1,OPTLIB  OPTIONAL NAME
         OPTION   'LB',,,,1,OPTLB   LOAD BIAS  (LB,VALUE)
         OPTION   'CL',2,1,0        'CORELIB'
         OPTION   'C1',19,1,0       'CSEC1'
         OPTION   'M10',(25,26),(0,1)
         OPTION   'M100',(25,26),(1,0)
         OPTION   'TSS',,,,1,OPTTSS (TSS,SIZE) - SAME AS BIG LOADER
         OPTION   'ERT',,,,1,OPTERT 'ERTABLE'  (ERT,SIZE)
         OPTION   'ERS',,,,1,OPTERS 'ERSTACK'  (ERS,SIZE)
         OPTION   'NTCB',18,1,0     'NOTCB'
         OPTION   'A',23,1,1        'ABS'
         OPTION   'R',23,0,1        'REL'
         OPTION   'M',11,1,0
         OPTION   'MN',11,1,0
         OPTION   'MV',10,1,0
         OPTION   'MNV',(10,11),(1,1),(0,0)
         OPTION   'MVN',(10,11),(1,1)
         OPTION   'NM',(10,11)      NO MAP
         OPTION   'NBS',9,1,0       NO BINARY  SEARCH
         OPTION   'MON',(9,11),(1,1)
         OPTION   'MOVN',(9,10,11),(1,1,1)
         OPTION   'MO',(9,11),(1,1),(0,0)
         OPTION   'MOV',(9,10),(1,1),(0,0)  MAPONLY BY VALUE
         OPTION   'MONV',(9,10,11),(1,1,1),(0,0,0) MAPONLY NAME,VALUE
         OPTION   'RDEF',8,1,0
         OPTION   'LDEF',16,1,0
         OPTION   'UDEF',31,1,0
         OPTION   'DREF',7,1,0
         OPTION   'SL',,,,1,OPTSL   (SL,VALUE) -- SAME AS LOADER
         OPTION   'PA',17,1,0       MAKE A PAGED LM
         OPTION   'RD',,,,1,OPTRD   READ ACCTS  (RD,ACCT,...)
         OPTION   'WR',,,,1,OPTWR   WRITE ACCTS  (WR,ACCT,...)
         OPTION   'EX',,,,1,OPTEX
         OPTION   'EV',3,1,0,1,OPTEV
         OPTION   'UN',3,1,0,1,OPTEV  MAKE PCL COMPATIBLE
         OPTION   'EXP',,,,1,OPTEXP EXPIRE DATE
         OPTION   'OSP',24,1,0         FORCE CSECT 0 INTO ROOT
         OPTION   'OS',(1,29),,,,OPTOS         SEG MODE OVERLAID
         OPTION   'OR',(1,29),(0,1),,-1,OPTOR  REF MODE OVERLAID
         OPTION   'OB',(1,29),(1,0),,-1,OPTOB  BREF MODE OVERLAID
         OPTION   'SEG',(1,29),,,,OPTOS        SEG MODE OVERLAID
         OPTION   'REF',(1,29),(0,1),,-1,OPTOR REF MODE OVERLAID
         OPTION   'BREF',(1,29),(1,0),,-1,OPTOB BREF MODE OVERLAID
         OPTION   'MREF',,,,-1,OPTOR     MREF MODE FOR MONITOR
         OPTION   'PRIV',,,,1,OPTPRIV    PRIVILEGED PROCESSOR FLAGS
         OPTION   'NASN',22,0,1     IGNORE ASSIGN/MERGE RECORD FOR DCBS
         OPTION   'LDR',,,,1,OPTLDR
         OPTION   'NDIC',,,,,OPTNDIC
         PAGE
M:GO     DSECT    2                 MAKE DETERMINABLE GODCB
         DO1      6
         DATA
         DATA     M:GO+22,0,0,0,M:GO+32
         DO1      11
         DATA
         DATA     X'1000003'
         RES      3
         DATA     X'2000002'
         RES      2
         DATA     X'3010002'
         RES      10
LYNX00   CSECT    0
         BOUND    8                 (JUST A REMINDER TO ANYONE...)
SAVEREGS RES      16
INBUFSIZ RES      1                 # CHARS IN INBUF
INBUF    RES,1    140               COMMAND INPUT BUFFER
FIELDSIZ RES      1                 # CHARS IN FIELDBUF
FIELDBUF RES,1    MAXFLDSIZ         BUFFER FOR INDIVIDUAL CMD FIELDS
         BOUND    4
******* DATA TO BE ZEROED BY INIT1 STARTS HERE *******
INITZERO EQU      %
#ROMS    RES      1                 # OF ELEMENT FILES TO BE LOADED
ROMFLAG  RES      1                 ZERO WHILE PROCESSING EF NAMES
TREEFLAG RES      1                 SET IF :TREE CARD IS EXPECTED
CURPOS   RES      1                 CURRENT CHAR POS. IN INBUF
OPTFLGS  DATA     0,0
DASHFLAG DATA     0
ERRCOUNT DATA
#SEGS    DATA     0
ROMINDX  DATA
ENDINIT0 EQU      %
******* END OF DATA TO BE ZEROED BY INIT1 ************
ONFLG    DATA     0                 SET IF 'ON' PREPOSITION USED (BATCH)
NXTDELIM RES      1
LASTENT  RES      1
EXITCC   DATA     0
MYNAME   RES      1
LMN      RES      7
EXECVEH  RES      3                 EXECUTE FEVICLE
TXTCFLD  RES      3                 FOR NAMES IN TEXTC FORM
LNKFPT   DATA     X'2000003'
         DO1      7
         DATA     0
         BOUND    8
DELEXS   DATA     '(, ;'+X'1010100'
DELEX    DATA     CHKDELIM
PREPFLG  DATA     -1                0=> ON/OVER FOUND
OPENSI   GEN,8,24 X'14',M:SI
         GEN,8,24 X'C1',1           ERR,ABN,ACCESS, TYPE=FILE
         DATA     CFILERR,0
         DATA     1                 MODE = IN
         GEN,8,8,8,8 1,0,3,3
CFNAM    RES      3
         GEN,8,8,8,8 2,0,2,2
CFACCT   RES      2
         GEN,8,8,8,8 3,1,2,2
CFPASS   RES      2
OPNBI    GEN,8,24 20,M:BI
         DATA     X'F0000000'
         DATA     BIERR,BIERR
         PZE      *SR2              BUFFER ADDRESS
         DATA     120               RECL
OPNBO    GEN,8,24 20,M:GO
         DATA     X'FF400001',BIERR,BIERR
         PZE      *SR2              BUFFER
         DATA     120,10,1,1,2,2    RECL,TRIES,CON,SEQ,OUT,SAVE
         DATA     X'1000101'
BOFILE   RES      1                 FILE NAME
         DATA     X'02000000',X'03010000' RESET ACCN,PASSWORD
READBI   GEN,8,24 16,M:BI
         DATA     X'C0000000',BIERR,BIABN
WRITEBO  GEN,8,24 17,M:GO
         DATA     X'C0000000',BIERR,BIERR
CLOSEBO  GEN,8,24 21,M:GO
Y8       DATA     X'80000000',2     CLOSE AND SAVE
PRECF    GEN,8,24 X'1D',M:SI
         DATA     X'40000000',PRECABN
PRECR    GEN,8,24 X'1D',M:SI
         DATA     X'10'
OPENLM   GEN,8,24 20,M:LM
         GEN,8,24 X'C1',1
         DATA     NOLMN,NOLMN
         DATA     1
         GEN,8,8,8,8 1,0,3,3
LMNAME   RES      3
         GEN,8,8,8,8 2,0,2,2
LMNACCT  RES      2
         GEN,8,8,8,8 3,1,2,2
LMNPASS  RES      2
UNSATTBL EQU      %
         RES      8*8               ROOM FOR 8 UNSATS
READTBL  RES      16
WRITETBL RES      16
EXTBL    RES      16
PATCH    RES      50                HANDY THING TO HAVE AROUND
         PAGE
LYNX01   CSECT    1
         BOUND    8                 (ANOTHER REMINDER NOT TO PUT JUNK HERE)
CCBUFMBS DATA     BA(J:CCBUF),BA(INBUF)
TTBSREGS GEN,8,24 7,BA(TTBSTBL)     NO DASH UNTIL TREE CARD
         DATA     BA(INBUF)
FIELDMBS DATA     BA(INBUF),BA(FIELDBUF)
TXT:SYS  TEXT     ':SYS '           MUST PRECEDE A ZERO FOR UNSAT
DWZERO   EQU      %
ZERO     DATA,8   0
         DO1      3
         DATA,8   0
ATOF     DATA     'A','F'
0TO9     DATA     '0','9'
BLANKS   TEXT     '       '
TXTNONE  TEXT     'NONE    '
TXT:TREE TEXT     ':TREE'
TXTNEVER TEXT     'NEVER'
*  END OF DOUBLEWORD BOUNDARY DATA
ZAPINBUF GEN,8,24 140,BA(INBUF)
ZAPINIT  GEN,8,24 4*(ENDINIT0-INITZERO),BA(INITZERO)
ZAPFLDBUF GEN,8,24 MAXFLDSIZ,BA(FIELDBUF)
TXTCMOV  GEN,8,24 12,BA(TXTCFLD)
DFLTMOV  GEN,8,24 DFLTSZ,LOCCT0*4
ROMCOMP  GEN,8,24 11,ROMT*4
DELIMS   TEXTC    DELIMITERS
3B       GEN,24,8 X'030000','B'
Y08      DATA     8**24
TXT%     TEXT     '%   '
TXTOVER  TEXT     'OVER'
TXTON    TEXT     'ON'
TXTRUN   TEXT     'RUN '
TXTC:J0  TEXTC    ':J0'
TXTC:P0  TEXTC    ':P0'
TXTJN    TEXT     'J0  '
TXTPN    TEXT     'P0  '
JPMSK    DATA     X'FFF0FFFF'
MN4      DATA     X'FFFFFFFC'
DFLTLOCT DATA     LOCCTWD,0,0,0
         DATA     BIASVALU
         DATA     0                 NONE EX ACCT
         DATA     0,X'A000A'        ERS,ERT
         DATA     X'400000'         TSS,NUNSAT
         DATA     0                 NRD,NWR
         GEN,8,24 3,'L'             LMNAME
         TEXT     '     '           BLANK FILL NAME
         DATA     0,0,0,0           ACCT,PASSWORD
         DATA     0,0               EXPIRE
         TEXTC    ':LIB'
         DATA     '    ',0,0        PASSWORD
RDDISP   EQU      %-DFLTLOCT        SIZE OF FIXED PART
DFLTSZ   EQU      BA(%)-BA(DFLTLOCT)
TTBSTBL  EQU      %                 TTBS TABLE FOR SCANNER
         DO1      64
         DATA     0
         LOCAL    I,HERE
HERE     EQU      %
I        DO       #DELIMS
         ORG,1    BA(TTBSTBL)+DELCHARS(I)
         DATA,1   I                 PUT ITS INDEX
         FIN
         ORG      HERE
         LOCAL
DECTBL   EQU      %-16              CVA TABLE OF WHICH THE 1ST...
         DATA     8000,4000,2000,1000  ...16 WORDS WILL NEVER BE USED
         DATA     800,400,200,100
         DATA     80,40,20,10
         DATA     8,4,2,1
F:LOADER DSECT    2
F:LOADER M:DCB    (FILE,'LOADER',':SYS',3),PASS
         PAGE
         M:PT     1
LYNXPP   CSECT    1
LYNX     EQU      %
         M:TRAP   TRAPPER,(TRAP,NAO),(IGNORE,FX)
,OPNSID  M:OPEN   M:SI,(DEVICE,'SI')  IN CASE IT GOT PREASSIGNED
         LC       J:JIT
         BCS,8    ONLINE
         CAL1,1   READSI            READ JUNK IN CCBUF
         LI,R7    79
         LI,SR1   X'40'
         CB,SR1   J:CCBUF,R7        FIND LAST CHAR OF BATCH CMD STRING
         BNE      %+2
         BDR,R7   %-2
         AI,R7    1                 # OF CHARACTERS IN COMMAND
         B        MOVECC
ONLINE   EQU      %
         M:PC     '>'
         LB,R7    JB:CCARS          BYTE COUNT OF JUNK IN J:CCBUF
         AI,R7    -1                DON'T COUNT CR
MOVECC   EQU      %
         LW,R1    ZAPINBUF
         MBS,R0   BA(BLANKS)        CLEAR INPUT BUFFER
         LD,R2    CCBUFMBS
         STB,R7   R3
         MBS,R2   0                 MOVE CCBUF TO INBUF
INIT0    RES      0                 MAKE A DEFAULT LOCCT
         LW,R3    DFLTMOV
         MBS,R3   BA(DFLTLOCT)-LOCCT0*4
         INT,R3   J:JIT             PUT SYSID IN PROPER PLACES
         STW,R3   LOCCT0+1
         SLS,R3   8
         STS,R3   LOCCT0+10
         LI,R3    -1
         STW,R3   PREPFLG
         LCI      2
         LM,R2    J:ACCN
         STM,R2   LOCCT0+13         SET OUTPUT ACCOUNT NAME
         LM,R2    TXTNONE           SET DEFAULT READ ACCT
         STM,R2   READTBL           IF EX AND NO RD
         STW,R2   LNKFPT+1          CLOBBER LOADER NAME UNLESS LDR OPT
INIT1    EQU      %
         STW,R7   INBUFSIZ
         LW,R1    ZAPINIT
         MBS,R0   BA(ZERO)          ZERO INITIAL DATA, FLAGS, COUNTERS
         BAL,SR4  SCANNER           GET 1ST FIELD (=XLOAD,LINK,RUN,ETC)
         BCS,1    SYNERR            DIDN'T FIND A FIRST FIELD
         LW,R1    FIELDBUF
         STW,R1   MYNAME            SAVE NAME USED TO ENTER XLOAD
         CI,SR1   '.'               SKIP OVER ANY FOLLOWING ACCOUNT
         BNE      MAINLOOP
         LW,R1    CURPOS
         LB,R1    INBUF,R1
         CI,R1    X'40'
         BE       MAINLOOP
         BAL,SR4  SCANNER
MAINLOOP EQU      %                 WE'LL PASS THIS WAY A FEW TIMES
         LW,SR1   ='(, ;'+X'1010100' ERRORS SCAN TO NEXT FIELD
         LI,SR2   CHKDELIM
         STD,SR1  DELEXS
         BAL,SR4  SCANNER           GET NEXT FIELD OR DELIMITER
         BCS,8    EOFHIT            END OF COMMAND
         BCR,1    PROCFLDS          GO PROCESS A FIELD
CHKDELIM EQU      %
         CI,SR1   ','               COMMA REMAINS ROM READING
         BE       MAINLOOP
         LW,R1    #ROMS             IF WE WERE IN 'EM
         STW,R1   ROMFLAG           OUT OF ROMNAMES
         CI,SR1   '('               START OF AN OPTION
         BE       PROCOPT           YEP
         CI,SR1   X'40'             MIGHT BE SPURIOUS BLANK DUE TO...
         BE       MAINLOOP          ...ENTRY AT CHKDELIM FROM PROCFLD
         CI,SR1   ';'
         BNE      SYNERR            YOU BLEW IT
         B        UNSAT             DO A LIBRARY SEARCH NUMMER
         SPACE    2
EOFHIT   EQU      %                 (OR, 'ARE WE REALLY AT THE END...')
         MTW,0    TREEFLAG          IS A :TREE CARD COMING UP
         BNEZ     PROCTREE          YEP
         LW,R1    #ROMS             CHECK ROM COUNT
         BEZ      ADDIDG            NO ROMS IS GOFILE
         BDR,R1   WRAPUP            MORE THAN ONE, GO FINISH
         MTW,0    PREPFLG           MUST NOT HAVE ON/OVER
         BGEZ     WRAPUP
,CLSSI   M:CLOSE  M:SI
PZDRQ    LCI      7
         LM,R1    ROMT              PICK UP 1ST ROM TABLE ENTRY
         LCI      3
         STM,R1   CFNAM             SET UP TO OPEN THIS FILE TO SEE...
         LCI      2                 ... IF ITS A ROM OR A COMMAND FILE
         STM,R4   CFACCT
         STM,R6   CFPASS
         CAL1,1   OPENSI            OPEN THE FILE
         LI,R1    CFILERR
,READSI  M:READ   M:SI,(BUF,INBUF),(SIZE,140),(BTD,0),(ABN,*R1),WAIT
         LW,R1    M:SI+13
         AI,R1    -1                IF THERE ARE ANY ZEROES
         MTB,0    INBUF,R1          IT CANT BE A COMMAND FILE
         BEZ      CFILERR
         BDR,R1   %-2
         CAL1,1   PRECR             FORCE REREAD OF FIRST RECORD
         LI,7     -1                BY SETTING INBUFSIZ NEGATIVE
         MTW,1    ONFLG             MUST CHECK ON IF FROM FILE
         B        INIT1
CFILERR  RES
         CAL1,1   CLSSI             YES: CLOSE IT
         CAL1,1   OPNSID            AND BACK TO DEVICE
         PAGE
*        RESET NOT LAST FLAG FOR LAST ROM IN ROMT,
*        FIGURE #'S & MOVE READ, WRITE, & UNSAT ACCOUNTS
*        INTO LOCCT
*        MOVE ALL THESE TABLES CONTIGUOUSLY INTO COMMON MEMORY,
*        & CALL THE LOADER.
*        REMEMBER LMN IN 'LMN'
*        EXIT TO LMN IF ENTERED VIA 'RUN' COMMAND
WRAPUP   EQU      %                 AND PREPARE TO EXIT TO LOADER
         MTW,0    ERRCOUNT          GIVE UP IF ERRORS
         BNEZ     OPERR+1
         LI,R1    RDDISP            DISP. TO VAR. LENGTH PART OF LOCCT
         LH,R2    LOCCT0+9          # READ ACCNTS
         BNEZ     %+4               SOME WERE SPECIFIED
         MTH,0    LOCCT0+5          NONE, WERE THERE EXECUTE ACCTS
         BEZ      GETWR             NO, LEAVE DEFAULT
         MTH,1    LOCCT0+9          YES, SET READ NONE
         LI,R0    READTBL
         LI,SR3   2                 SIZE OF READTBL ENTRY
         BAL,SR4  MOVER             MOVE READ ACCTS TO LOCCT
GETWR    EQU      %
         LI,R2    X'FFFF'
         AND,R2   LOCCT0+9          # WRITE ACCOUNTES
         BEZ      GETUNSAT          NONE
         LI,R0    WRITETBL
         LI,SR3   2
         BAL,SR4  MOVER             MOVE WRITE ACCOUNTS TO LOCCT
GETUNSAT EQU      %
         ANLZ,R0  LOCCT0I1          BASE OF UNSATTBL
         LI,R6    0                 HANDY INDEX REG
         LW,R2    LOCCT0
         CI,R2    2                 CHECK NOSYSLIB
         BANZ     NOSYSLIB
         INT,R7   LOCCT0+8          CURRENT # OF ENTRIES
         MTW,1    LOCCT0+8          ONE FOR THIS ONE
         LD,R4    TXT:SYS           NAME=0(IN R1),ACCT=:SYS,PASS=0 (IN R6)
         SLS,R7   3                 INDEX INTO TABLE
         LCI      7
         STM,R1   UNSATTBL,R7
NOSYSLIB RES
         LI,R2    X'FFFF'
         AND,R2   LOCCT0+8          GET # OF UNSAT ACCNTS FROM LOCCT
         BEZ      NOUNSAT           NOTHING TO DO
         AI,R1    2                 SPACE FOR FLAGS
UNSATLP  SLS,R6   3                 GET NEXT UNSAT SPECIFICATION
         LCI      7
         LM,SR2   UNSATTBL,R6
LOCCT0I1 STM,SR2  LOCCT0,R1
         SLS,R6   -3
         ANLZ,R5  LOCCT0I1          CALCULATE FLAG BYTE
         SW,R5    R0                DISP INTO TABLE
         MTB,0    SR2               IS THERE NAME
         BEZ      %+3               NO
         AI,R5    X'80'             YES, SET FLAG
         AI,R1    3                 AND SPACE TO ACCOUNT
         AI,R1    2                 SPACE FOR ACCNT
         STM,D1   LOCCT0-2,R1       WHICH IS ALWAYS THERE
         STM,D3   LOCCT0,R1         STORE PASSWORD IF THERE
         AI,D3    0
         BEZ      %+3
         AI,R5    X'40'
         AI,R1    2
         STB,R5   *R0,R6            STORE FLAG
         AI,R6    1
         BDR,R2   UNSATLP
NOUNSAT  ANLZ,R3  LOCCT0I1          GET TOTAL SIZE
         SW,R3    R0                OF UNSATTBL
         SLS,R3   8                 AND PUT IT IN THE LOCCT
         STS,R3   LOCCT0+8
         LH,R2    LOCCT0+5          # EXECUTE ACCNTS
         BEZ      GETEV             NONE
         LI,R0    EXTBL
         LI,SR3   2                 # OF WORDS PER ENTRY
         BAL,SR4  MOVER             MOVE TO LOCCT
GETEV    EQU      %
         LW,D1    =1**28
         CW,D1    LOCCT0            WAS EXECUTE VEHICLE SPECIFIED
         BAZ      NOEV              NOPE
         LCI      3                 MOVE EXECUTE VEHICLE NAME
         LM,D1    EXECVEH           ... INTO LOCCT
         STM,D1   LOCCT0,R1
         AI,R1    3
NOEV     EQU      %
         AI,R1    1                 POINT TO START OF TREE TABLE
         STW,R1   LOCCT0+2          SAVE POINTER IN LOCCT
         MTW,0    TREEFLAG          IS THIS GUY OVERLAID
         BEZ      NOTREE            NO
         LW,R2    #SEGS             # OF SEGMENTS
         LW,R3    R2
         MI,R3    11                GET TREE TABLE SIZE
         STW,R3   LOCCT0-1,R1       SAVE IT IN LOCCT
         LI,R0    TREET
         LI,SR3   11                EACH ENTRY IS 11 WORDS
         BAL,SR4  MOVER             MOVE TREET INTO LOCCT
         B        GETROMT
NOTREE   EQU      %
         LI,R2    11                TOTAL # OF WORDS IN TREET
         LCI      3
         LM,R3    LOCCT0+10         SEGNAME = LMN IF NOT OVERLAID
         LCI      8
         LM,R6    ZERO
         LCI      12
         STM,R2   LOCCT0-1,R1       MOVE TREE TABLE TO LOCCT
         AI,R1    11
GETROMT  EQU      %
         STW,R1   LOCCT0+3          DISPLACEMENT FROM LOCCT TO ROM TBL
         MTW,0    TREEFLAG          DID 'PROCTREE' MARK LAST ROMS
         BNEZ     MOVEROMT          YES
         LW,R3    #ROMS
         AI,R3    -1
         MI,R3    7
         LI,R4    0
         LI,R5    X'40'
         STS,R4   ROMT+2,R3         MARK LAST ROM IN SEG
         CI,R3    0                 IS THERE ONLY ONE 'ROM'
         BNE      MOVEROMT          NO, MORE THAN ONE SPECIFIED.
         LH,R3    LOCCT0            GET LOCCT FLAGS
         CI,R3    X'40'             IS THIS A 'MAP ONLY'
         BAZ      MOVEROMT          NOPE
         CI,R3    X'30'             OR NBS
         BAZ      MOVEROMT          TIS NBS, DONT WRITE ON EF
         LCI      7                 YEP: SO 'ROM' IS ACTUALLY 'LMN',
         LM,R2    ROMT              ...SO MOVE ITS NAME INTO THE...
         STM,R2   LOCCT0+10         ...LMN FIELD OF THE LOCCT.
MOVEROMT EQU      %
         LW,R2    #ROMS
         LI,R0    ROMT
         LI,SR3   7
         BAL,SR4  MOVER             MOVE ROM TABLE INTO LOCCT
         STW,R1   LOCCT             SAVE SIZE OF ALL TABLES
         LCI      7
         LM,R2    LOCCT0+10
         STM,R2   LMN               REMEMBER LMN
         AI,R1    511
         SLS,R1   -9                # OF PAGES IN LOCCT TABLES
         OR,R1    =X'0C'**24        MAKE AN M:GCP FPT
         CAL1,8   R1                AND GET SOME COMMON PAGES
         BCS,8    NOCORE            OH-OH
         LI,SR4   X'800'            COPY BI IIF REQUESTED
         CW,SR4   LOCCT0
         BAZ      NOBI
         CAL1,1   OPNBI
         CAL1,1   OPNBO
COPYBI   CAL1,1   READBI
         LI,SR4   2                 COUNT EODS
         CAL1,1   WRITEBO
         B        COPYBI
BIABN    LB,SR3   SR3               CHECK FOR DEOD OR EOF
         CAL1,1   CLOSEBO           SAVE OUTPU
         CI,SR3   6                 IF EOF, DONE
         BE       NOBI
         CI,SR3   5                 IF EOD, GET TWO IN A ROW
         BNE      BIERR             BADDIE
         BDR,SR4  COPYBI
NOBI     RES
         LW,R1    LOCCT             COPY ENTIRE TABLE INTO COMMON
         LW,R3    LOCCT,R1
         STW,R3   *SR2,R1
         BDR,R1   %-2
         LW,R3    LOCCT
         STW,R3   *SR2
         LI,R3    LOCCT-512         RELEASE ALL THE PAGES
         AI,R3    512
         M:FVP    *R3
         CI,R3    ROMT               LAST ROM PAGE IS THE LASS
         BL       %-3
         BCR,8    %-4
         MTW,0    LNKFPT+1          DID WE GET LDR OPTION
         BGZ      GOLOAD
         LI,R2    BA(F:LOADER+23)
         LI,R3    BA(LNKFPT+1)
         LB,R1    0,R2
         AI,R1    1
         STB,R1   R3
         MBS,R2   0
         AI,R3    3
         AND,R3   MN4
         LI,R2    BA(F:LOADER+27)
         OR,R3    Y08
         MBS,R2   0
         OR,R3    Y08
         MBS,R2   4
GOLOAD   LW,R1    MYNAME
         SW,R1    TXTRUN
         STW,R1   MYNAME            SAVE ANSWER
         BEZ      %+4               ASK LOADER TO RETURN
         LI,R1    2
         CW,R1    M:SI              IF SI IS A FILE
         BANZ     %+3               TRY FOR MORE INPUT AFITER LOAD
         LW,R1    Y8                SET FLAG IN LOCCT TO LET...
         STS,R1   *SR2              ...LOADER KNOW TO RETURN
         CAL1,8   LNKFPT
,FCPALL  M:FCP    255               FREE ALL COMMON PAGES
         CW,D4    MYNAME            RUN AND GOOD LOAD
         BCS,7    EXIT              NO, DONT CALL LMN
         LCI      7
         LM,R1    LMN
         STM,R1   LNKFPT+1
         SLS,R1   -24-2             # WORDS IN LMN -1
         LCI      4
         STM,R4   LNKFPT+2,R1       SQUEE ZE
         CAL1,8   LNKFPT
EXIT     EQU      %
         LI,7     2                 NO SPACE IF NOT FILE INPUT
         CW,7     M:SI
         BANZ     PRECABN
         CAL1,1   PRECF             ARE THERE MORE RECS IN SI
         CAL1,1   PRECR             YES, DONT LOSE ONE
         LI,R7    -1                SET INBUFSIZ TO FORCE READ
         B        INIT0             AND START OVER
PRECABN  RES
         M:EXIT                     THAT'S ALL FOLKS
         SPACE    2
MOVER    EQU      %
         STD,SR3  SAVEREGS+SR3
         LW,D4    SR3
         SCS,D4   -4
         LI,R3    0
MOVELOOP EQU      %
         LC       D4
         LM,R4    *R0,R3            (THE BIGGEST CHUNK MOVER CAN...
         STM,R4   LOCCT0,R1         ...HANDLE IS 11 WORDS)
         AW,R1    SAVEREGS+SR3
         AW,R3    SAVEREGS+SR3
         BDR,R2   MOVELOOP
         B        *SAVEREGS+SR4
         PAGE
*
*   FIELD PROCESSOR:  HANDLES E.F. LISTS,
*                     ON/OVER PREPOSITIONS,
*                     LOAD MODULE NAME,
*                     AND UNSAT ACCOUNTS.
*
PROCFLDS EQU      %                 PROCESS FIELDS IN XLOAD COMMAND
         MTW,0    ROMFLAG           ARE WE SCANNING ROM NAMES
         BNEZ     PREPCHK           NO- LOOK FOR ON OR OVER
ADDROM   EQU      %
         LW,R2    FIELDSIZ          LENGTH OF PROSPECTIVE ROM NAME
         CI,R2    10                MUST BE 10 CHARS OR LESS
         BG       ROMLERR           ROM NAME TOO LONG
         LW,R1    #ROMS             # OF ROMS IN ROM TABLE
         MI,R1    7                 DISP TO NEXT FREE ROMT ENTRY
         LCI      3
         LM,R3    TXTCFLD           GET ROMNAME
STROM    STM,R3   ROMT,R1           PUT IT AWAY
         LW,R3    FIELDBUF          CHECK FOR %, I. E. GOFILE
         CW,R3    TXT%
         BE       ADDIDG            YUP, USE M:GO ASSIGNMENT
         CI,SR1   '.'               IS ACCOUNT FOLLOWING
         BE       GETACCT           MAYBE
THISACCT EQU      %
         LCI      2
         LM,R2    J:ACCN
         B        SAVACCT
GETACCT  EQU      %
         BAL,SR4  SCANNER
         BCS,1    THISACCT          DOUBLE '.' = THIS ACCOUNT
         LCI      2
         LM,R2    FIELDBUF
SAVACCT  EQU      %
         STM,R2   ROMT+3,R1         SAVE ROM ACCOUNT
         CI,SR1   '.'               PASSWORD MAYBE?
         BNE      NOPASSWD          NO
         BAL,SR4  SCANNER
         BCR,1    GETPASSWD         GOT A FIELD FOR THE PASSWORD
NOPASSWD EQU      %
         LCI      2
         LM,R2    DWZERO            DEFAULT PASSWD = 0,0
         B        SAVEPASS
GETPASSWD EQU     %
         LCI      2
         LM,R2    FIELDBUF
SAVEPASS EQU      %
         STM,R2   ROMT+5,R1         SAVE ROM PASSWORD
         MTW,1    #ROMS             BUMP COUNT OF ROMT ENTRIES
         CI,SR1   ','               NEXT DELIM A COMMA
         BNE      CHKDELIM          NOPE: NO MORE ROMS FOLLOW
         BAL,SR4  SCANNER
         BCR,1    ADDROM            GO PROCESS NEXT ROM NAME
         B        SYNERR            TWO DELIMITERS IN A ROW
         SPACE    2
ADDIDG   EQU      %
         LI,R4    BA(M:GO+23)       GET FILE NAME FROM M:GO
         LB,R3    M:GO+23           AND LENGTH
         AI,R3    1
         CI,R3    11
         BG       ROMLERR
         ANLZ,R5  STROM
         SLS,R5   2
         STB,R3   R5
         MBS,R4   0                 MOVE TO ROM TABLE
         LI,R2    X'FF00'           CHECK FOR ACCOUNT
         AND,R2   M:GO+26
         LCI      2
         BDR,R2   %+3
         LM,R2    J:ACCN
         B        %+2
         LM,R2    M:GO+27
         STM,R2   ROMT+3,R1         PUT IN TABLE
         LM,R2    M:GO+30           GET PASSWORD IF PRESENT
         B        SAVEPASS
         SPACE    2
PREPCHK  EQU      %
         MTW,1    PREPFLG           ONLY ALLOW ONE ON/OVER
         BGZ      SYNERR
         LW,R2    FIELDBUF
         CW,R2    TXTOVER
         BNE      NOTOVER
         LI,R1    0                 RESET ONFLG IN CASE CONTINUATION
         STW,R1   ONFLG             ...CAUSED IT TO BE SET
         B        PREPOK
NOTOVER  EQU      %
         CW,R2    TXTON
         BNE      SYNERR            WHAT WAS THAT, ANYHOW?
         LC       J:JIT             IF WE'RE ONLINE, THEN TEL...
         BCS,8    PREPOK            ...HAS ALREADY DONE ON/OVER TEST
         MTW,1    ONFLG             SET FOR LATER TEST OPEN OF LMN
PREPOK   EQU      %
         CI,SR1   X'40'             WAS BLANK THE DELIMITER
         BNE      SYNERR            NO, SO I DON'T UNDER STAND YOU
         BAL,SR4  SCANNER
         BCS,1    SYNERR            SHOULDN'T BE ANOTHER DELIMITER
         CI,R2    10                IS NAME TOO LONG
         BG       LMNERR            INDEED IT IS
         LW,R1    FIELDBUF          IF % LEAVE *L IN LOCCT
         CW,R1    TXT%
         BE       %+4
         LCI      3
         LM,R1    TXTCFLD
         STM,R1   LOCCT0+10
         CI,SR1   '.'               IS THERE AN ACCT.
         BNE      CHKONFLG          NO
         BAL,SR4  SCANNER
         BCS,1    CHKLMPW           THIS ACCOUNT. PASSWD MAYBE??
         LCI      2
         LM,R2    FIELDBUF
         STM,R2   LOCCT0+13         SAVE LM ACCOUNT IN LOCCT
CHKLMPW  EQU      %
         CI,SR1   '.'
         BNE      CHKONFLG          NXT DELIM. NOT A PERIOD
         BAL,SR4  SCANNER
         BCS,1    SYNERR            ..WHAT
         LCI      2
         LM,R2    FIELDBUF
         STM,R2   LOCCT0+15         SAVE LM PASSWORD
CHKONFLG EQU      %                 IN ORDER TO MAINTAIN BATCH COMPATIBILITY
         MTW,0    ONFLG             ...WE MUST EVALUATE WHETHER 'ON'
         BEZ      CHKDELIM          ...IS A VALID PREPOSITION...
         STW,SR1  SAVEREGS          ...BY TRYING TO OPEN THE LMN
         LCI      7
         LM,R1    LOCCT0+10         GET LMN, ACCNT, PASSWD.
         LCI      3
         STM,R1   LMNAME            MOVE NAME TO FPT
         LCI      2
         STM,R4   LMNACCT           LIKEWISE THE ACCOUNT
         STM,R6   LMNPASS
         CAL1,1   OPENLM
         B        ONERR             THIS LOOKS FUNNY
NOLMN    EQU      %
         LW,SR1   SAVEREGS
         B        CHKDELIM
         SPACE    2
UNSAT    EQU      %
         INT,R1   LOCCT0+8          GET # OF UNSAT ACCOUNTS
         CI,R1    7                 MAX EIGHT
         BG       ACCTERR
         BL       %+4               OK IF STILL LESS THAN 7
         LW,R2    LOCCT0            EIGHTH IS OK ONLY IF
         CI,R2    2                 WE DONT HAVE TO ADD :SYS
         BAZ      ACCTERR           AT THE END
         MTW,1    LOCCT0+8          BUMP THE COUNT NOW
         SLS,R1   3                 DISP INTO UNSATTBL
         BAL,SR4  SCANNER           GET NAME OR DOT (.)
         LCI      3
         LM,R2    TXTCFLD           PUT IT AWAY
         STM,R2   UNSATTBL,R1
         LM,R2    TXT:SYS           DEFAULT ACCOUNT, 0 PASSWORD
         STM,R2   UNSATTBL+3,R1
         AI,R1    3                 TO ACCOUNT
         CI,SR1   '.'               MUST BE A DOT
         BNE      CHKDELIM
         BAL,SR4  SCANNER           GET ACCOUNT
         BCR,1    %+4               ACCOUNT THERE
         LCI      2
         LM,R2    J:ACCN            NO, USE CURRENT ACCOUNT
         B        %+3
         LCI      2
         LM,R2    FIELDBUF
         STM,R2   UNSATTBL,R1       TUCK AWAY AN UNSAT ACCOUNT
         CI,SR1   '.'               DO WE HAVE A LIBRARY PASSWD.
         BNE      CHKDELIM          NO
         BAL,SR4  SCANNER           GO GET IT
         BCS,1    SYNERR            EXTRA .
         LCI      2
         LM,R2    FIELDBUF
         STM,R2   UNSATTBL+2,R1     SAVE LIBRARY PASSWORD
         B        CHKDELIM
         PAGE
*
*   OPTION PROCESSOR:  HANDLES (OR TRIES TO) ANYTHING ENCLOSED IN
*                    PARENTHESIS IN THE COMMAND STRING, EXCLUDING
*                    THE :TREE CARD ARGUMENTS
*
PROCOPT  EQU      %                 THIS IS THE **OPTION PROCESSOR**
         LI,SR1   ')('+X'100'       ERRORS SCAN TO END OF OPTION
         LI,SR2   CHKPAREN
         STD,SR1  DELEXS
         BAL,SR4  SCANNER           GET OPTION KEYWORD
         BCS,1    SYNERR            THAT'S ALMOST AS BAD
         LI,R1    OPTCOUNT          NOW LET'S FIND OUT WHAT OPTION...
         LW,R2    FIELDBUF          .. THIS IS.
         CW,R2    OPNAMES,R1
         BE       FOUNDOPT
         BDR,R1   %-2
         LW,R3    JPMSK             MEBBE JN OR PN
         CS,R2    TXTJN
         BE       OPTJN             YUP
         CS,R2    TXTPN
         BE       OPTPN             YUP, TOO
         B        OPTERR            NOT THERE
FOUNDOPT EQU      %
         LD,R2    OPMASKS,R1
         STS,R2   LOCCT0            SET OPTION BITS(IF ANY) IN LOCCT
         OR,R2    R3
         DW,R3    R3
         CW,R2    OPTFLGS,R3        DO WE ALREADY HAVE THIS ONE
         BANZ     DUPERR            YUP
         AWM,R2   OPTFLGS,R3
         LB,R2    OPNXTFLD,R1       WHAT ABOUT ARGUMENTS TO THIS GUY
         BNEZ     PROC1             ...THERE MAY BE SOME
         LW,R7    OPSUBRS,R1        GET ADDR. OF SPECIAL ACTION ROUTINE
         BNEZ     CALLSACT          & GO TO IT
         B        CHKPAREN          NO S.ACT. ROUT. (HUH)
PROC1    EQU      %
         LW,R7    OPSUBRS,R1
         AI,R2    -1
         BNEZ     MAYBE             THIS ONE HAS OPTIONAL ARG(S)
         CI,SR1   ','               OPTION MUST FOLLOW COMMA
         BNE      SYNERR            THIS ONE DOESN'T
PROC2    EQU      %
         BAL,SR4  SCANNER           READ 1ST ARG OF OPTION
         BCS,1    SYNERR            (AM I REPEATING MYSELF)
         B        CALLSACT          GO TO SPECIAL ROUTINE
MAYBE    EQU      %
         CI,SR1   ','               IS ARG PRESENT IS THIS INSTANCE
         BE       PROC2             YEP: TREAT LIKE MANDATORY ARGUMENT
         LI,R2    0
         STW,R2   FIELDSIZ          ZAP FIELDSIZ IF NO ARGUMENT
CALLSACT EQU      %
         LW,R1    FIELDSIZ
         BAL,SR4  0,R7
CHKPAREN EQU      %
         CI,SR1   '('               NEW OPTION NEXT
         BE       PROCOPT           YES
         CI,SR1   ')'               IS OPTION TERMINATED PROPERLY
         BNE      SYNERR            NO
         B        MAINLOOP
         PAGE
*
*        PROCESS :TREE COMMANDS
*
PROCTREE EQU      %
         BAL,SR4  READ1
         LW,SR4   Y08               SET DASHFLAG
         STW,SR4  DASHFLAG          TO USE DASH AS DELIMITER
         LCI      2
         LM,R2    FIELDBUF
         CD,R2    TXT:TREE          IS IT A :TREE COMMAND
         BNE      BADTREE           NO
         LI,R1    0
         LI,R2    -1
         LCI      2
         PSM,R1   TSTACK            INITIALIZE STACK FOR TREE BUILDING
         LW,R2    TSTACK
         AI,R2    -1
         STW,R2   LASTENT           PTR TO TSTACK TOP -1
         LI,R2    0                 DISP TO CURRENT ROM
         LI,SR2   SCANTREE          ERROR RETURN
         LW,SR1   ='-,)'+X'10100'
         STD,SR1  DELEXS
ADDSEG   EQU      %
         BAL,SR4  SCANNER           ...LOOKING FOR A ROM NAME
         BCS,1    SYNERR
         BAL,SR4  ROMSETUP          MOVE ROM ENTRY TO PROPER POSITION
         LCI      3
         LM,R3    ROMT-7,R2         SEGNAME
         LCI      7
         LM,R7    ZERO
*   SET BLINKS ON WAY 'IN'
         LW,R6    *LASTENT          GET BLINK TO LAST SEG
         LW,D4    R2
         AI,D4    -7                POINT TO LAST ROM ADDED TO LIST
         STH,D4   R6
         LCI      11
         STM,R3   TREET,R1          MAKE A NEW TREE TABLE ENTRY
         MTW,1    #SEGS
         LW,R3    *TSTACK           GET DISP. TO PARALELL TREE SEG.
         BLZ      SETFLINK          NO PARALELL TREE
*   SET OLINKS ON WAY 'OUT'
         LW,R4    R1                SET PREVIOUS OVERLAY'S...
         LI,R5    X'FFFF'           ... OVERLAY LINK TO POINT TO ...
         STS,R4   TREET+4,R3        ... CURRENT OVERLAY.
         STW,R1   *TSTACK           NEW TOP OF STACK
         AI,R1    11
         B        SCANTREE
*   SET FLINKS ON WAY 'IN'
SETFLINK EQU      %
         STW,R1   *TSTACK           NEW TOP OF STACK
         LW,R3    *LASTENT          GET DISP. TO PREVIOUS ENTRY
         STH,R1   R4
         LI,R5    X'F0000'          SIGN EXTENSION WILL FILL OUT R5
         STS,R4   TREET+4,R3        POINT PREV. GUYS FLINK TO US
         AI,R1    11
SCANTREE EQU      %
         LB,SR1   NXTDELIM
         CI,SR1   '-'
         BE       MOREROMS          ANOTHER ROM IN THIS SEG
         CI,SR1   ','
         BE       NEWSEG            PARALELL OVERLAY SEGMENT
         CI,SR1   ')'
         BNE      SYNERR            WHOOPS...
SEGEND   EQU      %                 END OF OVERLAY SEGMENT
         INT,R3   TSTACK+1
         STB,R3   NXTDELIM          CLOBBER ) SO WE DONT LOOP
         CI,R3    2                 MUST BE AT LEAST 2 ELEMENT IS STK
         BLE      PARERR
         PLW,R3   TSTACK            BACK OFF STACK
         MTW,-1   LASTENT
         BAL,SR4  MARKLAST          MARK ROM AS 'LAST' IN SEG
         BAL,SR4  SCANNER
         BCS,8    ENDTREE           ALL DONE
         BCR,1    SYNERR            EXPECTING A DELIMITER HERE
         CI,SR1   ')'
         BE       SEGEND            END OF ANOTHER SEGMENT
         CI,SR1   ','               PARALELL SEGMENT
         BE       ADDSEG
         B        SYNERR
MOREROMS EQU      %
         BAL,SR4  SCANNER           WE MIGHT HAVE THE START OF A ...
         BCS,1    NEWOVLY           NEW OVERLAY BEING DEFINED
         BAL,SR4  ROMSETUP          ANOTHER ROM FOR THIS SEGMENT
         B        SCANTREE
NEWOVLY  EQU      %
         CI,SR1   '('               MAKE SURE SYNTAX IS CORRECT
         BNE      SYNERR            ITS NOT
         LI,R3    -1                NULL ENTRY FOR...
         PSW,R3   TSTACK            ...NEW TOP OF STACK
         MTW,1    LASTENT
NEWSEG   EQU      %
         BAL,SR4  MARKLAST          MARK ROM AS 'LAST' IN SEG
         B        ADDSEG            & GO TO WORK ON NEW SEGMENT
ENDTREE  EQU      %
         INT,R3   TSTACK+1
         CI,R3    2
         BNE      LEVELERR          WE DIDN'T GET BACK TO TOP LEVEL
         LW,R3    ROMINDX
         CW,R3    #ROMS
         BNE      EFERR             NOT ENOUGH EF'S IN TREE COMMAND
         B        WRAPUP            ...THAT'S IT.
         SPACE    3
ROMSETUP EQU      %
         STW,SR4  SAVEREGS+SR4
         LW,R4    #ROMS
         SW,R4    ROMINDX           # OF ROMS LEFT TO SEARCH
         LW,R3    ROMINDX           CURRENT ROM#
         MI,R3    7                 DISP
         LW,R2    R3                COPIED
         SLS,R3   2                 MAKE IT A BYTE DISP.
FIND     EQU      %
         LW,R7    ROMCOMP
         AW,R7    R3
         LI,R6    BA(FIELDSIZ)+3
         CBS,R6   0                 FIND ROM IN ROM TABLE
         BE       GOTROM
         AI,R3    7**2              ADVANCE TO NEXT ENTRY
         BDR,R4   FIND
         BIR,SR4  ROMTERR           NAME NOT IN EF LLST
         LW,SR4   *%                MAKE BIR TAKE NEXT TIME
         LW,R4    ROMINDX           SEARCH ALREADY USED ONES
         LI,R3    0
         B        FIND
GOTROM   EQU      %
         SLS,R3   -2                BACK TO WORD DISP.
         LCI      7                 SAVE THE ONE WE WANT
         LM,R4    ROMT,R3
         STM,R4   SAVEREGS+R4
         LW,SR4   R3
         SW,SR4   R2                DO WE NEDD TO MOVE IT
         BEZ      INPLACE           NO
         BGZ      MOVROM1
         LW,R3    #ROMS             MULTIPLE USE, MAKE A HOLE
         MI,R3    7
         LW,SR4   R3                GENERATE COUNT
         SW,SR4   R2
         MTW,1    #ROMS             COUNT IT
MOVROM1  AI,R3    -7
         AI,SR4   -6
         LCI      7
         LM,R4    ROMT,R3
         STM,R4   ROMT+7,R3
         BDR,SR4  MOVROM1
         LM,R4    SAVEREGS+R4
         STM,R4   ROMT,R2
INPLACE  EQU      %
         AI,R2    7
         MTW,1    ROMINDX
         B        *SAVEREGS+SR4
         SPACE    2
MARKLAST EQU      %                 MARK LAST MOVED ROM ENTRY...
         LI,R4    0                 ... AS LAST IN SEGMENT.
         LI,R5    X'40'
         LW,R3    ROMINDX           CURRENT ROM#
         MI,R3    7                 DISP
         STS,R4   ROMT-5,R3
         B        *SR4
         PAGE
*
*        SPECIAL ACTION ROUTINES FOR HANDLING OPTIONS THAT
*        SET WIERD FLAGS OR STORE VALUES INTO THE LOCCT.
*
OPTJN    RES
         SW,R2    TXTJN
         LH,R1    R2
         AW,R1    TXTC:J0
J0J1ADD  EQU      %
         LD,R4    TXT:SYS           J0&J1 COME FROM :SYS
ROMADD   EQU      %
         LW,SR2   #ROMS
         MI,SR2   7                 DISP TO NEXT FREE ROMT ENTRY
         AI,SR2   ROMT
         MTW,1    #ROMS
         LD,R2    BLANKS            BLANKPAD FOR TREE BUILDER
         LD,R6    DWZERO            (DEFAULT PASSWORD = 0,0)
         LCI      7
         STM,R1   *SR2              MOVE IT ALL INTO ROM TABLE
         B        CHKPAREN
*
*
*
OPTPN    RES
         SW,R2    TXTPN
         CI,R2    X'10000'          P0,P1 ARE AUTOMATIC
         BLE      CHKPAREN
         LH,R1    R2
         AW,R1    TXTC:P0
         B        J0J1ADD
         SPACE    2
OPTBI    EQU      %                 'BI' READ !BIN INPUT
         LW,R1    LOCCT0+1          GET SYSID
         SLS,R1   8
         OR,R1    3B                BUILD 'SYSID B' FILENAME
         STW,R1   BOFILE             SAVE NAME FOR LATER COPY
         LCI      2
         LM,R4    J:ACCN
         B        ROMADD            ADD FILE TO ROM TABLE
         SPACE    2
OPTLB    EQU      %                 'LB,VAL'  (LOAD BIAS)
         BAL,SR3  HEXCNVRT          GET HEX # BACK IN SR2
         LW,R2    SR2
         LI,R3    X'1FFFF'
         STS,R2   LOCCT0+4
         B        *SR4
         SPACE    2
OPTTSS   EQU      %                 'TSS,SIZE'
         BAL,SR3  HEXCNVRT
         STH,SR2  LOCCT0+8
         B        *SR4
         SPACE    2
OPTERT   EQU      %                 'ERT,SIZE'  LIB. ERTABLE SIZE
         BAL,SR3  HEXCNVRT
         LI,R1    1
         STH,SR2  LOCCT0+7,R1
         B        *SR4
         SPACE    2
OPTERS   EQU      %                 'ERS,SIZE' LIB. ERSTACK SIZE
         BAL,SR3  HEXCNVRT
         STH,SR2  LOCCT0+7
         B        *SR4
         SPACE    2
OPTSL    EQU      %                 'SL,VAL'
         BAL,SR3  HEXCNVRT
         STH,SR2  R2
         LW,R3    =X'F0000'
         STS,R2   LOCCT0
         B        *SR4
         SPACE    2
#READS   EQU      9*2
#WRITES  EQU      9*2+1
#EXACCTS EQU      5*2
OPTRD    EQU      %                 'RD,ACCNT,...'  READ ACCOUNTS
         LI,R1    #READS
         LI,R7    READTBL           PTRS TO # OF ENTRIES & TABLE...
         BAL,SR3  BLDTBL            TO BE USED BY BLDTBL.
         B        *SR4
         SPACE    2
OPTWR    EQU      %                 'WR,ACCNT,...'  WRITE ACCOUNTS
         LI,R1    #WRITES
         LI,R7    WRITETBL
         BAL,SR3  BLDTBL
         B        *SR4
         SPACE    2
OPTEX    EQU      %
         LI,R1    #EXACCTS
         LI,R7    EXTBL
         BAL,SR3  BLDTBL            MOVE EXECUTE ACCTS TO 'EXTBL'
         B        *SR4
         SPACE    2
OPTEV    EQU      %
         CI,R1    11
         BG       LMNERR
         LCI      3
         LM,R1    TXTCFLD
         STM,R1   EXECVEH
         SPACE    2
OPTNDIC  LW,R1    Y08               SET FLAG IN WORD 2
         STS,R1   LOCCT0+1
         B        *SR4
         SPACE    2
OPTLIB   LW,R1    FIELDSIZ
         BEZ      *SR4              NO NAME
         CI,R1    11                CHECK MAX
         BG       NAMERR
         LCI      3
         LM,R1    TXTCFLD
         STM,R1   LOCCT0+19
         B        *SR4
         SPACE    2
OPTEXP   EQU      %                 'EXP, JUNK' EXPIRE DATE
         CI,SR1   ')'               IS THERE ONLY ONE ARG.
         BNE      MMDDYY            NO
         LCI      2
         LM,R2    FIELDBUF
         CD,R2    TXTNEVER
         BE       NEVERST           NEVER IS GOOD
         BAL,SR3  DECCNVRT          MUST BE DDD
         BEZ      NUMERR            0 BAD
         CI,SR2   999
         BG       NUMERR
         LI,R1    '00'              MAKE BDDD00BB
         LCI      2
         LM,R2    FIELDBUF
         STH,R1   R3
         SLS,R2   -8                RIGHT ADJUST
         STB,R1   R2
         CI,R2    X'B0'
         BAZ      %-3
         STB,R3   R2
NEVERST  RES
         LCI      2
         STM,R2   LOCCT0+17         MOVE IT TO LOCCT
         B        *SR4
MMDDYY   EQU      %
         STW,SR4  SAVEREGS+SR4
         BAL,SR3  DECCNVRT
         BEZ      NUMERR            0 BAD
         CI,SR2   12                LEGAL MONTH
         BG       NUMERR
         CI,SR1   ','               AND COMMA MUST BE NEXT
         BNE      SYNERR
         LH,R2    FIELDBUF
         STW,R2   LOCCT0+17         SAVE MONTH
         BAL,SR4  SCANNER
         BCS,1    SYNERR
         CI,SR1   ','
         BNE      SYNERR
         BAL,SR3  DECCNVRT
         BEZ      NUMERR            0 BAD
         CI,SR2   31                MAX DAY
         BG       NUMERR
         LH,R3    FIELDBUF
         XW,R3    LOCCT0+17         STORE, RETRIIEVE MONTH
         STH,R3   LOCCT0+17         AND PUT IT IN TOO
         BAL,SR4  SCANNER
         BCS,1    SYNERR
         BAL,SR3  DECCNVRT
         CI,SR2   99                MAX YEAR
         BG       NUMERR
         LW,R2    FIELDBUF
         SCS,R2   16
         STW,R2   LOCCT0+18
         B        *SAVEREGS+SR4
         SPACE    2
OPTOS    EQU      %                 'OS'  SEG MODE OVERLAID PROG.
         MTW,1    TREEFLAG          SET OVERLAID LM FLAG
         B        *SR4
         SPACE    2
OPTOR    EQU      %                 'OR' / 'OR,NUM'  REF MODE OVERLAY
         MTW,0    FIELDSIZ          WAS 'NUM' OPTION PRESENT
         BEZ      REF1              NO
         BAL,SR3  DECCNVRT          CONVERT DECIMAL # TO HEX
         B        STORCNT
REF1     LI,SR2   22                DEFAULT REF MODE TABLE SIZE
STORCNT  EQU      %
         STH,SR2  R2
         SLS,R2   1                 ALIGN TO LOCCT POSITION
         LI,R3    X'E0000'          SIGN EXTENSION MAKES THIS WORK
         STS,R2   LOCCT0+4
         MTW,1    TREEFLAG          SET OVERLAID LM FLAG
         B        *SR4
         SPACE    2
OPTOB    EQU      %                 'OB' / 'OB,NUM'  BREF MODE OVERLAY
         MTW,0    FIELDSIZ          WAS OPTION PRESENT
         BEZ      BREF1             NO
         BAL,SR3  DECCNVRT
         B        STORCNT
BREF1    LI,SR2   11
         B        STORCNT
         SPACE    2
OPTPRIV  EQU      %
         LW,R1    FIELDSIZ
         CI,R1    1
         BNE      OPTERR            OPTION MUST BE ONE CHAR.
         LB,R1    FIELDBUF          SO GO & GET IT
         LI,R2    #PRIVS            # OF VALID PRIVILEGE FLAGS
         CB,R1    PRIVS,R2          IS IT ONE OF THEM???
         BE       %+3
         BDR,R2   %-2
         B        OPTERR            UNRECOGNIZED OPTION
         LW,R1    Y08               GET A BIT
         SLS,R1   0,R2              SHIFT THE BIT A BIT
         STS,R1   LOCCT0+1          AND SET THE APPROPRIATE PPROC FLAG
         CI,SR1   ','               IS NEXT DELIMITER A COMMA
         BNE      *SR4              NO, MUST BE END OF OPTIONS.
         PSW,SR4  TSTACK
         BAL,SR4  SCANNER           GET NEXT FIELD
         BCS,1    SYNERR            NEXT CHAR IS ANOTHER DELIMITER
         PLW,SR4  TSTACK
         B        OPTPRIV           RECYCLE
         SPACE    2
PRIVS    DATA,1   0,'X','M','J','P'
#PRIVS   EQU      BA(%)-BA(PRIVS)-1
         BOUND    4
         PAGE
OPTLDR   RES
         LI,R2    BA(FIELDSIZ)+3
         LI,R3    BA(LNKFPT+1)
         CI,R1    11                MAX NAME
         BG       SYNERR
         AI,R1    1
         STB,R1   R3
         MBS,R2   0
         AI,R3    3
         AND,R3   MN4
         LI,R2    BA(TXT:SYS)-8     DEFAULT ACCOUNT
         CI,SR1   '.'                IF NOT SPECIFIED
         BNE      %+4
         BAL,SR4  SCANNER
         BCS,1    SYNERR
         LI,R2    BA(FIELDBUF)-8
         OR,R3    Y08
         MBS,R2   8
         CI,SR1   '.'               PASSWORD TOO??
         BNE      CHKPAREN          NO
         BAL,SR4  SCANNER
         BCS,1    SYNERR
         OR,R3    Y08
         MBS,R2   0
         B        CHKPAREN
         PAGE
*
*        SUBROUTINES
*
TRAPPER  RES
         BCR,1    TRAPEX
         LW,R0    0,R1              ADDR OF TRAP
         STW,R0   LMNAME            SAVED
         LW,R2    *LMNAME           CHECK FIRST FOR MBS
         SLD,R2   -24
         CI,R2    X'61'
         BNE      NOTMBS
         SLS,R3   -28               GET REG
         OR,R3    =1
         AW,R3    R1
         LW,R1    2,R3              GET CONTENT OF REG
         SLS,R1   -2
         B        GETPG
NOTMBS   LCI      0                 GET REGS
         LM,R0    2,R1
         ANLZ,R1  *LMNAME           GET ADDR
         BCS,5    TRAPEX
GETPG    M:GVP    *R1               GET THE PAGE
         BCR,8    TRAPEX+1          O.K.
         AI,R1    512               AND THE NEXT
         M:GVP    *R1
         BCR,8    TRAPEX+1          O.K.
         M:GVP    TESTPAGE          GET ONE WE KNOW IS AVAILABLE
         BCS,8    NOCORE            MUST BE FRESH OUT OF MEMORY
TRAPEX   M:TRAP   0,(ABORT,NAO)
         M:TRTN
         PAGE
BLDTBL   EQU      %
         STW,SR4  SAVEREGS+SR4
BLDTBL1  EQU      %
         LH,R2    LOCCT0,R1         GET CURRENT COUNT OF ENTRIES
         CI,R2    8                 DO WE HAVE ENOIUGH ALREADY
         BGE      ACCTERR           YES, CANT TAKE ANY MORE
         SLS,R2   1                 CONVERT TO DISP
         MTH,1    LOCCT0,R1         BUMP FOR THIS ONE
         LCI      2
         LM,R3    FIELDBUF
         STM,R3   *R7,R2            MOVE FIELD INTO TABLE
         CI,SR1   ','               ANOTHER FIELD FOLLOWING???
         BNE      BLDXIT            NO
         BAL,SR4  SCANNER
         BCR,1    BLDTBL1           GOT ANOTHER FIELD
         B        SYNERR            SHOULDN'T HAVE HIT ANOTHER DELIM.
BLDXIT   EQU      %
         LW,SR4   SAVEREGS+SR4
         B        *SR3
         SPACE    2
HEXCNVRT EQU      %                 CONVERT HEX # IN FIELDBUF TO...
         LI,R1    0                 'REAL' HEX # IN SR2
         LW,R2    FIELDSIZ
         LI,SR2   0
         B        %+2
HEXLOOP  EQU      %
         SLS,SR2  4
         LB,R3    FIELDBUF,R1
         CLM,R3   ATOF
         BIL      OKA
         CLM,R3   0TO9
         BOL      HEXERR            BAD HEX DIGIT
         B        %+2
OKA      EQU      %
         AI,R3    9
         AND,R3   =X'F'
         OR,SR2   R3                BUILD UP HEX #
         AI,R1    1
         BDR,R2   HEXLOOP
         B        *SR3
         SPACE    2
DECCNVRT EQU      %                 CONVERT DECIMAL # IN FIELDBUF...
         LW,R1    FIELDSIZ          ... TO HEX # IN SR2
         CI,R1    4
         BG       NUMERR            TOO MANY DIGITS
         LW,R2    =X'F0F0F0F0'
         LW,R3    FIELDBUF
         AI,R1    -1
         PACK,3   R2,R1
         BCS,8    DECERR            ILLEGAL DECIMAL #
         SLS,D4   -4
         CVA,D4   DECTBL
         LW,SR2   D4
         B        *SR3
         PAGE
**************************************************************
*                                                            *
*                 SCANNER                                    *
*                                                            *
*        CALLING SEQUENCE:  BAL,SR4  SCANNER                 *
*        NO ARGUMENTS.                                       *
*        SKIPS TO NEXT NONBLANK.. RETURNS WITH:
*        CC1=0 IF FIELD FOUND                                *
*              FIELD IN FIELDBUF, & COUNT IN FIELDCNT        *
*              3-WORDS OF TEXTC IN TXTCFLD
*              R2  = FIELDSIZ
*              SR1 = TERMINATING DELIMITER.                  *
*        CC1=1 IF 1ST CHAR HIT WAS A DELIMITER(NON-BLANK)    *
*              SR1 = FOUND DELIMITER.                        *
*        CC8=1 IF CC1=1 AND DELIMITER IS EOF
*        NO VOLATILE REGS EXCEPT R2,SR1
**************************************************************
READ1    MTB,-1   INBUFSIZ          SET FLAG FOR AUTO CONTINUE
SCANNER  EQU      %
         LCI      5
         STM,R1   SAVEREGS+R1
         LW,R1    ZAPFLDBUF
         MBS,R0   BA(BLANKS)        CLEAR FIELD BUFFER
         LI,R1    0
         STW,R1   FIELDSIZ          AND FIELD SIZE
         STW,R1   TXTCFLD           AND OTHER FIALD BUFFER COUNT
         LCI      9                 EXITCC=8 WILL MEAN EOF FOUND
         STCF     EXITCC            EXITCC=1 WILL MEAN FIELD NOT FOUND
         LW,R1    CURPOS            GET CURRENT POSITION IN INBUF
BLNKSKP  LI,SR1   X'40'             BLANK IS DELIM FOR EOF
         LW,R2    INBUFSIZ
         BLZ      CONTINUE          IMMEDIATE CONTINUE FOR READ1
         SW,R2    CURPOS            # OF CHARS LEFT IN INBUF
         BLEZ     EOFXIT            NOTHING HERE
SKPLOOP  EQU      %                 ...EOF TERMINATES FIELD.
         CB,SR1   INBUF,R1          ADVANCE TO 1ST NON-BLANK
         BNE      NONBLANK
         AI,R1    1
         BDR,R2   SKPLOOP
NONBLANK EQU      %
         LD,R4    TTBSREGS          SET UP TO LOOK FOR DELIMITERS
         OR,R4    DASHFLAG          INCLUDE - AS DELIM IF IN TREE
         STB,R2   R5                CNT OF REMAINING CHARS IN INBUF
         AW,R5    R1                DISP. TO BEGIN SCANNING
         TTBS,R4  0                 FIND NEXT DELIMITER
         BCR,1    NDEL              NO DELIMITERS IN THE LINE
         LW,R3    Y8                GOT ONE, RESET EOF CC
         STS,R2   EXITCC
         LB,R3    R4                RETURN FOUND DE;LIMITER
         LB,SR1   DELIMS,R3
NDEL     RES
         LB,R5    R5                # OF REMAINING CHARS TO SEARCH
         SW,R2    R5                # OF CHARS BEFORE DELIMITER
         BEZ      CHKCONT           DELIM. WAS ONLY CHAR - NO FIELD
         LC       EXITCC            CC=0 MEANS WERE LOOKING FOR..
         BCR,1    SYNERR            THE DELIM IN A CONTINUATOION..
*                                   SO THIS FIELD IS TWO IN A ROW..
         LD,R4    FIELDMBS
         STB,R2   R5
         AW,R4    R1
         MBS,R4   0                 MOVE FIELD INTO FIELDBUF
         STW,R2   FIELDSIZ
         LW,R5    TXTCMOV           MOVE TO TXTCFLD TOO
         MBS,R5   BA(FIELDSIZ)+3-BA(TXTCFLD)
         LCI      0
         STCF     EXITCC            FLAG INDICATING WE FOUND A FIELD
CHKCONT  EQU      %                 CHECK FOR LINE CONTINUATION
         AW,R1    R2                ADVANCE CURPOS TO DELIMITER
         AI,R1    1                 INCREMENT CURPOS PAST DELIMITER
         CI,SR1   ';'
         BNE      NOCONTIN
         CW,R1    INBUFSIZ          WAS SEMICOLON THE LAST CHAR.
         BE       CONTINUE          YES-READ ANOTHER RECORD
NOCONTIN EQU      %
         STW,R1   CURPOS            SAVE CURRENT CHAR. POS.
EOFXIT   EQU      %
         LCI      5
         LM,R1    SAVEREGS+R1
         STB,SR1  NXTDELIM          SAVE DELIMITER
         LW,R2    FIELDSIZ
         LC       EXITCC
         B        *SR4
         PAGE
CONTINUE EQU      %
         LW,R1    ZAPINBUF
         MBS,R0   BA(BLANKS)        CLEAR INPUT BUFFER
         LI,R1    0                 IGNORE ABNORMAL SINCE THE
*                                   ENTIRELY BLANK LINE LOOKS LIKE EOF
         CAL1,1   READSI            READ ANOTHER RECORD
         STW,R1   CURPOS            RESET CURRENT CHAR POSITION
         LH,R2    M:SI+4
         SLS,R2   -1                GET # OF CHARS READ
         AI,R2    -1                POINT TO LAST ONE
         LI,SR1   ' '               SNUFF CR,LFS
         CB,SR1   INBUF,R2
         BL       %+2
         BDR,R2   %-2
         AI,R2    1
         LI,R3    3
         CS,R3    M:SI              IS M:SI ASSIGNED TO A DEVICE
         BNE      %+3
         LC       J:JIT             ARE WE BATCH (READING C DEVICE)
         BCS,12   %+2               NO ECHO IF UC
,LLECHO  M:WRITE  M:LL,(BUF,INBUF),(SIZE,*R2),(BTD,0)
         STW,R2   INBUFSIZ
         MTW,1    ONFLG             CHECK ON/OVER IF IN CONTINUED LINE
         LC       EXITCC            IF WERE LOOKING FOR A FIELD
         BCS,1    BLNKSKP           IGNORE BLANKS
         B        NONBLANK
         PAGE
*
*  LYNX ERROR MESSAGES
*        OPERR WILL JUST PRINT THE ERROR MESSAGE.
*        USRERR WILL TRY TO POINT TO THE CHARACTER AT WHICH
*               THE ERROR WAS DETECTED.
*
NOCORE   BAL,R0   OPERR
         TEXTC    '*** INSUFFICIENT MEMORY AVAILABLE'
EOFERR   BAL,R0   USRERR
         TEXTC    '*** UNEXPECTED END OF COMMAND'
SYNERR   BAL,R0   USRERR+1          INCLUDE DELIMITER
         TEXTC    '*** SYNTAX ERROR'
DUPERR   BAL,R0   USRERR
         TEXTC    '*** CONFLICTING OPTIONS'
BIERR    BAL,R0   OPERR
         TEXTC    '*** UNABLE TO COPY BI INPUT'
ROMLERR  BAL,R0   USRERR
LMNERR   EQU      %-1
NAMERR   EQU      %-1
         TEXTC    '*** FILENAME IS TOO LONG'
ACCTERR  BAL,R0   USRERR
         TEXTC    '*** TOO MANY ACCESS ACCOUNTS'
ONERR    BAL,R0   USRERR
         TEXTC    '*** ''ON'' ILLEGAL -- LOAD MODULE EXISTS'
OPTERR   BAL,R0   USRERR
         TEXTC    '*** UNRECOGNIZED OPTION'
HEXERR   BAL,R0   USRERR
         TEXTC    '*** ILLEGAL HEXADECIMAL NUMBER'
DECERR   BAL,R0   USRERR
         TEXTC    '*** ILLEGAL DECIMAL NUMBER'
NUMERR   BAL,R0   USRERR
         TEXTC    '*** NUMBER TOO LARGE'
BADTREE  BAL,R0   OPERR
         TEXTC    '*** BAD :TREE COMMAND'
ROMTERR  BAL,R0   USRERR
         TEXTC    '*** ELEMENT FILE IN TREE NOT IN E.F. LIST'
PARERR   BAL,R0   USRERR
         TEXTC    '*** UNBALANCED PARENTHESIS - BAD TREE STRUCTURE'
LEVELERR BAL,R0   USRERR
         TEXTC    '*** NOT BACK TO LEVEL 0 OF TREE'
EFERR    BAL,R0   OPERR
         TEXTC    '*** ELEMENT FILES IN E.F. LIST NOT IN TREE'
         PAGE
USRERR   EQU      %                 GIV THE USER AN ERROR MESSAGE
         MTB,-1   R0                DONT INCLUDE DELIMITER MOST LIKELY
         LCI      2                 SAVE REGS
         STM,R2   SAVEREGS+2
         MTW,1    ERRCOUNT          COUNT ERRORS
         LW,R2    *R0               START WITH A FEW ***S
         STW,R2   UNSATTBL
         LW,R3    =BA(UNSATTBL)+X'15000004' MESSAGE BUILDING PLACE
         LW,R2    R0                GET BUMP COUNT
         SAS,R2   -24               SPREAD SIGN
         AW,R2    CURPOS            ENDD OF MOVED PART
         CB,R2    R3                START AT BEGINNING
         BGE      %+3               IF THERE'S ENOUGH
         STB,R2   R3
         LI,R2    21
         MBS,R2   BA(INBUF)-21
         LB,R2    *R0               SIZE OF MESSAGE
         STB,R2   R3
         ANLZ,R2  %-2               ADDR OF MESSAGE
         MBS,R2   1
         AI,R3    -BA(UNSATTBL)-1
         STB,R3   UNSATTBL
         M:PRINT  (MESS,UNSATTBL)
         LCI      2
         LM,R2    SAVEREGS+2
USRERR1  LW,SR1   DELEXS            SCAN TO UNDERSTANDABLE DELIMITER
         CB,SR1   NXTDELIM
         BE       USRERRX           GOT ONE
         SLS,SR1  -8
         BDR,SR1  %-3
         BAL,SR4  SCANNER
         BCS,8    OPERR+1           ALL DONE
         B        USRERR1
USRERRX  LB,SR1   NXTDELIM
         B        *DELEX
OPERR    EQU      %
         M:PRINT  (MESS,*R0)
         CAL1,8   FCPALL            FREE ALL COMMON PAGES
         M:EXIT   4
         END      LYNX

