*        704725   SIGMA 5/7         BPM M:INIT1
***********************************************************************
*M*      IN1      INITIALIZATION FOR THE LOADER'S FIRST PASS.
***********************************************************************
*P*      NAME:    IN1
*P*      PURPOSE: ENTRY/EXIT FROM LDR.
*P*               ALLOCATES THE WORK SPACE FOR THE FIRST PASS.
*P*               READS THE LOCCT,ROM AND TREE TABLES.
*P*               READS AND PROCESSES THE ASSIGN RECORD.
*P*      DESCRIPTION: IN1 OBTAINS MEMORY AND ZEROES ITS OWN DATA PAGE
*P*               (IN LDR) AND READS THE LOCCT,ROM AND TREE TABLES.
*P*               KNOWING THE SIZE OF THESE TABLES,THE DECLARATION,
*P*               REF/DEF,AND EXPRESSION STACK POINTERS ARE NOW
*P*               INITIALIZED. THE REF/DEF STACK FOLLOWS. TOPOMEM IS
*P*               COMPUTED FROM J:EUP IN THE JIT,THE EXPRESSION STACK
*P*               POINTERS ARE SET AND THE DYNAMIC PLISTS ARE MOVED
*P*               INTO DEDICATED AREAS OF THE DATA PAGE FOR FUTURE USE.
*P*               THE ASSIGN RECORD IS SCANNED FOR F:NUMBER DCB NAMES
*P*               AND THESE ARE ENTERED AS PREFS IN THE REF/DEF STACK
*P*               FOR FUTURE BUILDING. UNLESS NOTCB WAS SPECIFIED,M:DO
*P*               IS ALSO PREF-ED TO ALLOW FOR SNAPS AND PMDS. IF THE
*P*               LOAD MODULE IS OVERLAID,M:SEGLD IS PREF-ED FOR USE
*P*               BY THE SEGMENT LOADER. IF BREF WAS SPECIFIED,THE
*P*               LIBRARY ROUTINE S:OVRLY IS ALSO PREF-ED. THE LOAD
*P*               MODULE FILE IS OPENED AND THE INFORMATION IN THE
*P*               LOCCT IS MOVED IN THE OPENLM PLIST. THE SYSTEM LIB.
*P*               IS OPENED TO PREVENT THE ALTERATION OF THE LIBRARY
*P*               WHILE THE LOADER IS USING IT. FINALLY,THE KNOWN
*P*               SIZES NOT ASSOCIATED WITH CSECTS OR DSECTS ARE ADDED
*P*               TO THE TREE. THESE INCLUDE THE TREE SIZE IN THE 01
*P*               AND THE TCB SIZE IN THE 00 AREA OF THE ROOT.
*P*      REFERENCE: THE OVERLAY LOADER TECHNICAL MANUAL CONTAINS A
*P*               DETAILED DESCRIPTION AND FLOW CHARTS FOR IN1.
***********************************************************************
         SYSTEM   SIG7FDP
MODE     EQU      1
         DO       MODE=1
SD       EQU      1
         ELSE
SD       EQU      0
         FIN
DEBUG    EQU      0
CFU      EQU      1
BPMLIB   EQU      0                 1=BUILD BPM LIB UNDER CP-V
*BPMLIB=1 MUST BE USED ONLY WITH MODE=1 AND THEN JUST TO
*FORM A LOADER TO USE IN BUILDING BPM LIBRARIES UNDER CP-V.
         DO       MODE=0
NAMELIST EQU      1
         ELSE
NAMELIST  EQU     0
         FIN
         CSECT    1
         DEF      MCI1
MCI1     EQU      %
         DEF      INIT1
         DEF      EFNAME
         DEF      EFACCNT
         DEF      EFPASS
         REF      M16,M17,MN1,MN9
         REF      Y1
         REF      Y4
         REF      Y01
         REF      Y004
         REF      Y00FFFF
         REF      Y0002
         REF      Y0004
         REF      Y000B
         REF      YFF00FFFF
         REF      TXHEAD
         REF      TXTREE
         REF      DECLSTK
         REF      DECLBAS
         REF      RFDFSTK
         REF      RFDFBAS
         REF      EXPRSTK
         REF      EXPRBAS
         REF      BSEG1
         REF      CSEG1
         REF      BUF
         REF      RSEG00
         REF      START
         REF      LOCCT
         REF      LOADBAS
         REF      NOTLLM
         REF      TOPOMEM
         REF      READLM
         REF      CLOSE
         REF      M:LL
         REF      M:LM
         REF      M:EF
         REF      OPENEF
         REF      USID
         REF      UNSATTBL          ADDR OF UNSAT TABLE IN LOCCT
         REF      UNSATFLG          DW UNSATFLGS IN ROOT DATA
         REF      LOCWD
         REF      HEADADR
         REF      HEADSIZE
         REF      LMNSW
         REF      PBUF
         REF      TEMPSIZE
         REF      DECLSIZE
         REF      RFDFDIS
         REF      TMPSZDIS
         REF      01DIS
         REF      FCOMDIS
         REF      LMNDIS
         REF      TCBBLNK
         REF      GETSEG
         REF      PASS3RET
         REF      ER10X
         REF      ER20
         REF      TXBLNK
         REF      BREFBIT
         REF      TXS:OVRL
         REF      RFLDTBSZ
         REF      Y003
         REF      TRESIZ
         REF      TSTACK
         REF      FASTSRCH          FLAG = 0 IF USING BINARY STACK SEARCH
         REF      RDSYMS            COUNT OF NO. OF ENTRIES IN REF/DEF
*,*                                 POINTER TABLE (RDPTRS).
         REF      RDPTRS            POINTER TO START OF ORDERED LIST
