         SYSTEM   SIG5                                                          
         TITLE    '       **** LIB ****'                                        
*                                                                               
         DEF      LIB,OLAYLIB,WR40                                              
         REF      ADDNXT,ADDX,B:C,B:ROM,B:X,BAP:ROM,BAP:ROO2,BEPROMI            
         REF      BL:ROO2,BOUNDCS,BOUNDRDW,CCDCBV                               
         REF      CCSTACK,CCVALUE,CHKBLANK,CMPZ,COMPBS,CONVROMX,DCBTYPE         
         REF      DWBOUND,EXTEND,F:DEFREF,F:DEVICE,F:EBCDIC,F:MODIR             
         REF      F:MODULE,F:PUBL,FBA:COMN,FBA:DCBT,FBA:INTT,FBA:LIM            
         REF      FBA:OVLO,FBA:ROO2,FBA:TABS,FBA:TEMP,FL:BACK,FL:BOUND          
         REF      FL:COMN,FL:ERROR,FL:GO,FL:LBLD,FL:LBPAS,FL:LIB,FL:MAP         
         REF      FL:MODF,FL:NXTCC,FL:OFLOW,FL:OUTOV,FL:PAS2,FL:PUBL            
         REF      FL:RTYPE,FL:STEP,FL:TASKS,FL:TEMP,FL:UDCB,FL:UNNAM            
         REF      FLTMPTSK,FPT:CCI6,FPT:CCI7,FPT:CC1,FPT:CC2,FPT:CC3            
         REF      FPT:CC4,FPT:CC5,FPT:CC8,FPT:DIAG,FPT:LB1,FPT:LB11             
         REF      FPT:LB10,FPT:LB13,FPT:LB2,FPT:LB3,FPT:LB4,FPT:LB5             
         REF      FPT:LB6,FPT:LB7,FPT:LB8,FPT:LB9,FPT:ONE1,FPT:ONE2             
         REF      FPT:ONE4,FPT:ONE3,FPT:PRLO,FPT:RDG,FPT:RD2,FPT:RD3            
         REF      FPT:WTG,FPT:XN1,FWA:ASSN,GETDECL,LBA:COMN,LBA:DCBT            
         REF      LBA:LIM,LBA:OVLO,LBA:PATH,LBA:ROM,LBA:ROO2,LOADERR            
         REF      LOADSEG,LWA:ASSN,M:C,M:GO,M:LL,M:LO,M:OC,M:OV,M:X1            
         REF      M:X2,M:X3,M:X4,M:X5,M:X6,MOVBYTS,MOVEDW,NBA:SECT              
         REF      NUM1,NUM2,NXTSEG,OLOADPCB,P:GRAN,P:POOL,PATHEND               
         REF      PT:CC6,PT:CC7,PT:DIAG1,PT:LB12,PT:RD1,PT:SCAN,PT:WTGR         
         REF      RABORT,RAREABC,RAX,RDIAG,RDIAGX,READXN,ROMBYTE                
         REF      ROMBYTES,ROMERR,SATREF,SCANEXIT,SCANFLAG,SCANITEM             
         REF      SCAN80,SCAN82,SCAN83,SCAN84,SCAN85,SCAN88,SCAN89              
         REF      SCAN89A,SCAN90,SCAN91,SCAN92,SCAN93,SCAN94,SCAN95             
         REF      SCAN96,SCAN98,SCAN99,SERCHDCB,SERCHFWD,SERCHPUB               
         REF      SERCHSEG,SERCHSYM,SERCHVAL,SKIPX,SOLVEX,STORCBV               
         REF      SYMFBA,T:BDP,T:BZA,T:FBA,T:LBA,T:LDADDR                       
         REF      T:LDINST,T:NBE,T:PL,TBENTRY,V:CCDCB,V:CCTYPE                  
         REF      V:COLAY,V:DECLNO,V:LIBSIZ,V:LINKID,V:MASK,V:MODLOC            
         REF      V:ROMRNO,V:SEGID,V:TOTSIZ,VMODMTB,WDP:ASSN,WORD               
         REF      WRITEXN,XBC,ZERONXT,ZEROX,4BYTES                              
         REF      X:3FFF,X:FFFF,Y:FFFE                                          
         TITLE    '       **** EQUATES ****'                                    
         ASECT                                                                  
R0       EQU      %                                                             
R1       EQU      %+1                                                           
R2       EQU      %+2                                                           
R3       EQU      %+3                                                           
R4       EQU      %+4                                                           
R5       EQU      %+5                                                           
R6       EQU      %+6                                                           
R7       EQU      %+7                                                           
R8       EQU      %+8                                                           
R9       EQU      %+9                                                           
R10      EQU      %+10                                                          
R11      EQU      %+11                                                          
R12      EQU      %+12                                                          
R13      EQU      %+13                                                          
R14      EQU      %+14                                                          
R15      EQU      %+15                                                          
         CSECT                                                                  
*                       *FPT CONSTANTS                                          
TYPE     EQU      X'02'                                                         
READ     EQU      X'10'                                                         
WRITE    EQU      X'11'                                                         
*                        *CONTROL BYTE MASKS AND VALUES                         
TY       EQU      X'C0'             SYMBOL TYPE (DEF,DSECT,PREF,SREF)           
DEF      EQU      0                     EXTERNAL DEFINITION                     
DSECT    EQU      X'40'                 DUMMY SECTION                           
SREF     EQU      X'80'                 SECONDARY REFERENCE                     
PREF     EQU      X'C0'                 PRIMARY REFERENCE                       
D        EQU      X'20'            *SYMBOL HAS/HASNOT BEEN DEFINED,             
*                                   ALLOCATED, OR SATISFIED FLAG MASK           
DEFINED  EQU      X'20'                 DEFINED DEF                             
UNDEFINE EQU      0                     DEF UNDEFINED                           
SATISFYD EQU      X'20'                 SATISFIED REF                           
UNSAT    EQU      0                     REF UNSATISFIED                         
ALLOCATD EQU      X'20'                 ALLOCATED DSECT                         
UNALLOCT EQU      0                     DSECT NOT ALLOCATED                     
V        EQU      X'10'            *SYMBOL HAS BEEN DEFINED/ALLOCATED/          
*                                   SATISFIED WITH EITHER A VALUE               
*                                   OR AN EXPRESSION FLAG MASK                  
VALUE    EQU      X'10'                 VALUE                                   
EXP      EQU      0                     EXPRESSION                              
C        EQU      X'08'            *SYMBOL VALUE IS EITHER A CONSTANT OR        
*                                   AN ADDRESS FLAG MASK                        
CONSTANT EQU      X'08'                *SYMBOL VALUE IS A CONSTANT              
*                                       WITH NO RESOLUTION                      
ADDRESS  EQU      0                    *SYMBOL VALUE IS AN ADDRESS              
*                                       WITH BYTE RESOLUTION                    
F        EQU      X'04'            *SYMBOL IS/ISNOT A DUPLICATE FLAG            
*                                   MASK                                        
DUPLICAT EQU      X'04'                 DUPLICATE SYMBOL                        
NOTDUP   EQU      0                     NOT DUPLICATE SYMBOL                    
*                                                                               
LB       EQU      X'03'             SYMBOL FROM ROM OR LIBRARY                  
ROM      EQU      0                     SYMBOL FROM ROM                         
USER     EQU      X'02'                 SYMBOL FROM USER LIBRARY                
SYSTEM   EQU      X'01'                 SYMBOL FROM SYSTEM LIBRARY              
PUBLIC   EQU      X'03'                 PUBLIC LIBRARY SYMBOL                   
*                                                                               
RES      EQU      DSECT+ALLOCATD+; *RES SYMBOL CONTROL BYTE                     
                  EXP+NOTDUP+ROM    (TO BE ALLOCATED AT SEGMENT END)            
EXCLPREF EQU      PREF+UNSAT+VALUE; EXCLUDED PREF SYMBOL CONTROL BYTE           
                  +NOTDUP+ROM                                                   