*,*                                 OF POINTERS INTO THE REF/DEF STACK
         REF      BINSRT1           ENTRY TO BINARY SORT ROUTINE FOR
         REF      PATCH
*,*                                 ADDING AN ENTRY TO THE SORT TABLE.
         REF      ER12              ILLEGAL LIBRARY LOAD MODULE ERR CODE
         DO       MODE=1
         REF      CHKLM
         REF      CORELIB
         REF      MREFLAG,TOVBPSD,TOVBALPSD
         DO       CFU=1
         REF      TXM:STAR,CFUPTR
         FIN
         FIN
         REF      RFLDMODS
         REF      CODE
         DO       SD=1
         REF      SYMBOLTB
         FIN
         DO       MODE=0
         REF      CJOB
         FIN
         PAGE
BE       EQU      X'683'
BNEZ     EQU      X'693'
BGE      EQU      X'681'
BGEZ     EQU      X'681'
BL       EQU      X'691'
BAZ      EQU      X'684'
BCR8     EQU      X'688'
BCR10    EQU      X'68A'
BLE      EQU      X'682'
BEZ      EQU      X'683'
BANZ     EQU      X'694'
*        QUIT     ERROR,CONDITION,OUTPUT
         REF      MESSAGE
         REF      IOMSG
QUIT     CNAME
         PROC
LF       EQU      %
         DO       NUM(AF)=3
         DO       AF(2)~=0
         GEN,12,20  AF(2),%+4
         FIN
         STW,AF(3) CODE
         ELSE
         DO       AF(2)~=0
         GEN,12,20  AF(2),%+3
         FIN
         FIN
         LI,R3    AF(1)
         DO       MODE=1&AF(3)=SR3
         B        IOMSG
         ELSE
         B        MESSAGE
         FIN
         PEND
SNAP     CNAME
         PROC
LF       CAL1,3   %+1
         DATA     0,AF(1),AF(2),AF(3),AF(4),X'02000000'
         PEND
         PAGE
*                 SYMBOLIC REGISTER DEFINITIONS.
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
         PAGE
*                 IMMEDIATE CONSTANTS FOR LOADER.
K0       EQU      0
K1       EQU      1
K2       EQU      2
K3       EQU      3
K4       EQU      4
K5       EQU      5
K6       EQU      6
K7       EQU      7
K8       EQU      8
K9       EQU      9
KA       EQU      X'A'
KB       EQU      X'B'
KC       EQU      X'C'
KD       EQU      X'D'
KE       EQU      X'E'
KF       EQU      X'F'
K10      EQU      X'10'
K11      EQU      X'11'
K12      EQU      X'12'
K13      EQU      X'13'
K14      EQU      X'14'
K15      EQU      X'15'
K16      EQU      X'16'
K17      EQU      X'17'
K19      EQU      X'19'
K1C      EQU      X'1C'
K1E      EQU      X'1E'
K1F      EQU      X'1F'
K20      EQU      X'20'
K24      EQU      X'24'
K39      EQU      X'39'
K3C      EQU      X'3C'
K3F      EQU      X'3F'
K40      EQU      X'40'
K43      EQU      X'43'
K6C      EQU      X'6C'
K78      EQU      X'78'
K80      EQU      X'80'
KFF      EQU      X'FF'
K100     EQU      X'100'
K120     EQU      X'120'
K1FF     EQU      X'1FF'
K168     EQU      X'168'            * D360
KNX400   EQU      -X'400'
KNX600   EQU      -X'600'
K200     EQU      X'200'
K202     EQU      X'202'
K256     EQU      X'256'
K800     EQU      X'800'
KC00     EQU      X'C00'
K2000    EQU      X'2000'
K3FFF    EQU      X'3FFF'
K7FFF    EQU      X'7FFF'
K8000    EQU      X'8000'
KFF00    EQU      X'FF00'
K10000   EQU      X'10000'
K1FE00   EQU      X'1FE00'
K1FFFF   EQU      X'1FFFF'
K20000   EQU      X'20000'
KN1      EQU      -1
KN2      EQU      -2
KN3      EQU      -3
KN4      EQU      -4
KN8      EQU      -8
KN16     EQU      -16
KN100    EQU      -100
KTE      EQU      'E'
TREEADR  EQU      PBUF+8
CSEGADR  EQU      PBUF+12
CSEGNO   EQU      PBUF+13
         PAGE
INIT1    EQU      %
*                                   THIS ROUTINE GETS ALL AVAILABLE DATA
*                                   PAGES. R6 CONTAINS THE SIZE OF
*                                   THE LOCCT, TREE AND ROM TABLES
*                                   (PROVIDED BY CCI). IT CALCULATES
*                                   STACK POINTER
*                                   DOUBLE WORDS FOR THE DECLARATION,
*                                   REF/DEF AND EXPRESSION STACK.
*                                   IT ALSO SAVES THE USER ID, GIVEN
*                                   IN R7.
*                                   POINTER TO THE TEMPSTACK.
         LI,R1    -TEMPSIZE       ZERO
         LI,R0    0               DYNAMIC DATA
         STW,R0   DECLSTK+TEMPSIZE,R1   AND TEMPSTACK
         BIR,R1   %-1
         LI,R0    TSTACK+1          SET UP TSTACK DW
         STW,R0   TSTACK
         LW,R1    SR3
         AI,R1    -TSTACK-2
         STH,R1   TSTACK+1
         LI,R0    TSTACK
         DO       DEBUG~=0
         LI,R7    0
         FIN
         INT,R7   *79               GET SYSID FROM JIT
         AI,R7    X'30000'          ADD 3 BYTE COUNT FOR IDNAMES
         SLS,R7   8
         STW,R7   USID
         STW,SR1  PASS3RET          SAVE ID FOR POSSIBLE RETURN TO PASS3
         PSW,SR3  *R0               SAVE RETURN TO LDR
         CAL1,1   OPNLL             OPEN LL FOR ERRORS
         DO       MODE=0
         LI,R1    0
         CI,R5    KC
         BLE      %+2
         LI,R1    -1
         STW,R1   TRESIZ            SET OVERLAY FLAG
         FIN
         DO       MODE=1
*                                   SET MEMORY VIOLATION TRAP CONTROL
         CAL1,8   M:TRAP
         FIN
         CAL1,8   M:GP              GET ALL POSSIBLE CORE
         LW,R1    SR1
         MI,R1    K200              NO. OF WORDS GOTTEN.
         STW,SR2  LOCCT
         LCW,R2   R1                ZERO
         AW,R1    SR2               GOTTEN
         LI,R3    0                 CORE.
         STW,R3   *R1,R2
         BIR,R2   %-1
         DO       MODE=1
         CAL1,8   M:INT
         CAL1,8   STIMER
         CAL1,8   M:GL              GET COMMON LIMITS
         AI,SR2   -1                END OF MEMORY
         STW,SR2  TOPOMEM
         SW,SR2   LOCCT             CALCULATE MIDMEM
         MI,SR2   5                 =5/11 UP FROM LOW END
         DH,SR2   Y000B
         AW,SR2   LOCCT
         AND,SR2  MN9               MAKE MIDDLE OF A PAGE
         AI,SR2   256
         STW,SR2  RDPTRS
         ELSE
         AI,R1    KN2
         STW,R1   TOPOMEM
         FIN
         PAGE
         DO       DEBUG=1
*THIS ROUTINE READS THE LOCCT
* WHICH WAS FORMED PREVIOUSLY BY THE LOCCT PROCESSOR.
* THE ROUTINE IS INCLUDED HERE UNDER THE ASSEMBLY PARAMETER
* DEBUG=2 AS A CONVENIENCE FOR !RUNNING THE LOADER AS A USER
* RATHER THAN AS A PROCESSOR.
READLOCCT EQU     %
         PSW,SR2  *R0
         PSW,D4   *R0
         REF      M:BI,PRINT
         CAL1,8   IGTRAP
         LI,R6    0                 SIZE.
         LI,D4    -1                CHECKSUM.
         LW,D2    LOCCT             BUFFER.
PASS3LCT EQU      %
         LW,R1    *D2
         CAL1,1    READBI
         AI,D4    1
         LB,SR2   *D2               GET CODE
         CI,SR2   X'3E'
         BE       %+3
         CI,SR2   X'1E'
         BNE      BADLCT            BAD CODE
         LI,R3    1
         LB,R2    *D2,R3            GET SEQ.
         CW,R2    D4
         BNE      BADLCT            BAD SEQ.
         LI,R3    2
         LB,R2    *D2,R3            GET CHECKSUM
         LI,R4    0
         STB,R4   *D2,R3            SET CHECKSUM IN IMAGE=0
         LI,R3    3
         LB,R3    *D2,R3            GET BYTE COUNT.
         AW,R6    R3                ACCUMULATE TOTAL.
         AI,R6    -4                RECORD SIZE (BYTES).
         SLS,R3   -2                MAKE WORDS.
         PSW,R3   *R0
         AI,D2    -1
         AW,R4    *D2,R3            FORM A WORD
         BDR,R3   %-1               CHECKSUM IMAGE.
         LH,R5    R4
         AND,R4   M16
         CI,R5    0
         BEZ      %+3               TAKE CARE OF OVERFLOW.
         AW,R4    R5
         B        %-5
         SLD,R4   -8                FORM A BYTE
         SLS,R5   -8                CHECKSUM OF IMAGE.
         CI,R4    0
         BEZ      %+3
         AH,R4    R5
         B        %-5
         SLD,R4   16
         CW,R4    R2
         BNE      BADLCT            BAD CHECKSUM.
         PLW,R3   *R0
         AI,D2    1
         STW,R1   *D2               RESTORE LAST WORD OF PREV. IMAGE.
         AW,D2    R3
         AI,D2    -1
         CI,SR2   X'1E'
         BNE      PASS3LCT
         LI,R5    M:BI
         CAL1,1   CLOSE
         PLW,D4   *R0
         PLW,SR2  *R0
         B        CONTINUE
BADLCT   EQU      %
         LI,R5    BAD
         CAL1,9   2
IGTRAP   GEN,8,7,17  X'14',0,TRAP
         GEN,24,8 0,3
READBI    EQU     %
         GEN,8,24 X'10',M:BI
         GEN,4,28 X'F',0
         DATA     BADLCT
         DATA     BADLCT
         DATA     X'8000000D'
         DATA     120
BAD      TEXTC    'BAD LOCCT FILE'
CONTINUE EQU      %
         SLS,R6   -2
         MTW,1    LOCCT
         FIN
         PAGE
         DO       DEBUG=0
*                                    GET THE LOCCT,TREE AND ROM TABLES
*                                   FROM: ABS AREA ON RAD (BPM)
*                                     OR JIT (CP-V)
         DO       MODE~=1
         LW,R5    LOCCT
         SLS,R6   2
         LI,R7    36
         CAL1,1   RDABS            READ FROM ABS AREA
         SLS,R6   -2
         ELSE
         LW,D3    SR1               LOCATION OF LOCCT FROM M:GL
         INT,R5   *D3
         BCS,8    %+3               CLEAR RETURN  IF  NOT  REQUIRED
         LI,R3    0
         STW,R3   PASS3RET
         STW,R5   BUF               SAVE  LOCCT SIZE
         AI,R5    KNX600
         BLZ      ENUFF             IF INITIAL 4 PAGES IS NOT ENOUGH,
         CAL1,8   M:GP2               GET ADDITIONAL PAGES REQUIRED
         AI,R5    KNX400
         BGEZ     %-2