*                        *T:LDEF AND DEFREF ENTRY TYPES                         
#DEF     EQU      X'4000'           EXTERNAL DEF                                
#PREF    EQU      X'8000'           EXTERNAL PREF                               
#EXCL    EQU      X'4000'           EXCLUDED EXTERNAL REF                       
#DSECT   EQU      X'C000'           DUMMY SECTION                               
*                        *MONITOR CELLS                                         
PCBPOINT EQU      X'4E'             FWA OF BACKGROUND PROGRAM'S PCB             
K:BACKBG EQU      X'140'            FWA OF BACKGROUND                           
K:BCKEND EQU      X'141'            LWA OF BACKGROUND                           
K:FGDEND EQU      X'143'            LWA OF FOREGROUND                           
K:CCBUF  EQU      X'144'            FWA OF CONTROL COMMAND BUFFER               
K:FGDBG2 EQU      X'146'            DEFAULT FWA OF FOREGROUND                   
K:FMBOX  EQU      X'147'            MONITOR FOREGROUND PRGMS MAILBOX            
K:BPEND  EQU      X'153'            LWA+1 OF LOADED BACKGROUND PROGRAM          
K:DCT1   EQU      X'176'            POINTER TO HW WITH # OF DCT ENTRIES         
K:DCT16  EQU      X'177'            POINTER TO DW WITH DEVICE EBCDIC            
K:OPLBS3 EQU      X'179'            POINTER TO OPLB'S CURRENT ASSIGNMENT        
K:RFT4   EQU      X'17A'            RAD FILE TABLE GRANULE SIZE POINTER         
K:RFT5   EQU      X'17B'            RAD FILE TABLE RECORD SIZE POINTER          
*                        *OVERLAY LOADER SEGMENT IDENTS                         
SEG:CCI  EQU      1                 CONTROL COMMAND INTERPRETER                 
SEG:PAS1 EQU      2                 PASS ONE                                    
SEG:PAS2 EQU      3                 PASS TWO                                    
SEG:MAP  EQU      4                 MAP                                         
SEG:DIAG EQU      5                 DIAGNOSTICS                                 
SEG:LIB  EQU      6                 LIBRARY SEARCH                              
*                        *ALARMS                                                
PROGERR  EQU      42          PROGRAM ERROR,OLAY,ADDR XXXXX                     
BACKSIZE EQU      54          BACKGROUND TOO SMALL                              
MAXLROM  EQU      75                LIB ROM'S EXCEED MAX                        
         TITLE    ' **** DYNAMIC TABLE AREA POINTERS ****'                      