ENUFF    EQU      %
         LW,R6    BUF
         LW,R5    LOCCT
         AI,R5    -1
         LW,R2    *D3,R6            MOVE FROM JIT
         STW,R2   *R5,R6
         BDR,R6   %-2
         LW,R6    BUF
         FIN
         FIN
         PAGE
*                                   INITIALIZE STACK POINTER DOUBLEWORDS.
         LW,SR2   LOCCT
         AW,SR2   R6                COMPUTE DECL STACK
         AI,SR2   1                 DOUBLEWORD.
         AND,SR2  MN1
         STW,SR2  DECLBAS           BASE
         AI,SR2   KN1
         LW,R2    SR2
         LW,R3    DSTK2
         STD,R2   DECLSTK           AND D.W.
         AI,R2    DECLSIZE          COMPUTE RFDF STACK
         LW,R3    RFDFSTK2
         STD,R2   RFDFSTK           D.W.
         LW,SR2   R2
         AI,SR2   K1
         STW,SR2  RFDFBAS           AND BASE.
         LW,R2    TOPOMEM
         AI,R2    K1
         LI,R3    K0                COMPUTE EXPR STACK
         STD,R2   EXPRSTK           D.W.
         AI,R2    KN1
         STW,R2   EXPRBAS           AND BASE.
         PAGE
         LW,R5    LOCCT
         DO1      MODE=0
         STW,D4   FCOMDIS,R5
         LW,R6    *R5
         CI,R6    X'10'             LIB SPECIFIED
         BAZ      NONLIB            NNOPE
         CI,R6    X'100'            ABS SPECIFIED TOO?
         BAZ      SAVLOCWD          NOPE
         AI,R6    -X'100'           RESET ABS FLAG
         OR,R6    Y01               AND SET SPECIAL DSECT HANDLING FLAG
SAVLOCWD EQU      %
         OR,R6    X2000             YES: SET NOTCB TOO
         CW,R6    RFLDMODS          DID THIS BOZO SAY REF OR BREF
         BAZ      NONLIB            NO
*E*      ERROR:   0200-12
*E*      MESSAGE: ILL. LIB. LOAD MOD.
*E*      DESCRIPTION: THE USER SPECIFIED REF OR BREF ON A LIBRARY LOAD
         QUIT     ER12              YES HE DID. GIVE HIM A HARD TIME.
NONLIB   EQU      %
         STW,R6   LOCWD
         CW,R6    Y004
         BAZ      NORM
         MTW,1    FASTSRCH          TURN OFF FAST SRCH
         MTB,1    RDPTRS            WITHOUT A MESSAGE
         MTB,-2   RDSYMS
         SW,R6    Y004              MEBBE RESET MAPONY FLAG
         CW,R6    Y003              IS THIS REALLY A MAPONLY
         BAZ      NONLIB
         PSW,SR2  *R0               SAVE SR2 FOR LATER USE.
         B        ZTREE2
RD%HD1   EQU      %
         LI,R5    M:LM
         CAL1,1   1,R4              OPEN DCB FOR EXISTING LM.
         PLW,SR2  *R0
         LW,R5    SR2
         LI,R6    X'30'        LOAD NUMBER OF WORDS INTO R6
         LI,R7    TXHEAD
         DO       MODE=1
         BAL,SR4  CHKLM
         FIN
         CAL1,1   READLM       READ HEAD RECORD.  R5=BUFFER ADDRESS.
         STW,R5   HEADADR
         INT,R3   2,R5
         SLS,R3   1            LOAD MODULE BIAS.
         STW,R3   LOADBAS           SAVE IT FOR FIN
         LW,R3    1,R5
         AND,R3   M17               PICK UP LMN'S START ADDRESS
         STW,R3   START             AND SAVE IT FOR THE MAPER
         INT,R3   5,R5         TREE SIZE IN WORDS.
         AI,R5    HEADSIZE     TREE ADDR (FOLLOWS HEAD)
         STW,R5   TREEADR
         AW,R5    R3
         STW,R5   RFDFBAS      REF/DEF AD(FOLLOWS TREE).
         SLS,R3   2
         STW,R3   TRESIZ       SIZE OF TREE IN BYTES.
         LW,R5    TREEADR
         LW,R6    TRESIZ
         LI,R7    TXTREE       **GET TREE RECORD**
         DO       MODE=1
         BAL,SR4  CHKLM
         FIN
         CAL1,1   READLM       READ TREE RECORD.
         LW,R2    TREEADR
         LI,R3    0
         STW,R2   CSEGADR      CURRENT SEGMENT TREE ADR.
         STW,R3   CSEGNO       CURRENT SEGMENT DISPL IN TREE.
         LI,R3    1
         STW,R3   LMNSW        IF EXISTING LOAD MODULE.
         LW,R1    TREEADR      PLACE TREE ADDRESS INTO R1 TO BE
         AI,R1    1            USED BY FIN--POSITION BEYOND COUNT.
         PLW,SR3  *R0
         B        *SR3
NORM     EQU      %
         LI,R3    0
         STW,R3   LMNSW        SET SWITCH TO INDICATE NORMAL RUN.
         LW,R6    4,R5
         LW,R2    R6
         SLS,R6   -17               GET REF TABLE SIZE
         STW,R6   RFLDTBSZ
         AND,R2   M17
         STW,R2   4,R5              ZAP REF SIZE IN LDBIAS OF THE LOCCT
*                                   ADJUST THE RELATIVE POINTER TO THE
*                                   ATREE AND ROM TABLES TO ACTUAL ADDRESSES
         AWM,R5   3,R5
         AWM,R5   2,R5
         LW,R6    2,R5
         AI,R6    KN1
         AWM,R6   *R6
         MTW,1    *R6
         LW,R2    3,R5              PICK UP ROMT AND TREET POINTERS
         LW,R1    2,R5
         DO       MODE=1
         CAL1,8   M:FCP             RELEASE ALL COMMON PAGES
         FIN
*                                   ZERO THE LAST 6 WORDS OF EACH
*                                   SEGMENT OF THE TREE TABLE.
ZTREE    LW,R4    R1
         AI,R4    KN1
         LW,R6    R1
         AI,R6    K4
         LI,D1    K0
ZTREE1   LI,R7    K6
         STW,D1   *R6,R7
         BDR,R7   %-1
         AI,R6    KB
         CW,R6    *R4
         BL       ZTREE1
*
*
*                                   MOVE THE M:LM OPEN PLIST ABOVE
*                                   THE TEMPSTACK
ZTREE2   EQU      %
         LW,R4    EXPRSTK
         AI,R4    -(LMPLX-LMPL)
         LI,R3    LMPLX-LMPL
         LW,R6    LMPL-1,R3
         STW,R6   *R4,R3
         BDR,R3   %-2
*                                   SET UP OPEN PLIST WITH ALL
*                                   PARAMETERS FROM THE LOCCT. USE
*                                   "IDL" IF IT IS A LIBRARY LOAD
*                                   MODULE.
         LW,R6    8,R4
         AND,R6   YFF00FFFF
         STW,R6   8,R4
         LCI      9
         LM,R6    10,R5
         LCI      3
         STM,R6   9,R4
         LI,R7    -1                IF THIS IS A LIBRARY,
         DO       MODE=1
         LI,SR1   K1FE00
         AND,SR1  4,R5              OR IF BIAS=0
         STW,SR1  LOADBAS
         BEZ      INHCL
         AND,R6   Y00FFFF           (CORE OR :LIB TYPE),
         CW,R6    :P                INHIBIT CORE LIBRARY
         BE       INHCL             YES
         FIN
         LW,R6    LOCWD
         CI,R6    K10
         DO       BPMLIB=1
         QUIT     X'34',BANZ        QUIT IF ATTEMPTING TO BUILD
*                                    NON-LIB LMN WITH SPECIAL
*                                    LOADER FOR CP-V USE
         ELSE
         BAZ      NOTLIB
         FIN
         LW,R6    USID
         AI,R6    'L'
         STW,R6   9,R4
         LW,R6    NOACCT
         STW,R6   12,R4
         DO       MODE=1
INHCL    RES
         STW,R7   CORELIB
         FIN
         DO       SD=1
         STW,R7   SYMBOLTB          SET DONT FORM IST
         FIN
NOTLIB   LCI      2
         STM,SR2  13,R4
         STM,SR4  16,R4
         DO       BPMLIB=1
         CI,D2    0
         BNE      EXPIRE
         LW,D2    TXNEVER           DEFAULT EXPIRE FOR BPM='NEVER'
         LW,D3    TXNEVER+1
EXPIRE   EQU      %
         B        EXPROK
         FIN
         STM,D2   19,R4
         DO       MODE=1
         CI,D2    0                 IS FIRST WORD OF EXPIRE DATE ZERO
         BNEZ     EXPROK            BRANCH IF NOT
         LW,D1    R4
         AI,D1    18                  OTHERWISE,
         LI,R3    2                 CLEAR NO. OF SIGNI. WDS IN EXPIRE
         STB,D2   *D1,R3            CONTROL WD IN OPEN FPT
EXPROK   EQU      %
         FIN
         INT,R6   9,R5
         SLD,R6   1
         LW,D1    LOCCT
         AI,D1    K14
         LW,D2    19,R5             CHECK LOCCT FORMAT
         BEZ      %+4               OLD..NOLIB PASSWORD
         LC       D2                IS THIS A COUNT BYTE
         BCS,15   %+2               OR A CHARACTER
         AI,D1    3                 A COUNT..LIB NAME
         LW,D2    D1
         AW,D2    R6
         LW,R5    R4
         AI,R5    K15
         LI,R3    2
         STB,R6   *R5,R3            SIGNIF. NO. OF WORDS FOR READ ACCTS
         LI,R6    16
         LW,D3    *D1,R6
         STW,D3   *R5,R6
         BDR,R6   %-2
         LW,D1    D2                SET D1 TO END OV WRITES
         AW,D1    R7                LESS ONE
         AI,R5    K11
         STB,R7   *R5,R3            SIGNIF. NO. OF WDS FOR WRITE ACCTS
         LI,R7    16
         LW,D3    *D2,R7
         STW,D3   *R5,R7
         BDR,R7   %-2
         DO       MODE=1
         STW,D1   UNSATTBL
         MTW,1    UNSATTBL
         LW,R6    LOCCT
         INT,R7   8,R6              NO. OF UNSAT ACCTS
         SLS,R7   2                   4 WDS PER ACCT
         LD,D3    UNSDFLT           DEFAULT FLAGS FOR OLD LOVCTS
         CI,R7    X'3FC00'          IS THE NUMMER VERY LARGE
         BAZ      %+4               NO
         SLS,R7   -10               YES..MUST BE NEW FORMAT
         LCI      2
         LM,D3    *UNSATTBL         GET FLAGS FOR NEW LOCCT
         STD,D3   UNSATFLG          PUTEM AWAY
         AW,D1    R7
         LW,D2    D1
         LW,R7    5,R6              NO. OF EXECUTE ACCTS
         LH,R7    R7
         SLS,R7   1                   2 WDS PER ACCT
         AW,D2    R7
         AI,R5    K11
         STB,R7   *R5,R3            SIGNIF. # WDS FOR EX ACCTS
         LI,R7    16
         LW,D3    *D1,R7
         STW,D3   *R5,R7
         BDR,R7   %-2
         AI,R5    K11
         LC       *R6               IS THERE VEHICLE
         BCR,1    %+2               NO
         LI,R7    K3
         STB,R7   *R5,R3            SET COUNT
         LI,R7    K3
         LW,D3    *D2,R7
         STW,D3   *R5,R7
         BDR,R7   %-2
         FIN
         LW,D1    16,R4
         BNEZ     PASSOK
         LI,R6    0
         LI,R7    X'FF00'
         STS,R6   15,R4