*                                                                               
*                       *THE FOLLOWING TABLES AREAS ARE DYNAMICALLY             
*                        ALLOCATED (DURING PASSONE) AND ARE LOCATED             
*                        BETWEEN THE END OF THE LOGEST OVERLAY                  
*                        (K:PEND) AND THE END OF BACKGROUND (K:BACKEND).        
*                       *THE EQUATED VALUES ARE INDICES INTO T:FBA,             
*                        T:LBA,T:NBE,AND T:BZA.                                 
*                                                                               
T:PUBVAL EQU      1      PUBLIC LIBRARY DEF VALUE TABLE                         
*                            *5 BYTES PER ENTRY                                 
*                            *ENTRIES PARALLEL TO T:PUBSYM ENTRIES              
*                                                                               
*                                                                               
T:PUBSYM EQU      2      PUBLIC LIBRARY DEF EBCDIC NAME TABLE                   
*                            *VARIABLE SIZED ENTRIES                            
*                            *ENTRIES PARALLEL TO T:PUBVAL ENTRIES              
*                                                                               
*                                                                               
*                                                                               
T:VALUE  EQU      3     *PROGRAM SYMBOL TABLE VALUES (ADDR,CONSTANT,OR E        
*                        (SYMBOL TABLE HAS DEFS,DSECTS,AND FORWARD REFS)        
*                            *5 BYTES PER ENTRY                                 
*                            *ENTRIES PARALLEL TO T:SYMBOL                      
*                                                                               
*                                                                               
T:SEG    EQU      4      SEGMENT INFORMATION TABLE                              
*                            *9 WORDS PER ENTRY                                 
*                            *ONE ENTRY PER SEGMENT                             
*                                                                               
T:DCBV   EQU      5      TABLE OF VARIABLE DCB'S                                
*                            *7 WORDS PER ENTRY                                 
*                            *ONE DCB FOR EACH DISTINCT RAD FILE                
*                             SPECIFIED FOR ROM INPUT                           
*                                                                               
T:DCB    EQU      6     *TABLE OF SYSTEM (M:) AND USER (F:) DCB                 
*                        DEF'S AND  REF'S                                       
*                            *3 WORDS PER ENTRY                                 
*                                                                               
T:ROMI   EQU      7     *ROM INPUT INFORMATION TABLE;CONTAINS THE               
*                        NUMBER OF ROM'S TO INPUT AND THE INPUT SOURCE.         
*                        (TABLE ONLY EXIST DURING PASSONE)                      
*                            *1 WORD PER ENTRY                                  
*                                                                               
T:MODIFY EQU      8     *TABLE OF CORE IMAGE MODIFICATIONS FOR THE              
*                        SEGMENT                                                
*                            *VARIABLE SIZED ENTRIES                            
*                                                                               
T:MODULE EQU      9      MODULE INFORMATION TABLE                               
*                            *5 WORDS PER ENTRY                                 
*                            *ONE ENTRY PER MODULE                              
*                                                                               
B:MT     EQU      10    *MODULE TABLES BUFFER FOR T:DECL,T:CSECT,T:FWD          
*                        AND T:FWDX; BUFFER OUTPUT EITHER AT THE END            
*                        OF THE SEGMENT OR WHEN THE BUFFER IS FULL.             
*                                                                               
T:DECL   EQU      11    *MODULE DECLARATION TABLE; EACH DECLARATION             
*                        ENTRY POINTS TO AN ENTRY IN (1) T:DCB,                 
*                        (2) T:SYMBOL/T:VALUE,(3) T:CSECT, OR                   
*                        (4) T:PUBSYM/T:PUBVAL                                  
*                            *2 BYTES PER ENTRY                                 
*                                                                               
T:CSECT  EQU      12    *CONTROL SECTION TABLE; EACH ENTRY CONTAINS             
*                        SIZE AND ALLOCATED ADDRESS.                            
*                            *2 WORDS PER ENTRY                                 
*                                                                               
T:FWD    EQU      13    *FORWARD TABLE; EACH ENTRY CONTAINS A FORWARD           
*                        NUMBER AND IT'S CORRESPONDING VALUE. A VALUE           
*                        CAN BE AN ADDR, CONSTANT, OR AN EXPRESSION.            
*                            *2 WORDS PER ENTRY                                 
T:FWDX   EQU      14     FORWARD EXPRESSION TABLE                               
*                            *VARIABLE SIZED ENTRIES                            
*                                                                               
T:SYMBOL EQU      15    *PROGRAM SYMBOL TABLE EBCDIC NAMES AND DSECT            
*                        SIZES; ENTRIES PARALLEL TO T:VALUE ENTRIES             
*                            *VARIABLE SIZED ENTRIES                            
*                                                                               
T:VALX   EQU      16    *T:VALUE EXPRESSION TABLE; BACKWARD TABLE               
*                        WITH FORWARD ENTRIES,BUILT FROM K:BACKEND              
*                            *VARIABLE SIZED ENTRIES                            
*                                                                               
*                                                                               
NBE:ROMI EQU      T:NBE+T:ROMI                                                  
NBE:SEG  EQU      T:NBE+T:SEG                                                   
NBE:VALU EQU      T:NBE+T:VALUE                                                 
BDP:SEG  EQU      T:BDP+T:SEG                                                   
BDP:VALU EQU      T:BDP+T:VALUE                                                 
BDP:SYM  EQU      T:BDP+T:SYMBOL                                                
BDP:PUBS EQU      T:BDP+T:PUBSYM                                                
BAP:VALX EQU      T:BDP+T:VALX                                                  
FBA:SYM  EQU      T:FBA+T:SYMBOL                                                
FBA:SEG  EQU      T:FBA+T:SEG                                                   
FBA:ROMI EQU      T:FBA+T:ROMI                                                  
FBA:VALU EQU      T:FBA+T:VALUE                                                 
LBA:ROMI EQU      T:LBA+T:ROMI                                                  
LBA:VALX EQU      T:LBA+T:VALX                                                  
         TITLE    '  **** SUBROUTINE CALLS ****'                                
*                                                                               
BAL      EQU      X'6A'             BAL OPERATION CODE                          
*                                                                               
ADDLDEF  COM,8,4,3,17    BAL,13,0,ADDLDEF                                       
ADDNXT   COM,8,4,3,17    BAL,14,0,ADDNXT                                        
BOUNDRDW COM,8,4,3,17    BAL,15,0,BOUNDRDW                                      
COMPBS   COM,8,4,3,17    BAL,15,0,COMPBS                                        
EXTEND   COM,8,4,3,17    BAL,15,0,EXTEND                                        
LOADSEG  COM,8,4,3,17    BAL,15,0,LOADSEG                                       
MOVBYTS  COM,8,4,3,17    BAL,15,0,MOVBYTS                                       
MOVEDW   COM,8,4,3,17    BAL,14,0,MOVEDW                                        
OVERLAP  COM,8,4,3,17    BAL,13,0,OVERLAP                                       
RDIAG    COM,8,4,3,17    BAL,15,0,RDIAG                                         
RDPACK   COM,8,4,3,17    BAL,15,0,RDPACK                                        
SRCHLDEF COM,8,4,3,17    BAL,15,0,SRCHLDEF                                      
SERCHVAL COM,8,4,3,17    BAL,15,0,SERCHVAL                                      
SYMFBA   COM,8,4,3,17    BAL,15,0,SYMFBA                                        
WRPACK   COM,8,4,3,17    BAL,15,0,WRPACK                                        
         TITLE     '      **** PROCEDURES ****'                                 
*                                                                               
*        ****************************                                           
*        *                          *                                           
*        *                          *                                           
*        *  PUSH,PULL PROCEDURES    *                                           
*        *                          *                                           
*        *                          *                                           
*        ****************************                                           
*                                                                               
*                 FORMAT            PUSH    R1(,R2)                             
*                                   PULL    R1(,R2)                             
*                 USES TEMP STACK DEFINED IN WDS 0-1 OF PCB.                    
PUSH     CNAME    1                                                             
PULL     CNAME    0                                                             
         PROC                                                                   
         DO       (AF(2)=0)|(AF(2)=AF(1))                                       
LF       GEN,8,4,3,17  X'88'+NAME,AF(1),0,PCBPOINT  SINGLE REG IN AF(1)         
         ELSE                                                                   
         DO       AF(2)>AF(1)       E.G.  PUSH   9,11                           
LF       LCFI     (AF(2)-AF(1)+1)&X'F'                                          
         ELSE                       E.G.  PUSH   11,7 (1E 11-16,0-7)            
LF       LCFI     (16-AF(1)+AF(2)+1)&X'F'                                       
         FIN                                                                    
         GEN,8,4,3,17  X'8A'+NAME,AF(1),0,PCBPOINT                              
         FIN                                                                    
         PEND                                                                   
         TITLE    '    **** OVERLAY POOL CELLS ****'                            
*                                                                               
*                                                                               
*                                                                               
T:PFBA   EQU      P:POOL-1         *FIRST BYTE ADDRESS POINTERS FOR THE         
*                                   DYNAMIC TABLES WHEN PACKED TOGETHER         
PFBA:PBV EQU      T:PFBA+T:PUBVAL                                               
PFBA:PBS EQU      T:PFBA+T:PUBSYM                                               
PFBA:VAL EQU      T:PFBA+T:VALUE                                                
PFBA:SEG EQU      T:PFBA+T:SEG                                                  
PFBA:DV  EQU      T:PFBA+T:DCBV                                                 
PFBA:DCB EQU      T:PFBA+T:DCB                                                  
PFBA:ROM EQU      T:PFBA+T:ROMI                                                 
PFBA:MDF EQU      T:PFBA+T:MODIFY                                               
PFBA:MDL EQU      T:PFBA+T:MODULE                                               
PFBA:MTB EQU      T:PFBA+B:MT                                                   
PFBA:DEC EQU      T:PFBA+T:DECL                                                 
PFBA:CST EQU      T:PFBA+T:CSECT                                                
PFBA:FWD EQU      T:PFBA+T:FWD                                                  
PFBA:FX  EQU      T:PFBA+T:FWDX                                                 
PFBA:SYM EQU      T:PFBA+T:SYMBOL                                               
PFBA:VLX EQU      T:PFBA+T:VALX                                                 
*                                                                               
LBA:PACK EQU      P:POOL+16         LBA+1 OF PACKED DYNAMIC TABLES              
*                                   (ON A DW BOUNDARY)                          
*                                                                               
FWA:LDEF EQU      P:POOL+17         FWA POINTER FOR T:LDEF (ON DW BOUND)        
*                                                                               
FWA:BUF  EQU      P:POOL+18         FWA POINTER FOR EBCDIC,DEFREF,AND           
*                                   MODIR FILES BUFFER; ALSO, LWA+1 OF          
*                                   T:LROM  (ON A DW BOUNDARY)                  
*                                                                               
LWA:BACK EQU      P:POOL+19         LWA+1 OF BACKGROUND                         
*                                                                               
LHA:BACK EQU      P:POOL+20         LHA+1 OF BACKGROUND                         
*                                                                               
FL:WRPCK EQU      P:POOL+21         1=PACKED TABLES STORED ON X6                
*                                   0=PACKED TABLES IN CORE                     
*                                                                               
FL:ADREF EQU      P:POOL+22         1=PREF'S FROM DEFREF TABLE ADDED TO         
*                                     T:LDEF                                    
*                                   0=PREF'S NOT ADDED TO T:LDEF FROM           
*                                     DEFREF TABLE                              
         TITLE    '       **** CELLS ****'                                      
*                                                                               
OLAYLIB  EQU      %                                                             
*                                                                               
X:C000   DATA     X'C000'                                                       
X:TYDVCF DATA     TY+D+V+C+F                                                    
         TITLE    '       **** LIB ****'                                        
LIB      EQU      %                                                             
         LW,R7    BDP:SEG                                                       
         AW,R7    FBA:SEG                                                       
         SLS,R7   -1                                                            
         LH,R3    3,R7              R3=BDP OF THIS SEG'S T:VALUE TABLE          
         LW,R4    BDP:VALU          R4=BYTE LENGTH OF SEG'S T:VALUE TABL        
         SW,R4    R3                                                            
         BEZ      LB440            *SEG DOESN'T HAVE ANY EXTERNAL DEF'S         
*                                   OR REF'S,EXIT                               
         LW,R0    NBE:SEG          *CHANGE T:SEG BYTE DISPLACEMENT              
         AWM,R0   BDP:SEG           POINTER TO POINT TO END OF THIS             
*                                   SEG'S ENTRY                                 
         LI,R0    TEMPBUF+1                                                     
         STW,R0   FWA:BUF                                                       
         LW,R8    FBA:TABS         *PACK THE DYNAMIC TABLES TOGETHER            
         LI,R1    T:PUBVAL          (ON DW BOUNDARIES) AT THE TOP OF            
LB10     LW,R5    T:FBA,R1          THE DYNAMIC TABLE'S AREA                    
         LW,R6    R8                                                            
         STW,R6   T:PFBA,R1                                                     
         LW,R8    T:BDP,R1                                                      
         BEZ      LB12                                                          
         MOVEDW                                                                 
         LW,R8    T:BDP,R1                                                      
LB12     AW,R8    R6                                                            
         BOUNDRDW                                                               
         AI,R1    1                                                             
         CI,R1    T:VALX                                                        
         BL       LB10                                                          
         LW,R5    BAP:VALX                                                      
         LW,R6    R8                                                            
         STW,R6   PFBA:VLX                                                      
         LW,R8    LBA:VALX                                                      
         SW,R8    BAP:VALX                                                      
         BEZ      LB14                                                          
         MOVBYTS                                                                
         LW,R8    LBA:VALX                                                      
         SW,R8    BAP:VALX                                                      
LB14     AW,R8    R6                                                            
         BOUNDRDW                                                               
         STW,R8   LBA:PACK         *DID PACKING THE TABLES REGAIN ANY           
         CW,R8    LBA:VALX          CORE SPACE                                  
         BE       LBMSG1                NO,BACKGROUND TOO SMALL                 
         BG       LBMSG2                ERROR,PACK LARGER THAN AREA             
         SLS,R8   -2                                                            
         STW,R8   FWA:LDEF          START T:LDEF AT LWA+1 OF 'PACK'             
         LW,R8    LBA:VALX                                                      
         SLS,R8   -1                CALCULATE:                                  
         STW,R8   LHA:BACK             LHA+1 OF BACKGROUND                      
         SLS,R8   -1                                                            
         STW,R8   LWA:BACK              LWA+1 OF BACKGROUND                     
         LI,R2    0                 SET FLAG STATUS TO 'PACK IN CORE'           
         STW,R2   FL:WRPCK                                                      
         STH,R2   *FWA:LDEF         SET T:LDEF 'ENTRY COUNT' TO ZERO            
         AW,R3    PFBA:VAL          CALCULATE FBA OF SEG'S T:VALUE TABLE        
         AW,R4    R3                          LBA+1                             
LB30     LB,R0    0,R3             *SEARCH THIS SEG'S T:VALUE TABLE FOR         
         AND,R0   X:TYDVCF          UNSATISFIED PREF'S AND EXCLUDED             
         CI,R0    PREF+UNSAT+NOTDUP PREF'S.  SAVE TYPE AND T:VALUE              
         BE       LB50              ENTRY NUMBER IN T:LDEF                      
         CI,R0    EXCLPREF                                                      
         BE       LB60                                                          
LB40     AW,R3    NBE:VALU                                                      
         CW,R3    R4                END OF T:VALUE                              
         BL       LB30                  NO,CONTINUE SEARCH                      
         BE       LB100                 YES                                     
         BG       LBMSG2                PAST END,PROGRAM ERROR                  
LB50     LI,R9    #PREF                                                         
         B        LB65                                                          
LB60     LI,R9    #EXCL                                                         
LB65     LW,R7    R3                    CALCULATE T:VALUE ENTRY NO.             
         SW,R7    PFBA:VAL                                                      
         DW,R7    NBE:VALU                                                      
         AI,R7    1                                                             
         OR,R9    R7                                                            
         ADDLDEF                    ADD ENTRY TO T:LDEF                         
         B        LB40                                                          
LB100    CI,R2    0                 ARE THERE ANY ENTRIES IN T:LDEF             
         BE       LB355                 NO,EXIT                                 
         STH,R2   *FWA:LDEF             YES,SAVE ENTRY COUNT                    
         LW,R3    PFBA:VAL         *SEARCH THE PATH'S T:VALUE TABLE FOR         
         XW,R3    FBA:VALU          DEF'S FROM THIS LIBRARY AND ADD TO          
         LI,R6    0                 T:LDEF                                      
LB104    LI,R10   DEF+NOTDUP            (R3=FBA OF T:VALUE AREA)                
         AW,R10   FL:LBLD                                                       
         LI,R11   TY+F+LB                                                       
         SERCHVAL                                                               
         CI,R6    0                     END OF SEARCH                           
         BE       LB106                     YES                                 
         AI,R9    #DEF                      NO,ADD 'DEF' ENTRY TO T:LDEF        
         ADDLDEF                                                                
         LI,R6    1                                                             
         B        LB104                                                         
LB106    STW,R3   FBA:VALU              (RESTORE T:VALUE AREA POINTER)          
         STH,R2   *FWA:LDEF                                                     
         PAGE                                                                   
         LI,R9    0                                                             
         LI,R5    7                                                             
         CAL1,1   FPT:LB1          *OPEN F:DEFREF TO GET BYTE COUNT             
         LB,R7    F:DEFREF,R5       OF DEFREF FILE                              
         LH,R8    *K:RFT5,R7                                                    
         AND,R8   X:FFFF                                                        
         BNEZ     LB108                                                         
         CAL1,1   FPT:LB2           CLOSE FILE                                  
         B        LB355                                                         
LB108    STW,R8   FPT:LB8+5                                                     
         CAL1,1   FPT:LB2          *CLOSE F:DEFREF                              
         CAL1,1   FPT:LB3          *OPEN F:MODIR TO GET BYTE COUNT              
         LB,R7    F:MODIR,R5        OF MODIR FILE                               
         LH,R10   *K:RFT5,R7                                                    
         AND,R10  X:FFFF                                                        
         BEZ      LB355                                                         
         STW,R10  FPT:LB9+5                                                     
         CW,R8    R10                                                           
         BGE      LB110                                                         
         LW,R8    R10                                                           
LB110    CAL1,1   FPT:LB4          *CLOSE F:MODIR                               
         CAL1,1   FPT:LB5          *OPEN F:EBCDIC TO GET BYTE COUNT             
         LB,R7    F:EBCDIC,R5       OF EBCDIC FILE                              
         LH,R10   *K:RFT5,R7                                                    
         AND,R10  X:FFFF                                                        
         BEZ      LB355                                                         
         STW,R10  FPT:LB7+5                                                     
         CW,R8    R10                                                           
         BGE      LB120                                                         
         LW,R8    R10                                                           
LB120    BOUNDRDW                   R8=BYTE COUNT OF LARGEST LIB FILE           
         SLS,R8   -2                                                            
         LW,R9    LWA:BACK         *CALCULATE FWA OF EBCDIC,DEFREF, AND         
         SW,R9    R8                MODIR FILES' BUFFER                         
         STW,R9   FWA:BUF                                                       
         LH,R7    *FWA:LDEF         CALCULATE LWA+1 OF T:LDEF                   
         AI,R7    2                                                             
         SLS,R7   -1                                                            
         AW,R7    FWA:LDEF                                                      
         CW,R7    R9                WILL LIB FILES BUFFER OVERLAP T:LDEF        
         BLE      LB150                 NO                                      
         LW,R0    FL:WRPCK              YES,IS THE PACK IN CORE                 
         BNEZ     LBMSG1                       *NO,BACKGROUND TOO SMALL         
         WRPACK                                *YES,WRITE ON X6 AND             
         LW,R5    FWA:LDEF                          MOVE T:LDEF TO TOP          
         SLS,R5   2                                 OF PACKED T:VALUE           
         LW,R6    PFBA:VAL                          TABLE                       
         LH,R8    *FWA:LDEF                                                     
         AI,R8    1                                                             
         SLS,R8   1                                                             
         MOVEDW                                                                 
         SLS,R6   -2                                                            
         STW,R6   FWA:LDEF                                                      
LB150    LW,R8    PFBA:SYM         *WILL THE LIB FILES BUFFER OVERLAP           
         AW,R8    BDP:SYM           T:SYMBOL                                    
         BOUNDRDW                                                               
         SLS,R8   -2                                                            
         CW,R8    FWA:BUF                                                       
         BLE      LB160                *NO                                      
*                                      *YES,MOVE T:SYMBOL TO LWA+1              
*                                           OF T:LDEF                           
         LW,R0    FL:WRPCK                                                      
         BEZ      LBMSG2                   (ERROR,PACK SHOULD BE ON X6)         
         LH,R8    *FWA:LDEF                                                     
         AI,R8    1                                                             
         SLS,R8   1                                                             
         LW,R9    FWA:LDEF                                                      
         SLS,R9   2                                                             
         AW,R8    R9                                                            
         BOUNDRDW                                                               
         LW,R6    R8                                                            
         LW,R5    PFBA:SYM                                                      
         LW,R8    BDP:SYM                                                       
         MOVEDW                                                                 
         LW,R3    R6                        R3=FBA OF T:SYMBOL                  
         AW,R6    BDP:SYM                                                       
         LW,R8    R6                                                            
         BOUNDRDW                                                               
         SLS,R8   -2                                                            
         CW,R8    FWA:BUF                  *DOES THE LIB FILES BUFFER           
*                                           STILL OVERLAP T:SYMBOL              
         BG       LBMSG1                        YES,BACKGROUND TOO SMALL        
         BLE      LB170                         NO                              
LB160    LW,R3    PFBA:SYM                                                      
LB170    LI,R9    0                                                             
         CAL1,1   FPT:LB7          *READ EBCDIC FILE INTO LIB FILES'            
         CAL1,1   FPT:LB6           BUFFER AND CLOSE F:EBCDIC                   
         XW,R3    FBA:SYM           (STORE CURRENT ADDR OF T:SYMBOL)            
*                                       R3=FBA OF T:SYMBOL AREA                 
         LH,R4    *FWA:LDEF             R4=T:LDEF ENTRY INDEX                   
LB180    LH,R9    *FWA:LDEF,R4      GET FIRST/NEXT T:LDEF ENTRY                 
         AND,R9   X:3FFF                                                        
         SYMFBA                    *GET FBA OF T:SYMBOL ENTRY THAT              
*                                   CORRESPONDS TO THE T:VALUE ENTRY            
*                                   POINTED TO BY THE T:LDEF ENTRY              
         LW,R1    R5                    R1=FBA OF T:SYMBOL ENTRY                
         LI,R2    0                     R2=EBCDIC BYTE INDEX                    
LB190    LB,R10   *FWA:BUF,R2      *SEARCH EBCDIC TABLE TO LOCATE               
         CB,R10   0,R1              ENTRY THAT MATCHES THE T:SYMBOL             
         BNE      LB195             ENTRY                                       
         ANLZ,R6  LB190                 R6=FBA OF CURRENT EBCDIC ENTRY          
         LW,R5    R1                                                            
         COMPBS                                                                 
         BE       LB200                                                         
LB195    AW,R2    R10                                                           
         CW,R2    FPT:LB7+5         END OF EBCDIC TABLE                         
         BL       LB190                 NO                                      
         LI,R9    0                     YES,MATCHING ENTRY NOT FOUND            
         B        LB210                     CHANGE T:LDEF ENTRY TO NULL         
LB200    LH,R9    *FWA:LDEF,R4             *MATCHING EBCDIC TABLE ENTRY         
         AND,R9   X:C000                    LOCATED,CHANGE T:LDEF ENTRY         
         OR,R9    R2                        TO POINT TO EBCDIC ENTRY            
LB210    STH,R9   *FWA:LDEF,R4                                                  
         BDR,R4   LB180                                                         
         STW,R3   FBA:SYM           RESTORE T:SYMBOL AREA POINTER               
         PAGE                                                                   
         LH,R2    *FWA:LDEF         PACK T:LDEF TO ELIMINATE NULL ENTRYS        
         LI,R1    0                                                             
LB230    LH,R8    *FWA:LDEF,R2                                                  
         BNEZ     LB240                                                         
LB235    BDR,R2   LB230                                                         
         B        LB355                 EXIT,T:LDEF HAS ZERO ENTRIES            
LB240    AI,R1    1                                                             
         CW,R1    R2                                                            
         BGE      LB250                                                         
         LH,R9    *FWA:LDEF,R1                                                  
         BNEZ     LB240                                                         
         STH,R8   *FWA:LDEF,R1                                                  
         B        LB235                                                         
LB250    STH,R2   *FWA:LDEF                                                     
         LW,R3    BDP:PUBS         *DOES THE PROGRAM TO BE LOADED               
*                                   REFERENCE A PUBLIC LIBRARY                  
         BEZ      LB259                *NO                                      
*                                      *YES,ADD THE PUBLIC LIBRARY              
*                                           DEF'S TO T:LDEF                     
         AW,R3    PFBA:PBS              R3=LBA+1 OF T:PUBSYM                    
         LW,R1    PFBA:PBS              R1=BA POINTER TO T:PUBSYM ENTRY         
         LH,R4    *FWA:LDEF             R'=T:LDEF INDEX (OF LAST ENTRY)         
         LW,R7    FWA:BUF               R7=FHA OF EBCDIC TABLE                  
         SLS,R7   1                                                             
LB251    EQU      %                *SEARCH EBCDIC TABLE FOR AN ENTRY            
*                                   THAT MATCHES THE T:PUBSYM ENTRY             
         LI,R2    0                     R2=EBCDIC TABLE BYTE INDEX              
LB252    LB,R10   *FWA:BUF,R2      *DO THE EBCDIC ENTRIES HAVE EQUAL            
         CB,R10   0,R1              BYTE COUNTS                                 
         BE       LB254                                                         
LB253    AW,R2    R10                   NO,END OF EBCDIC TABLE                  
         CW,R2    FPT:LB7+5                                                     
         BL       LB252                       *NO,TRY NEXT ENTRY                
         B        LB256                       *YES,MATCH NOT FOUND              
LB254    ANLZ,R6  LB252                 YES,ARE THE EBCDIC ENTRIES              
         LW,R5    R1                        EQUAL                               
         COMPBS                                                                 
         BNE      LB253                         NO                              
         LI,R9    #DEF                          YES,ADD PBULIB DEF TO           
         OR,R9    R2                                T:LDEF SO THAT THE          
         AI,R4    1                                 DUPLICATE LIBRARY           
         ANLZ,R0  LB255                             ROUTINE WILL NOT            
         CW,R0    R7                                GET LOADED                  
         BGE      LB258            *IF THIS ENTRY IS ADDED, T:LDEF WILL         
*                                   OVERLAY THE EBCDIC TABLE                    
LB255    STH,R9   *FWA:LDEF,R4                                                  
LB256    LB,R10   0,R1              CALCULATE BA OF NEXT T:PUBSYM ENTRY         
         AW,R1    R10                                                           
         CW,R1    R3                    END OF T:PUBSYM                         
         BL       LB251                    *NO,CONTINEU                         
         BG       LBMSG2                   *PAST END,PROGRAM ERROR              
         STH,R4   *FWA:LDEF                *YES,ADJUST T:LDEF ENTRY             
         B        LB259                         COUNT                           
LB258    LW,R0    FL:WRPCK          HAS THE PACK BEEN OUTPUT ON X6              
         BNEZ     LBMSG1                YES,BACKGROUND TOO SMALL TO             
*                                           CONTINUE                            
         WRPACK                         NO,WRITE THE PACKED TABLES ON           
         LW,R5    LBA:PACK                 X6 AND MOVE T:LDEF TO THE            
         LW,R6    PFBA:VAL                 END OF T:PUBSYM                      
         LW,R8    R4                       (NO.OF HALFWORDS IN T:LDEF)          
         SLS,R8   1                                                             
         MOVEDW                                                                 
         SLS,R6   -2                                                            
         STW,R6   FWA:LDEF                                                      
         B        LB255                                                         
         PAGE                                                                   
LB259    LI,R9    0                                                             
         CAL1,1   FPT:LB8          *READ DEFREF FILE INTO LIB FILES             
         CAL1,1   FPT:LB2           BUFFER AND CLOSE F:DEFREF                   
         LW,R6    FPT:LB8+5                                                     
         SLS,R6   -1                    R6=HW LENGTH OF DEFREF TABLE            
         LI,R1    0                     R1=T:LROM ENTRY INDEX(BACKWARD)         
         LI,R9    X'3FFF'               R9=X'3FFF'                              
LB260    LH,R5    *FWA:LDEF         SEARCH T:LDEF FOR A PREF                    
LB261    LH,R0    *FWA:LDEF,R5                                                  
         AND,R0   X:C000                                                        
         CI,R0    #PREF                                                         
         BE       LB262                                                         
         BDR,R5   LB261                                                         
         B        LB352                 NONE,END OF DEFREF SEARCH               
LB262    EQU      %                *SEARCH DEFREF TABLE FOR ENTRY'S             
*                                   WITH DEF'S THAT WILL SATISFY PREF'S         
*                                   IN T:LDEF                                   
         LI,R2    0                    *R2=DEFREF ENTRY INDEX                   
         STW,R2   FL:ADREF                                                      
LB265    LW,R3    R2                   *R3=HALFWORD INDEX INTO DEFREF           
         LH,R12   *FWA:BUF,R2              ENTRY                                
         AW,R12   R2                    R12=INDEX OF NEXT DEFREF ENTRY          
         AI,R3    1                                                             
         LH,R11   *FWA:BUF,R3           R11=MODIR FILE INDEX FOR                
*                                           DEFREF ENTRY                        
         CI,R11   -1                                                            
         BE       LB350             (DELETED ENTRY)                             
LB270    AI,R3    1                 GET FIRST/NEXT DEF OR REF IN LIB ROM        
         CW,R3    R12                                                           
         BGE      LB350                                    /SIG7-3224/*C5733    
         LH,R8    *FWA:BUF,R3       R8= LIB ROM DEF,DSECT OR PREF               
*                                                                               
         CI,R8    #DEF                                                          
         BAZ      LB350                  PREF,END OF LIB ROM'S DEF'S            
         SRCHLDEF                  *SEARCH T:LDEF FOR AN ENTRY WITH A           
         CI,R5    0                 MATCHING EBCDIC INDEX                       
         BE       LB270                 NONE                                    
         AND,R10  X:C000                                                        
         AND,R8   X:C000                                                        
         CI,R8    #DEF                                                          
         BE       LB280                 R8=LIBRARY ROM DEF OR EXCL PREF         
*                                  *LIB ROM IS A DSECT                          
         CI,R10   #DEF              IS THE T:LDEF ENTRY A DEF OR EXCL           
         BE       LB350                 YES,DEFREF ENTRY HAS ALREADY            
*                                           BEEN ADDED TO T:LDEF AND            
*                                           T:LROM                              
         CI,R10   #DSECT            IS THE T:LDEF ENTRY A DSECT                 
         BE       LB270                 YES,IGNORE                              
         CI,R10   #PREF             IS THE T:LDEF ENTRY A PREF                  
         BNE      LBMSG2                NO,PROGRAM ERROR                        
         BE       LB290                 YES,ADD DEFREF ENTRY'S DEF'S            
*                                           AND PREF'S TO T:LDEF AND            
*                                           ADD MODIR FILE INDEX TO             
*                                           T:LROM                              
LB280    EQU      %                 *LIB ROM IS A DEF                           
         CI,R10   #DEF              IS THE T:LDEF ENTRY A DEF OR EXCL           
         BE       LB350                 YES,DONT LOAD ROM                       
         CI,R10   #DSECT            IS THE T:LDEF ENTRY A DSECT                 
         BE       LBMSG2                YES,PROGRAM ERROR                       
         CI,R10   #PREF             IS IT A PREF                                
         BNE      LBMSG2                NO,PROGRAM ERROR                        
LB290    EQU      %                                                             
         AI,R1    -1                    (POINT TO NEXT T:LROM ENTRY)            
         LH,R5    *FWA:LDEF                                                     
         OVERLAP                   *CHECK TO SEE THAT T:LROM WILL NOT           
*                                   OVERLAP T:LDEF                              
LB295    STH,R11  *FWA:BUF,R1      *STORE LIBRARY ROM'S MODIR FILE              
*                                   INDEX IN T:LROM                             
         LW,R3    R2               *ADD LIBRARY ROM'S DEF'S AND PREF'S          
         AI,R3    2                 TO T:LDEF; CHANGING ANY PREF'S              
*                                   TO DEF'S AND NOT ADDING PREF'S              
*                                   THAT MATCH EXCLUDES                         
LB300    LH,R8    *FWA:BUF,R3                                                   
         SRCHLDEF                  *SEARCH T:LDEF FOR AN ENTRY WITH AN          
*                                   EBCDIC INDEX THAT MATCHES THE LIB           
*                                   ROM'S EBCDIC INDEX                          
         CI,R5    0                                                             
         BE       LB330                 NONE,ADD LIB DEF/PREF TO T:LDEF         
         AND,R8   X:C000                R8=LIB ROM TYPE(DEF,PREF,DSECT)         
         AND,R10  X:C000                R10=T:LDEF ENTRY TYPE                   
*                                           (DEF,PREF,DSECT OR EXCL)            
         CI,R10   #DEF              IS THE T:LDEF ENTRY A DEF OR EXCL           
         BNE      LB310                *NO                                      
         CI,R8    #PREF                *YES,IS THE LIB ROM EXTERNAL             
*                                           A PREF                              
         BE       LB340                        *YES,IGNORE                      
         CI,R8    #DSECT                IS THE LIB ROM EXTERNAL A DSECT         
         BE       LB340                     YES,IGNORE                          
         BNE      LBMSG2                    NO,PROGRAM ERROR                    
LB310    CI,R10   #PREF             IS THE T:LDEF ENTRY A PREF                  
         BNE      LB320                *NO                                      
         CI,R8    #PREF                *YES,IS THE LIB ROM EXTERNAL             
*                                           ALSO A PREF                         
         BE       LB340                        *YES,NO NEED TO ADD              
         CI,R8    #DSECT                       *NO,IS IT A DSECT                
         BE       LB315                                                         
         CI,R8    #DEF                         *NO,IS IT A DEF                  
         BNE      LBMSG2                              *NO,PROGRAM ERROR         
LB315    EQU      %                                                             
         LH,R10   *FWA:LDEF,R5                        *YES,CHANGE T:LDEF        
         AND,R10  X:3FFF                                   ENTRY TO A           
         OR,R10   R8                                       DEF OR DSECT         
         STH,R10  *FWA:LDEF,R5                                                  
         B        LB340                                                         
LB320    CI,R10   #DSECT            IS THE T:LDEF ENTRY A DSECT                 
         BNE      LBMSG2                NO,PROGRAM ERROR                        
         CI,R8    #PREF                 YES,IS THE LIB ROM EXTERNAL             
*                                           A PREF                              
         BE       LB340                         YES,IGNORE                      
         CI,R8    #DSECT                        NO,IS IT A DSECT                
         BE       LB340                             YES,IGNORE                  
         B        LBMSG2                            NO,PROGRAM ERROR            
LB330    LH,R5    *FWA:LDEF         ADD LIB ROM EXTERNAL TO T:LDEF              
         AI,R5    1                                                             
         OVERLAP                   *CHECK TO SEE THAT T:LDEF WILL NOT           
*                                   OVERLAP T:LROM                              
LB335    STH,R8   *FWA:LDEF,R5                                                  
         STH,R5   *FWA:LDEF                                                     
         AND,R8   X:C000            IS A PREF BEING ADDED TO T:LDEF             
         CI,R8    #PREF                                                         
         BNE      LB340                 NO                                      
         LI,R8    1                     YES,SET REF-ADDED FLAG                  
         STW,R8   FL:ADREF                                                      
LB340    AI,R3    1                 INDEX NEXT EXTERNAL IN DEFREF ENTRY         
         CW,R3    R12                                                           
         BL       LB300                                                         
LB350    LW,R2    R12               GET NEXT DEFREF ENTRY                       
         CW,R2    R6                    END OF DEFREF TABLE                     
         BL       LB265                     *NO                                 
         LW,R0    FL:ADREF          WERE ANY PREF'S ADDED                       
         BNEZ     LB260                 YES                                     
         PAGE                                                                   
LB352    LI,R9    0                *READ MODIR FILE INTO LIB FILES' BUF         
         CAL1,1   FPT:LB9           AND CLOSE F:MODIR                           
         CAL1,1   FPT:LB4                                                       
         LW,R2    R1                DOES T;LROM HAVE ANY ENTRIES                
         BNEZ     LB360                 YES                                     
*                                       NO                                      
LB355    LI,R1    0                *NONE OF THE LIBRARY ROM'S SATISFY           
         B        LB365             THE UNSATISFIED PREF'S (IF ANY);            
*                                   UNPACK DYNAMIC TABLES AND EXIT              
LB360    LH,R4    *FWA:BUF,R2      *CONVERT T:LROM ENTRIES FROM A               
         LH,R8    *FWA:BUF,R4       MODIR FILE INDEX TO A MODULE                
*                                   FILE RECORD NUMBER                          
         STH,R8   *FWA:BUF,R2                                                   
         BIR,R2   LB360                                                         
LB365    LW,R0    FL:WRPCK          WERE THE PACKED TABLES SAVED ON X6          
         BEZ      LB400                 NO                                      
*                                       YES                                     
         LW,R5    FWA:BUF    *DOES LBA+1 OF THE PACK OVERLAP T:LROM             
         SLS,R5   1                                                             
         AW,R5    R1                                                            
         SLS,R5   1                                                             
         CW,R5    LBA:PACK                                                      
         BGE      LB370             NO                                          
         LCW,R8   R1                YES,MOVE T:LROM TO THE BOTTOM OF            
         BEZ      LB370                 BACKGROUND                              
         SLS,R8   1                                                             
         LW,R6    LBA:VALX                                                      
         SW,R6    R8                                                            
         CW,R6    LBA:PACK    *IS THERE ROOM FOR T:LROM AND THE PACK            
         BL       LBMSG1            NO,OUTPUT MSG AND ABORT                     
         MOVBYTS                    YES,MOVE T:LROM AND RESET ADOR              
         LW,R0    LWA:BACK              POINTER                                 
         STW,R0   FWA:BUF                                                       
LB370    RDPACK                     READ PACKED DYNAMIC TABLES FROM X6          
LB400    LCW,R8   R1               *STORE NO. OF T:LROM ENTRIES IN              
         AI,R1    -1                T:LROM AND MOVE TO TEMPORARY BUFFER         
         STH,R8   *FWA:BUF,R1       IN LIB OVERLAY                              
         AI,R8    1                                                             
         SLS,R8   1                                                             
         LI,R6    BA(TEMPBUF)                                                   
         LW,R5    FWA:BUF               CALCULATE FBA OF T:LROM                 
         SLS,R5   1                                                             
         AW,R5    R1                                                            
         SLS,R5   1                                                             
         LW,R10   R6                    WILL T:LROM FIT IN TEMPBUF              
         AW,R10   R8                                                            
         CW,R10   FBA:TABS                                                      
         BG       LBMSG3                    NO, OUTPUT MSG AND ABORT            
         MOVBYTS                            YES,MOVE T:LROM AND DO NOT          
         LI,R6    WA(TEMPBUF)                   ALLOW DIAG TO BE CALLED         
         STW,R6   FWA:BUF                                                       
         LI,R1    T:VALX            UNPACK THE DYNAMIC TABLES                   
         LW,R6    BAP:VALX                                                      
         LW,R8    LBA:VALX                                                      
         SW,R8    BAP:VALX                                                      
         B        LB415                                                         
LB410    LW,R6    T:FBA,R1                                                      
         LW,R8    T:BDP,R1                                                      
LB415    LW,R5    T:PFBA,R1                                                     
         MOVBYTS                                                                
         AI,R1    -1                                                            
         CI,R1    T:VALUE                                                       
         BG       LB410                                                         
         BL       LBMSG2                                                        
         LCW,R0   NBE:SEG          *RESET T:SEG POINTER TO POINT TO             
         AWM,R0   BDP:SEG           FBA OF THIS SEGMENT'S ENTRY                 
         LI,R1    T:ROMI                                                        
         LH,R8    *FWA:BUF            (NO. OF ENTRIES IN T:LROM)                
         BEZ      LB440                 NO ENTRIES IN T:LROM,EXIT               
         SLS,R8   2                   (NO. OF BYTES FOR T:ROMI)                 
         SW,R8    LBA:ROMI                                                      
         AW,R8    FBA:ROMI      WILL THE T:LROM ENTRIES FIT INTO T:ROMI         
         BLEZ     LB420             YES                                         
         LI,R2    0                 NO,EXTEND T:ROMI BY THE NUMBER OF           
         XW,R2    NBE:ROMI             BYTES IN R8                              
         EXTEND                                                                 
         STW,R2   NBE:ROMI                                                      
LB420    LI,R5    BA(R3)           *CONVERT T:LROM ENTRIES INTO T:ROMI          
         LH,R2    *FWA:BUF          FORMAT AND ADD TO T:ROMI                    
LB430    LH,R3    *FWA:BUF,R2                                                   
         BLZ      LBMSG2                                                        
         AI,R3    X'10000'                                                      
         ADDNXT                                                                 
         BDR,R2   LB430                                                         
LB440    LI,R11   SEG:PAS1         *CALL PASSONE TO PROCESS LIBRARY             
         LOADSEG                    ROM'S IN T:ROMI                             
         TITLE    '       **** MESSAGES ****'                                   
LBMSG1   LI,R9    BACKSIZE         *OUTPUT MSG 'BACKGROUND TOO SMALL'           
         RDIAG                      AND ABORT                                   
LBMSG2   LI,R9    PROGERR          *OUTPUT MSG 'PROGRAM ERROR' AND ABORT        
         RDIAG                                                                  
LBMSG3   LI,R9    MAXLROM          *OUTPUT MSG 'LIB ROM'S EXCEED MAX'           
         RDIAG                      AND ABORT                                   
         TITLE    '       **** ADDLDEF ****'                                    
*                                                                               
*        PURPOSE: TO ADD AN ENTRY TO T:LDEF; MOVING T:LDEF TO THE END           
*                 OF T:PUBSYM IN THE PACKED TABLE IF T:LDEF WOULD               
*                 EXTEND PAST THE BACKGROUND AREA.                              
*                                                                               
*        INPUT:   R2=NUMBER OF ENTRIES IN T:LDEF                                
*                 R9=T:LDEF ENTRY (IN BITS 16-31)                               
*                                                                               
*        CALL:    BAL,R13  ADDLDEF                                              
*                                                                               
*        OUTPUT:  R2=R2+1                                                       
*                 R9=UNCHANGED                                                  
*                                                                               
*        CALLS:   WRPACK,MOVEDW                                                 
*                                                                               
*                                                                               
ADDLDEF  AI,R2    1                                                             
AD10     ANLZ,R0  AD20             *WILL T:LDEF EXTEND PAST BACKGROUND          
         CW,R0    LHA:BACK          END (ONLY RELEVENT IF PACK IN CORE)         
         BGE      AD30                                                          
AD20     STH,R9   *FWA:LDEF,R2          NO,ADD ENTRY TO T:LDEF                  
         B        *R13                                                          
AD30     LW,R0    FL:WRPCK              YES,IS THE PACK IN CORE                 
         BNEZ     LBMSG2                       YES,PROGRAM ERROR SINCE          
*                                                  T:LDEF CANNOT BE             
*                                                  LARGER THAN T:VALUE          
         WRPACK                                NO,WRITE THE PACK ON X6          
         LW,R5    LBA:PACK                        AND MOVE T:LDEF TO            
         LW,R6    PFBA:VAL                        THE TOP OF  T:VALUE           
         LW,R8    R2                                                            
         SLS,R8   1                                                             
         MOVEDW                                                                 
         SLS,R6   -2                                                            
         STW,R6   FWA:LDEF                                                      
         B        AD10                                                          
         TITLE    '        **** SRCHLDEF ****'                                  
*                                                                               
*        PURPOSE: TO SEARCH T:LDEF FOR AN ENTRY WITH A MATCHING EBCDIC          
*                 BYTE INDEX                                                    
*                                                                               
*        INPUT:   R8=T:DEFREF ENTRY (WITH EBCDIC INDEX IN BITS L8-31)           
*                 R9=X'3FFF'                                                    
*                                                                               
*        CALL:    BAL,R15   SRCHLDEF                                            
*                                                                               
*        OUTPUT:  R5=T:LDEF HALFWORD INDEX OF MATCHING ENTRY, OR                
*                   =ZERO,IF NO MATCH                                           
*                 R8,R9=UNCHANGED                                               
*                 R10=T:LDEF ENTRY WITH MATCHING EBCDIC INDEX                   
*                                                                               
*        USES:    R5,R10                                                        
*                                                                               
*                                                                               
SRCHLDEF LH,R5    *FWA:LDEF                                                     
SR10     LH,R10   *FWA:LDEF,R5                                                  
         CS,R8    R10                                                           
         BE       *R15                                                          
         BDR,R5   SR10                                                          
         B        *R15                                                          
         TITLE    '     **** OVERLAP ****'                                      
*                                                                               
*        PURPOSE: TO DETERMINE IF T:LDEF WILL OVERLAP T:LROM WHEN AN            
*                 ENTRY IS TO BE ADDED TO ONE OF THE TABLES.  IF SO,            
*                 TO EITHER SAVE THE PACKED DYNAMIC TABLES ON X6 AND            
*                 MOVE T:LDEF TO THE TOP OF THE AREA OR ABORT IF THE            
*                 PACK HAS ALREADY BEEN SAVED ON X6.                            
*                                                                               
*        INPUT:   R1=THE NEGATIVE OF THE NUMBER OF HALFWORD ENTRIES             
*                    IN T:LROM (INCLUDING THE ENTRY TO BE ADDED,IF ANY)         
*                 R5=THE NUMBER OF HALFWORD ENTRIES IN T:LDEF,                  
*                    (INCLUDING THE ENTRY TO BE ADDED,IF ANY)                   
*                 FWA:LDEF=FWA OF T:LDEF                                        
*                 FWA:BUF=LWA+1 OF T:LROM                                       
*                                                                               
*        CALL:    BAL,R13  OVERLAP                                              
*                                                                               
*        OUTPUT:  R1,R5 UNCHANGED                                               
*                                                                               
*        CALLS:   WRPACK,MOVEDW,RDIAG                                           
*                                                                               
*        USES:    ALL REGISTERS USED ARE RESTORED                               
*                                                                               
*                                                                               
OVERLAP  PUSH     2,3                                                           
CK10     ANLZ,R2  LB295       CALCULATE HA OF LAST T:LROM ENTRY                 
         ANLZ,R3  LB335       CALCULATE HA OF LAST T:LDEF ENTRY MINUS 1         
         CW,R2    R3         *WILL T:LDEF OVERLAY T:LROM                        
         BLE      CK20                                                          
         PULL     2,3            NO,EXIT                                        
         B        *R13                                                          
CK20     LW,R8    FL:WRPCK      YES,HAVE THE PACKED TABLES BEEN SAVED           
         BEZ      CK30                                                          
         LW,R8    FWA:LDEF              YES,IS T:LDEF AT THE TOP OF THE         
         SLS,R8   2                         DYNAMIC TABLE AREA                  
         CW,R8    FBA:TABS                                                      
         BE       LBMSG1                        YES,BACKGROUND TOO SMALL        
         BNE      CK40                          NO,MOVE T:LDEF AGAIN            
CK30     WRPACK                         NO,WRITE THE PACK ON X6 AND ...         
CK40     PUSH     5,11                     MOVE T:LDEF TO THE TOP OF THE        
         LW,R5    FWA:LDEF                 DYNAMIC TABLE AREA                   
         SLS,R5   2                                                             
         LW,R6    FBA:TABS                                                      
         LH,R8    *FWA:LDEF                                                     
         AI,R8    1                                                             
         SLS,R8   1                                                             
         MOVEDW                                                                 
         SLS,R6   -2                                                            
         STW,R6   FWA:LDEF                                                      
         PULL     5,11                                                          
         B        CK10                                                          
         TITLE    '       **** RDPACK ****'                                     
*                                                                               
*        PURPOSE: TO READ PACKED DYNAMIC TABLES FROM X6, SEQUENTIALLY           
*                                                                               
*        INPUT:   LBA:PACK=LBA+1 OF PACKED DYNAMIC TABLES (IN CORE)             
*                 FBA:TABS=FBA OF DYNAMIC TABLE'S AREAS                         
*                                                                               
*        CALL:    BAL,R15  RDPACK                                               
*                                                                               
*        OUTPUT:  NONE                                                          
*                                                                               
*        USES:    RESTORES ALL REGISTERS USED                                   
*                                                                               
RDPACK   PUSH     6,12                                                          
         LI,R9    READ                                                          
         LI,R10   0                 IF 'EOT' ON READ,ABORT                      
         B        WR10                                                          
         TITLE    '       **** WRPACK ****'                                     
*                                                                               
*        PURPOSE: TO WRITE PACKED DYNAMIC TABLES ON X6, SEQUENTIALLY            
*                                                                               
*        INPUT:   LBA:PACK=LBA+1 OF PACKED DYNAMIC TABLES                       
*                 FBA:TABS=FBA OF DYNAMIC TABLE'S AREAS                         
*                                                                               
*        CALL:    BAL,R15  WRPACK                                               
*                                                                               
*        OUTPUT:  FL:WRPCK=1                                                    
*                                                                               
*        USES:    RESTORES ALL REGISTERS USED                                   
*                                                                               
WRPACK   PUSH     6,12                                                          
         CAL1,1   FPT:LB10          SET RECORD SIZE TO 4*8191                   
         LW,R9    FL:WRPCK                                                      
         BNEZ     LBMSG2                PROGRAM ERROR,PACK ALREADY ON X6        
         MTW,1    FL:WRPCK                                                      
         LI,R9    WRITE                                                         
         LI,R10   1                 IF 'EOT' ON WRITE,RETURN TO 'WR40'          
WR10     STW,R10  PT:LB12                                                       
         STB,R9   FPT:LB11                                                      
         LI,R6    0                                                             
         LI,R9    PT:LB12           PARAMETER TABLE FOR 'ABNIO'                 
         LW,R11   FBA:TABS                                                      
         SLS,R11  -2                    R11=WA OF PACK BUFFER                   
         LW,R12   LBA:PACK                                                      
         SW,R12   FBA:TABS              R12=NO. OF BYTES IN PACK                
WR20     AI,R12   -4*8191     ARE THERE LESS THAN MAX BYTES TO OUTPUT           
         BLEZ     WR30            YES                                           
         LI,R8    4*8191          NO,OUTPUT THE PACK IN MORE THAN ONE           
         STW,R8   FPT:LB11+5         RECORD       (RSZ)                         
         STW,R11  FPT:LB11+4                      (BUF)                         
         CAL1,1   FPT:LB11                                                      
         AI,R11   8191                                                          
         AI,R6    1                                                             
         B        WR20                                                          
WR30     AI,R12   4*8191      WRITE/READ LAST RECORD ON X6                      
         BEZ      LBMSG2            (BYTE COUNT SHOULD NEVER BE ZERO)           
         STW,R12  FPT:LB11+5           (RSZ)                                    
         STW,R11  FPT:LB11+4            (BUF)                                   
         CAL1,1   FPT:LB11                                                      
WR32     CAL1,1   FPT:LB13          CLOSE  M:X6                                 
         LB,R10   FPT:LB11                                                      
         CI,R10   WRITE                                                         
         BNE      WR35                                                          
         LI,R7    7                 *WRITE REQUEST,CALCULATE THE NO. OF         
         LB,R7    M:X6,R7                         GRANULES WRITTEN ON X6        
         LH,R11   *K:RFT4,R7                                                    
         AND,R11  X:FFFF            GRAN SIZE IN BYTES                          
         AW,R12   R11                                                           
         AI,R12   -1                                                            
         DW,R12   R11                                                           
         CI,R6    0                                                             
         BE       WR34                                                          
WR33     LI,R8    4*8191                                                        
         LH,R11   *K:RFT4,R7                                                    
         AND,R11  X:FFFF            GRAN SIZE IN BYTES                          
         AW,R8    R11                                                           
         AI,R8    -1                                                            
         DW,R8    R11                                                           
         AW,R12   R8                                                            
         BDR,R6   WR33                                                          
WR34     LW,R11   Y:FFFE            *IS THIS THE LARGEST NO OF                  
         LI,R10   0                  GRANULES WRITTEN ON X6                     
         LS,R10   M:X6+4                                                        
         SLS,R12  17                                                            
         CW,R10   R12                                                           
         BGE      WR35                  NO                                      
         LW,R10   R12                   YES,SAVE IN M:X6                        
         STS,R10  M:X6+4                                                        
WR35     PULL     6,12                                                          
         B        *R15                                                          
WR40     EQU      %           RETURN HERE FROM 'ABNIO' IF 'EOT' ON WRITE        
         MTW,1    FL:OFLOW          SET FILE-OVERFLOW FLAGS                     
         MTB,1    M:X6+2                                                        
         MTW,1    FL:ERROR         *ERROR IN THIS SEGMENT'S LOAD                
         LI,R15   LB355                                                         
         B        WR32                                                          
*                                   AND EXIT                                    
         TITLE    '       **** TEMPBUF ****'                                    
TEMPBUF  RES      1000             *TEMPORARY BUFFER FOR T:LROM WHILE           
*                                   THE PACKED DYNAMIC TABLES ARE               
*                                   BEING UNPACKED                              
*                                                                               
*                                   NOTE:THIS BUFFER WILL GET CLOBBERED         
*                                        IF RDIAG OVERLAY GETS CALLED           
         END                                                                    