PASSOK   EQU      %
         LW,R6    LOCWD
         AND,R6   Y004
         BNEZ     RD%HD1            MAP EXISTING LOAD MODULE.
         LW,R6    M:EF              SAVE ASN FIELD IN
         STW,R6   RSEG00            CASE M:EF HAS BEEN ASSIGNED TO TAPE.
*                                   PREPARE TO READ "DCB" RECORD FROM
*                                   RAD TO DISCOVER WHAT  F: ASSIGN
*                                   CARDS ARE PRESENT. DONT DO THIS
*                                   FOR LIBRARY MODULES
         LW,D4    LOCWD
         CI,D4    X'10'
         BANZ     NOASGNS5
         DO       MODE~=1
         STW,R2   LMPLX-LMPL+1,R4
         LW,R5    RFDFSTK
         SLS,R5   -9                COMPUTE BUFFER AREA ON
         AI,R5    2                 PAGE BOUNDARY, TWO PAGES
         SLS,R5   9                 ABOVE REFDEF STACK
         LW,R6    CJOB-1            GET CCITAB
         LW,R6    11,R6             GET RAD SECTOR SIZE
         SLS,R6   2                 MAX BYTE COUNT FOR THE RECORD
         LI,R7    35
*                                   THE RECORD CONSISTS OF A LIST OF
*                                   F: NUMBER NAMES IN TEXTC FORMAT
*                                   STARTING ON WORD BOUNDARIES. 1ST
*                                   WRD IN RECORD IS THE RECORD SIZE
         CAL1,1   RDABS
         LW,D1    0,R5              GET TABLE SIZE
         AW,D1    R5                POINTER TO END OF TABLE
         LW,R2    RFDFSTK
         AI,R5    1
         AI,R2    1
GTASGNS1 EQU      %
         LB,R6    *R5
         AI,R6    K4                *
         SLS,R6   -2
         AI,R6    3
         LW,R7    Y0002
         STB,R6   R7
         STW,R7   0,R2              MARK THE ENTRY A PREF
         LI,R7    0
         STW,R7   1,R2              CLEAR VALUE
         STW,R7   2,R2              AND RESOLUTION FIELDS
         LW,R7    0,R5              MOVE DCB NAME INTO RFDF ENTRY
         STW,R7   3,R2
         LW,R7    1,R5              MOVE 2ND WRD TOO-IF ANY; IF NOT,
         STW,R7   4,R2              THIS WILL BE OVERWRITTEN LATER.
         AW,R2    R6                UPDATE REFDEF POINTER
         AI,R6    KN3
         AW,R5    R6                UPDATE POINTER TO TABLE
         CW,R5    D1
         BL       GTASGNS1
         SW,R2    RFDFSTK
         AI,R2    KN1               TOTAL SIZE OF NEW ENTRIES
         MSP,R2   RFDFSTK
         SLS,R2   16                INCLUDE SIZE OF NEW ENTRIES
         STW,R2   RFDFDIS,R1        IN R00T'S TREE
         LW,R2    LMPLX-LMPL+1,R4
         ELSE
         DO       MODE+CFU=2
         LW,R3    RFDFSTK
         LW,R5    LOCCT
         LCI      2
         LM,R6    LMNDIS,R5
         CD,R6    TXM:MON
         BNE      REFCFU
         STW,R6   MREFLAG           MREF MODE IN EFFECT
         SW,R3    RFDFBAS           PUT PREF'S FOR T:OVBALPSD
         AI,R3    2                 AND T:OVBPSD IN RFDF.
         STW,R3   TOVBALPSD         SAVING DISPS FOR FUTURE USE
         AI,R3    6
         STW,R3   TOVBPSD
         LI,R5    TXT:OVBAL
         BAL,SR4  REFDCB
         LI,R5    TXT:OVB
         BAL,SR4  REFDCB
         B        NOCFU
REFCFU   EQU      %
*                                   UNLESS LOADING THE CP-V
*                                   MONITOR OR LIBLMN,
*                                   FORCE REF TO M:*
         MTW,0    LOADBAS           IF BIAS=0, NO DCBS
         BEZ      NOASGNS5
         AI,R3    K1
         STW,R3   CFUPTR
         LI,R5    TXM:STAR
         BAL,SR4  REFDCB
         FIN
NOCFU    EQU      %
         LW,D4    LOCWD             DON'T DO THIS
         CI,D4    X'200'            IF NO ASSIGNS
         BAZ      NOASGNS           HAVE BEEN READ
*                 READ ASSIGN/MERGE RECORD ABOVE REF/DEF STACK.
*                 SCAN IT FOR F:NUMBER DCBS.
*                 SET UP REF/DEF PREF ENTRY.
         LW,R5    RFDFSTK           COMPUTE
         SLS,R5   -9                BUFFER
         AI,R5    1                 AREA ON
         LW,D4    LOCCT             IF INITIAL 4 PAGES IS NOT
         SLS,D4   -9                ENOUGH TO INCLUDE
         AI,D4    4                 THE ASSIGN/MERGE RECORD
         CW,D4    R5                THEN GET
         BG       %+2               2 ADDITIONAL
         CAL1,8   M:GP2             PAGES
         SLS,R5   9                 PAGE BOUNDARY.
         STW,R5   *R5               MAKE SURE PAGE IS AVAILABLE.
         CAL1,1   RDAMR
         MTW,0    1,R5              DISPLACEMENT TO FIRST ASSIGN ENTRY.
         BEZ      NOASGNS
         STW,R5   BUF               SAVE AMR TABLE BASE.
         AW,R5    1,R5              ADDRESS OF FIRST ENTRY.
MOREAMR  EQU      %
         AI,R5    1
         LW,SR1   *R5
         SLS,SR1  -8
         AND,SR1  M16
         CI,SR1   'F:'
         BNE      AMR50
         LB,R3    *R5               FOUND AN F:.GET BYTE COUNT.
AMR10    EQU      %
         LB,SR1   *R5,R3
         CI,SR1   X'F0'             IS IT NUMERIC
         BL       AMR50
         CI,R3    3                 YES.
         BE       %+2
         BDR,R3   AMR10
         LI,SR4   AMR50             SET RETURN
REFDCB   RES
         LW,R6    RFDFSTK           SET UP REF/DEF ENTRY
         LW,R7    Y0002             SET ENTRY TYPE TO PREF.
         LB,R3    *R5
         AI,R3    4                 COMPUTE ENTRY
         SLS,R3   -2                WORD COUNT
         AI,R3    3
         STB,R3   R7
         STW,R7   1,R6
         LW,R7    TXBLNK            BLANK PAD LAST WORD
         STW,R7   *R3,R6
         MSP,R3   RFDFSTK           ACCOUNT FOR ENTRY IN STACK
         SLS,R3   16
         AWM,R3   RFDFDIS,R1        AND IN THE TREE'S ROOT.
         AI,R6    4                 START OF TEXT
         LB,R7    *R5               COUNT
         STB,R7   *R6
         LB,R3    *R5,R7            MOVE THE REST OF THE DCB NAME
         STB,R3   *R6,R7
         BDR,R7   %-2
         DO       MODE=1
         MTW,0    FASTSRCH          IF NO BINARY SEARCH
         BNEZ     *SR4              DONT MAKE ONE
         LCI      4
         PSM,R2   *R0
         LW,D4    R6
         PSW,SR4  *R0               SAVE RETURN
         BAL,SR4  BINSRT1           ADD TO SORT TABLE
         PLW,SR4  *R0
         LCI      4
         PLM,R2   *R0
         FIN
         B        *SR4
AMR50    EQU      %
         LW,R5    -1,R5
         BEZ      NOASGNS
         AW,R5    BUF               GO PROCESS NEXT ASSIGN.
         B        MOREAMR
*E*      ERROR:   0200-20
*E*      MESSAGE: BAD ASSIGN/MERGE RECORD
*E*      DESCRIPTION: AN I/O ERROR OCCURRED READING THE ASSIGN/MERGE
*E*               RECORD.
*E*      REGISTERS: SR3 CONTAINS THE I/O ERROR INFORMATION.
ER20X    QUIT     ER20,,SR3
         FIN
NOASGNS  EQU      %                 *
         DO       MODE=1
         MTW,0 MREFLAG
         FIN
         BNEZ     NOSGLD
         LW,R5    LOCWD
         CW,R5    RFLDMODS
         BANZ     SGLD
         LW,R5    LOCCT             REF M:SGLD IF MORE THAN
         LW,R5    2,R5              ONE  SEGMENT
         SW,R5    -1,R5
         LCW,R5   R5
         CI,R5    X'C'
         BLE      NOBREF
SGLD     EQU      %
         LI,R5    TXM:SGLD
         BAL,11   REFDCB
NOSGLD   EQU      %
         LW,R5    LOCWD
         CW,R5    BREFBIT
         BAZ      NOBREF
         LI,R5    TXS:OVRL
         BAL,11   REFDCB
NOBREF   EQU      %
*                                   IF NOTCB WAS NOT DECLARED WE
*                                   FORCE A REFERENCE TO M:DO.
         LW,R5    LOCWD
         CI,R5    K2000
         BANZ     NOASGNS5
         LI,R5    TXM:DO
         BAL,11   REFDCB
NOASGNS5 EQU      %                 *
*                                   OPEN THE LOAD MODULE FILE.
         LW,R6    LOCWD
         CW,R6    Y004
         BANZ     %+3
         LI,R6    K8
         STW,R6   7,R4
         LI,R6    ER10X
         STW,R6   3,R4
         LW,R6    Y4
         LW,R7    YC
         STS,R6   2,R4
*                                   MOVE THE OPEN ELEMENT FILE PLIST
*                                   TO THE TSTACK.
         CAL1,1   1,R4
         CAL1,1   SETDCB
         LI,R4    OPENEF-1
         LI,R5    EFPLX-EFPL
         LW,R6    EFPL-1,R5
         STW,R6   *R4,R5
         BDR,R5   %-2
*                                   ESTABLISH VFC FOR THE MAP.
         CAL1,1   VFC
*                                   IF M:EF IS ASSIGNED TO LABELED
*                                   TAPE WE MUST FLAG ALL THE ENTRIES
*                                   IN THE ROM TABLE ENTRIES TO
*                                   DISTINGUISH THEM FROM LIBRARY
*                                   LOAD MODULES FROM THE DISC,
*                                   WHEN THEY ARE ADDED TO THE TABLE
*                                   LATER.
         LI,R4    0                 PICK UP ORIGINAL ASN FIELD OF
         XW,R4    RSEG00            M:EF.
         CI,R4    K2
         BAZ      NOTTAPE
         LW,R7    LOCCT
         LW,R7    3,R7              GET POINTER TO ROM TABLE
         AI,R7    2
LROMS    LI,R5    2
         STS,R5   *R7
         AI,R7    7
         CW,R7    DECLBAS
         BLE      LROMS
NOTTAPE  RES
         MTW,0    LOADBAS           IF BIAS=0, NO LOADER BUILT STUFF
         BEZ      ENDINIT1
         PAGE
*                                   INITSIZE ACCOUNTS, IN THE TREE
*                                   TABLE FOR EACH SEGMENT, FOR THE
*                                   TWO WORDS AT THE FRONT OF THE 01
*                                   PROTECTION TYPE FOR THE NAMELIST
*                                   AND IN THE ROOT SEGMENT FOR TREE
*                                   TABLE AND THE TCB.
         B        INITSIZ2
INITSIZE LI,R4    CSEG1
         LI,R5    BSEG1
INITSIZ1 BAL,SR4  GETSEG
         B        INITSIZ2
         B        INITSIZ2
         B        ENDINIT1
INITSIZ2 LW,R7    CSEG1
         AI,R7    01DIS
         AW,R7    R1
         LW,D4    LOCWD
         CI,D4    K10
         BANZ     NO01
         MTW,0    CSEG1
         BNEZ     INITSIZE
         LW,R5    R1
         AI,R5    KN1
         SW,R5    *R5
         LCW,R5   R5
         AI,R5    2                 ADD 1 FOR THE COUNT AND 1 IN CASE
*                                   TREE IS ODD.
         AND,R5   MN1
         SLS,R5   15
         DO       NAMELIST=1
         AW,R5    Y0004
         FIN
         AWM,R5   *R7
         LW,R4    LOCWD
         CI,R4    K2000
         BANZ     INITSIZE
NO01     MTW,0    CSEG1
         BNEZ     INITSIZE
         LW,R4    LOCWD
         CI,R4    K2000
         BANZ     INITSIZE
         AI,R7    5-7               00DIS-01DIS
         LW,R5    LOCCT
         AI,R5    TMPSZDIS
         LH,R6    *R5
         LW,R4    R6
        AI,R5    7-8               ERRDIS-TMPSZDIS
         LH,R6    *R5
         AW,R4    R6
         INT,R5   *R5
         AW,R4    R5
         AI,R4    TCBBLNK+14
         AI,R4    1
         AND,R4   MN1
         SLS,R4   15
         AWM,R4   *R7
         B        INITSIZE
*                                   INIT1 EXIT.
*
ENDINIT1 PLW,SR3  *R0
         B        *SR3
YC       DATA     X'C0000000'
X2000    DATA     X'2000'
         PAGE
TXM:SGLD TEXTC    'M:SGLD'
         DO       MODE=1
         REF      TRAP
M:TRAP   GEN,8,24 X'14',TRAP
         DATA     X'00200001'
M:GL     GEN,8,24 11,0
OPNLL    GEN,8,24 20,M:LL
         DATA     X'1000000',2      OUT
M:INT    GEN,8,24 14,PATCH
STIMER   DATA     X'11040000',X'10000000'
M:GP     GEN,8,24 8,4
M:GP2    GEN,8,24 8,2
M:FCP    GEN,8,24 X'D',256
         ELSE
M:GP     GEN,8,24 8,256
         FIN
LMPL     GEN,8,24 X'14',M:LM
         DATA     X'8F000001'
         DATA     NOASGNS,10,2,2,1
         DATA     X'01010303',0,0,0,X'02000202',0,0,X'03000202',0,0
         DATA     X'04000202',0,0,X'05001010'
         DO       16
         DATA     0
         FIN
         DO       MODE=0
         DATA     X'06011010'
         ELSE
         DATA     X'06001010'
         FIN
         DO       16
         DATA     0
         FIN
         DO       MODE=1
         DATA     X'14001010'
         DO       16
         DATA     0
         FIN
         DATA     X'15010303',0,0,0
         FIN
LMPLX    EQU      %
EFPL     GEN,8,24 X'14',M:EF
         DATA     X'C7000001'
         PZE      *SR1              ERROR
         PZE      *SR1              ABN
         DATA     1,1,1             SEQ,DIR,IN
EFNAME   EQU      %+1-EFPL+OPENEF
EFACCNT  EQU      EFNAME+4
EFPASS   EQU      EFNAME+7
         DATA     X'01000303',0,0,0,X'02000202',0,0,X'03010202',0,0
EFPLX    EQU      %
VFC     GEN,8,24 5,M:LL
         GEN,28,4 1,0
NOACCT   DATA     X'02000002'
         DO       MODE~=1
RDABS    GEN,8,24 X'16',M:LM
         DATA  X'B8000000',NOASGNS,X'80000005',X'80000006',X'80000007'
         ELSE
RDAMR    GEN,8,7,17   X'2D',0,M:EF
         DATA     X'70000000'
         DATA     ER20X
         GEN,1,31 1,R5
         DATA     X'800'
:P       DATA     X'007AD700'
         FIN
SETDCB   GEN,8,24 6,M:LM
         DATA     X'80000000',ER10X
         DO       BPMLIB=1
TXNEVER  TEXT     'NEVER'
         FIN
         DO       MODE=1
TXT:OVBAL DATA    X'0AE37AD6'
         DATA     X'E5C2C1D3'
         DATA     X'D7E2C440'
TXT:OVB  DATA     X'08E37AD6'
         DATA     X'E5C2D7E2'
         DATA     X'C4404040'
         FIN
         BOUND    8
TXM:MON  TEXTC    'M:MON'
DSTK2    GEN,1,15,16 1,DECLSIZE,X'8000'
RFDFSTK2 DATA     X'FFFF8000'
TXM:DO   TEXTC    'M:DO'
UNSDFLT  DATA     X'4044484C',X'5054585C' ACCT,PASS EACH..NO NAME
         END

