*                SIGMA 5/7         BPM M:FINISH
***********************************************************************
*M*      FIN      FINISHES THE LOAD PROCESS BY PRINTING THE LOAD MAP.
***********************************************************************
*P*      NAME:    FIN
*P*      PURPOSE: ENTRY/EXIT FROM LDR.
*P*               UPDATES AND PRINTS SEVERITY LEVEL.
*P*               READS IDD FILE AND CALLS MOD.
*P*               GENERATES LOAD MAP.
*P*      DESCRIPTION: THE FIN SEGMENT COMPRISES THE FINAL STAGE OF THE
*P*               LOADER.BY NOW THE ENTIRE LOAD MODULE HAS BEEN WRITTEN
*P*               OUT. FINISH COMPUTES AND OUTPUTS THE SEVERITY LEVEL.
*P*               NEXT THE MOD ROUTINE IS CALLED. THIS ROUTINE
*P*               ESTABLISHES THE ENVIRONMENT FOR BOTH THE MODIFY AND
*P*               MAPER ROUTINES. IF THE SEVERITY LEVEL IS LESS THAN OR
*P*               EQUAL TO THE MAXIMUM,MODIFICATIONS ARE PERFORMED PER
*P*               THE !MODIFY CARDS WHICH HAVE BEEN PACKAGED INTO THE
*P*               IDD FILE BY CCI. IN ANY CASE MOD CALLS MAPER TO
*P*               GENERATE THE LOAD MAP.
*P*      REFERENCE: THE OVERLAY LOADER TECHNICAL MANUAL.
***********************************************************************
         SYSTEM   SIG7FDP
MODE     EQU      1
         CSECT    1
         DEF      MCFN
MCFN     EQU      %
         DEF      FINISH
         DEF      WRTCLR,LLBUF,SAVESEG,CSEGNO
         DEF      CLRBUF
         REF      TXBLNK
         REF      PBUF
         REF      USID
         REF      MODIFY
         REF      ER11
         REF      LIB
         REF      TXTREE
         REF      EFNAME
         REF      EFACCNT
         REF      SETEF
         REF      M4
         REF      M1
         REF      M8
         REF      M16
         REF      M17
         REF      MN1
         REF      MN16
         REF      Y2
         REF      Y8
         REF      Y02
         REF      Y001
         REF      Y002
         REF      Y004
         REF      Y008
         REF      Y00C
         REF      Y0003
         REF      Y0004
         REF      Y0006
         REF      Y0007
         REF      Y000F
         REF      Y00008
         REF      BREFERR
         REF      RFDFBAS
         REF      SEVLEV
         REF      BUF
         REF      RSEG00
         REF      RREL00
         REF      CSEG00
         REF      START
         REF      LOCCT
         REF      LOADBAS
         REF      MBIAS
         REF      TOPOMEM
         REF      OPENEF
         REF      LOCWD
         REF      EXPRDIS
         REF      RFDFDIS
         REF      00DIS
         REF      10DIS
         REF      LMNDIS
         REF      USACTDIS
         REF      BINTOHEX,BLANKER,PRINT
         REF      READLM
         REF      WRITELM
         REF      M:LM
         REF      M:LL
         REF      M:EF
M:DIC    EQU      M:EF
         REF      CLOSE
         REF      VAL%SW
         REF      LIBFLG
         REF      LMNSW
         REF      CODE
         REF      RFLDMODS          MASK FOR REF & BREF BITS IN LOCWD
         DO       MODE=1
         REF       CHKLM
         REF      Y03
         FIN
         REF      M24
         REF      J:LMN             SET LAST LOADED LMN IF SUCCESSFUL
         PAGE
*   VARIABLES AND SCRATCH AREA USED BY MAPER ROUTINE
NOIDD    EQU      LIB
RFOFLSVL EQU      X'F'             SEVERITY ASSIGNED TO RFLD TABLE OVRFLW
NBREFSVL EQU      X'3'
RFDFADR  EQU      RFDFBAS
HICORE   EQU      TOPOMEM
LLBUF    EQU      BUF
TREEADR  EQU      PBUF+8
FBRS     EQU      PBUF+9
NXTDISP  EQU      PBUF+10
NSK      EQU      PBUF+11
CSEGADR  EQU      PBUF+12
CSEGNO   EQU      PBUF+13
COLINDX  EQU      PBUF+14
MAPCHAIN EQU      PBUF+15
ENDRFDF  EQU      PBUF+16
LISK     EQU       ENDRFDF
ERRSW1   EQU      PBUF+17
SAVESEG  EQU      PBUF+19
SEGHI    EQU      RSEG00
SEGLO    EQU      RREL00
SEGSZ    EQU      CSEG00
         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
R8       EQU      8
R9       EQU      9
R10      EQU      10
R11      EQU      11
R12      EQU      12
R13      EQU      13
R14      EQU      14
R15      EQU      15
SR1      EQU      8
SR2      EQU      9
SR3      EQU      10
SR4      EQU      11
D1       EQU      12
D2       EQU      13
D3       EQU      14
D4       EQU      15
* * * * * * * * * * * * * * * *
%R4      EQU      16
%R8      EQU      32
         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'
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'
K22      EQU         X'22'
K24      EQU      X'24'
K26      EQU      X'26'
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'
KF0      EQU      X'F0'
KF1      EQU      X'F1'
KF2      EQU      X'F2'
KFF      EQU      X'FF'
K100     EQU      X'100'
K120     EQU      X'120'
K1FF     EQU      X'1FF'
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'
KFF00   EQU      X'FF00'
K8000    EQU      X'8000'
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'
KTR      EQU      'R'
         PAGE
         REF      MESSAGE
         REF      IOMSG
*        QUIT     ERROR,CONDITION,OUTPUT
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
BGEZ     EQU      X'681'
BE       EQU      X'683'
BNEZ     EQU      X'693'
BGE      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'
         PAGE
***********************
***** FILBUF PROC *****
***********************
*
*        FILBUF,RN   BA(SOURCE),SRCDSPL,SRCSIZ,BA(DESTN)
*    (OR INDIRECT)   *WADDR1,SRCDSPL,*WADDR2,*WADDR3
* (INDIRECT,INDEXED) (*WADDR1,X1),SRCDSPL,*WADDR2,(*WADDR3,X3)
*
*                                   R12,R13 VOLATILE
FILBUF   CNAME                   **MOVE BYTE STRING TO BUFFER**
         PROC
         LOCAL    R,RU1,RFADR,I8
LF       EQU       %
R        SET       CF(2)           REGISTERS
RU1      SET       R+1
         DO        AFA(3)          IS SIZE INDIRECT
RFADR    SET       AF(3)
         DO1      RFADR=R12
         DO1
         LW,R12    RFADR           YES
         ELSE
         LI,R12    AF(3)           NO
         FIN
         DO        AFA(4,1)        IS DESTIN ADDR INDIRECT(,INDER12ED)
RFADR    SET       AF(4,1)         YES
         DO1      RFADR=RU1
         DO1
         LW,RU1    RFADR,AF(4,2)
         ELSE
         LI,RU1    AF(4)           NO
         FIN
         DO       MODE=1
         STB,R12  RU1
         ERROR,15,R&1 'MBS REQUIRES EVEN-ODD PAIR'
         FIN
         DO        CF(2)=0
         DO       MODE=1
         MBS,0    BA(AF(2))
         ELSE
         LB,R13    AF(2)
         STB,R13   0,RU1
         AI,RU1    1
         BDR,R12   %-2
         FIN
         GOTO      I8
         FIN
         DO        AFA(1,1)        IS SOURCE ADDR INDIRECT(,INDER12ED)
RFADR    SET       AF(1,1)
         DO1      RFADR=R
         DO1
         LW,R      RFADR,AF(1,2)   YES
         DO        AF(2)~=0
         AI,R      AF(2)
         FIN
         ELSE
         LI,R      AF(1)+AF(2)     NO
         FIN
         DO       MODE=1
         MBS,R    0
         ELSE
         LB,R13    0,R
         STB,R13   0,RU1
         AI,R      1
         AI,RU1    1
         BDR,R12   %-4
         FIN
I8       EQU       %
         PEND
*  MOVE WORDS - SOURCE & DESTINATION RANGES DISJOINT, R11 VOLATILE
*        MOVE,RS  RC,RD    /  (RS)=SRCEADDR,(RC)=CNT,(RD)=DESTADDR
MOVE     CNAME
         PROC
LF       EQU      %
         AI,CF(2) KN1
         AI,AF(2) KN1
         LW,R11   *CF(2),AF(1)
         STW,R11  *AF(2),AF(1)
         BDR,AF(1) %-2
         PEND
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         PAGE
FINISH   EQU      %
*                                   FINISH COMPUTES AND PRINTS THE
*                                   FINAL SEVERITY LEVEL, PERFORMS ANY
*                                  MODIFICATIONS PER MODIFY CARDS, AND
*                                   GENERATES THE LOAD MAP.
         PSW,SR4  *R0
         CAL1,1   SETLM
         INT,SR1  BREFERR
         LI,R4    RFOFLSVL
         CI,SR2   0
         BNEZ     UPDSEV
CHKNBREF EQU      %
         LI,R4    NBREFSVL
         CI,SR1   0
         BEZ      CHECKSEV
UPDSEV   EQU      %
         CW,R4    SEVLEV
         BLE      CHECKSEV
         STW,R4   SEVLEV
CHECKSEV BAL,SR4  BLANKER
         LW,R7    SEVLEV
         BEZ      MODNMAP
         PSW,R1   *R0
*                                   PRINT NON-ZERO SEVERITY LEVELS.
*
         BAL,SR4  BINTOHEX
         LCI      3
         LM,SR4   SVL
         LCI      5
         STM,SR4  PBUF+1
         LI,R5    PBUF
         CAL1,2   PRINT
         LI,SR3   ERRTEXT
         LW,SR4   MESCONST
         STW,SR4  PBUF
         LI,R4    -2
         INT,SR1  BREFERR
BUILDMES EQU      %
         LW,R7    10,R4
         BEZ      NEXTERR
         BAL,SR4  BINTOHEX
         STW,D4   PBUF+1
         LCI      5
         LM,SR4   *SR3
         STM,SR4  PBUF+2
         CAL1,2   PRINT
NEXTERR  AI,SR3   5
         BIR,R4   BUILDMES
         PLW,R1   *R0
MODNMAP  EQU      %
         LW,R7    LOCWD
         CW,R7    RFLDMODS          IS THIS REF OR BREF
         BAZ      NOREFLOC          NO
         LW,SR4   MESCONST          YES: TELL USER HOW MANY OVERLAY-
*                                   CAUSING REFS WE HIT
         AW,SR4   =14**24           ALLOW FOR MESSAGE SIZE
         STW,SR4  PBUF
         LW,R7    VAL%SW            GET # OF OVERLAY-CAUSING REFS
         PSW,R1   *R0
         BAL,SR4  BINTOHEX
         PLW,R1   *R0
         STW,D4   PBUF+1
         LCI      5
         LM,SR4   UTBLMSG
         STM,SR4  PBUF+2
         LCI      4
         LM,SR4   UTBLMSG+5
         STM,SR4  PBUF+7
         LI,R5    PBUF
         CAL1,2   PRINT
NOREFLOC EQU      %
         LW,R5    Y003              SET CONDITION CODES
         AND,R5   LOCWD             FOR FAST MAP TYPE TESTS
         SLS,R5   8
         STW,R5   VAL%SW
         BAL,SR4  BLANKER           ALSO SET Y8 IF ONLINE
         BE       %+3               AND M:LL IS A TERMINAL
         LW,R5    Y8
         STS,R5   VAL%SW
         LC       VAL%SW            SET SWITCH TO BUILD SORT LIST
         BCR,1    %+2               IF DOING A NAME MAP
         MTW,4    VAL%SW
*E*      ERROR:   0200-11
*E*      MESSAGE: SEV. LEV. EXCEEDED
*E*      DESCRIPTION: THE SEVERITY LEVEL GENERATED BY THE LOADER IS
*E*               GREATER THAN THE MAXIMUM SPECIFIED.
         BAL,SR4  MOD               PROCESS ANY MODIFY CARDS & PRINT MAP
         CW,R5    SEVLEV
         QUIT     ER11,BGE,R5
         LI,R5    M:LM              CLOSE AND SAVE THE FILE.
         DO       MODE=1
         LW,R6    LOCWD
         CI,R6    X'4000'
         BAZ      DONTDEL
         MTW,0    LOADBAS           (IF BIAS=0, 1ST REC GOOD).
         BEZ      DONTDEL           OTHERWISE,
         CAL1,1   DELZEREC          DELETE IT
         FIN
DONTDEL  EQU      %
         CAL1,1   CLOSE
         MTW,0    NOIDD
         BNEZ     EXIT
         CAL1,1   CLSDIC            CLOSE & RELEASE MODIFY FILE
EXIT     EQU      %
*                                   ALL DONE!
         PLW,SR4  *R0
         B        *SR4
CLSDIC   GEN,8,24 X'15',M:DIC
         DATA     X'80000000',1
         DO       MODE=1
SETLM    GEN,8,24 6,M:LM
         DATA     X'C0000000',LMERR,LMERR
LMERR    QUIT     16,,SR3
DELZEREC GEN,8,24 X'D',M:LM
         DATA     X'80000000',Y03
         FIN
         PAGE
*                                   THIS ROUTINE PROCESSES ANY !MODIFY
*                                   CARDS ENCOUNTERED BY CCI AND OUT-
*                                   PUTS THE LOAD MAP. THE MODIFY CARDS
*                                   ARE NOW RECORDS IN A FILE NAMED
*                                   SYSID D. THE M:EF DCB (CALLED M:DIC) IS USED
*                                   INITIALIZE TREE & PNTRS FOR MAPER
MOD      PSW,SR4  *R0
         MTW,-1   -1,R1
         LW,R5     -1,R1            CLEAR LAST WORD IN EACH TREE
         AW,R5    R1                FOR DISPLACED DEFS FLAG
         LI,R7    0
         LW,R4    R1
         STW,R7   10,R4
         AI,R4    11
         CW,R4    R5
         BL       %-3
         STW,R7   NOIDD             RESET MODIFY FLAG
         LW,R5    TOPOMEM
         STW,R5   NXTDISP
         LH,R5    LOCWD
         AND,R5   M4
         PSW,R5   *R0
         CW,R5    SEVLEV
*                                   CHECK SEVERITY LEVEL.
         BL       NOMOD
*                                   OPEN THE DEBUG FILE.
         LW,R5    LOCWD
         CW,R5    Y004
         BANZ     NOMOD             BRANCH IF ALREADY EXISTING
         LI,R4    'D'
         AW,R4    USID
         STW,R4   EFNAME
         LW,R4    LOCCT
         CI,R5    K10               DONT SET J:LMN IF LIB
         BANZ     %+4
         LCI      7
         LM,SR1   10,R4
         STM,SR1  J:LMN
         LCI      2
         LM,R5    13,R4
         STM,R5   EFACCNT
         LI,SR1   NOMOD             SET OPEN RETURN IF NO OPEN
         LW,R4    LOCWD
         DO       MODE=0
         CI,R4    X'4000'           IN XMEM FOR BPM, M:DIC
         BAZ      %+2               WAS USED TO WRITE SCRATCH SYSID X
         CAL1,1   CLSDIC            FILE.  RELEASE IT NOW.
         FIN
         CAL1,1   OPENEF
         LI,SR1   MOD1              SET RETURN FOR FUTURE ERR/ABNS
         CAL1,1   SETEF
         CAL1,1   PRECORD
         CI,R4    X'4010'
         BAZ      MOD8
         BAL,SR4  BLANKER
         LCI      6
         LM,SR1   NOMODMSG
         STM,SR1  PBUF
         LW,R4    LOCWD
         CI,R4    X'10'
         BANZ     %+4
         LCI      4                 XMEM
         LM,SR1   XMEMMSG
         B        %+3
         LCI      4                 LIBRARY LMN
         LM,SR1   LIBMSG
         STM,SR1  PBUF+6
         LI,R5    PBUF
         CAL1,2   PRINT
         CAL1,1   CLSDIC
         LW,R5    TOPOMEM
         STW,R5   NXTDISP
         B        NOMOD
*                                   THE NECESSARY TABLE FOR THE MODIFY
*                                   ROUTINE IS BUILT IN PBUF.
MOD8     AW,R7    R1
         STW,R7   PBUF+2
         LI,SR1   K0
         STW,SR1  SAVESEG
MOD0     LI,D1    PBUF+4
         LI,D2    00DIS
         LI,R5    K0
         STW,R5   PBUF+1
         BAL,SR4  RDRFDF            READ THIS SEGMENTS RFDF STK
         LW,D3    R5
         SLS,D3   15
         STW,D3   PBUF+3
         LW,D3    TOPOMEM
         SLS,D3   15
         STW,D3   PBUF+7
         MTB,2    *R7,R4
*                                   READ IN THE PROTECTION TYPES FOR THE
*                                   SEGMENT AND THE RELOCATION DICT.
MOD4     SLS,R6   -2
         AW,R5    R6
         AI,R5    K1
         SLS,R5   -1
         SLS,R5   16
         STW,R5   *D1
         SLS,R5   -15
         LW,R6    *D2,R7
         SLS,R6   -16
         CI,R6    K0
         BE       MOD2
         LW,SR4   LOCWD
         CI,SR4   K100
         BANZ     MOD9
         CI,SR1   K0
         BE       %+3
         CAL1,1   WRITELM
         B        MOD2
         DO       MODE=1
         BAL,SR4  CHKLM
         FIN
         CAL1,1   READLM
MOD2     MTB,1    *R7,R4
         AI,R6    K7
         SLS,R6   -2
         AND,R6   MN1
         AW,R5    R6
         AI,R5    K1
         SLS,R5   -1
         AWM,R5   *D1
         SLS,R5   1
         LW,R6    *D2,R7
         AND,R6   MN16
         SLS,R6   -13
         CI,R6    K0
         BE       MOD3
         CI,SR1   K0
         BE       %+3
         CAL1,1   WRITELM
         B        MOD3
         DO       MODE=1
         BAL,SR4  CHKLM
         FIN
         CAL1,1   READLM
MOD3     AI,D1    K1
         AI,D2    K2
         MTB,1    *R7,R4
         CI,D2    10DIS
         BLE      MOD4
         CI,SR1   K0
         BNE      MOD7
         LI,D3    K0
         STW,D3   EXPRDIS,R7
         SLS,R6   -2
         AW,R5    R6
MOD6     STW,R5   PBUF
         CW,R5    NXTDISP           OVERFLOW INTO DISPLACED DEF STK
         BLE      MOD6A             B IF NOT
         LW,R6    TOPOMEM
         STW,R6   NXTDISP           REINITIALIZE DISPL. DEF STK
MOD6A    EQU      %
         LW,SR2   R7
         LB,R6    *SR2
         LI,R7    K0
         STB,R7   *SR2,R6
         B        MOD5A
*                                   READ THE DEBUG FILE WITH THE
*                                   KEY EQUAL TO THE SEGMENT NAME
*                                   CONCATENATED WITH 0,1,2....
MOD5     MTB,1    *SR2,R6
         BEZ      MOD1              DONE MAX # OF MODIFYS FOR THIS SEG
MOD5A    EQU      %
         CAL1,1   RDDBUG
         LB,R7    *R5
         CI,R7    K2
         BNE      MOD5
         ANLZ,R7  MOD6
         LCI      4
         PSM,R1   *R0
*                                   DO THE MODIFICATION.
         BAL,SR4  MODIFY
         LCI      4
         PLM,R1   *R0
         B        MOD5
*                                   LAST DEBUG FOR THE SEGMENT HAS BEEN
*                                   PROCESSED, GO WRITE THE SEGMENT.
MOD1     LW,R7    PBUF+2
         MTB,-1   *R7
         LI,SR1   K1
         B        MOD0
MOD7     MTB,-1   *R7
         B        MAP1
NOMOD    MTW,1    NOIDD             SET FLAG FOR NO MODIFY CARDS
         LI,SR1   0
         LW,D4    LOCWD
         CI,D4    K10
         BAZ      MAP
         STW,D4   LIBFLG       SET LIBRARY FLAG.
         LW,R4    MBIAS             IF A LIBRARY LOAD MODULE,
         STW,R4   RFDFDIS,R1        POINT TO ORIGINAL RFDFSTK IN TREE
         AW,R7    R1
         B        MAP1
MOD9     LI,SR4   MOD10
         STW,SR4  PBUF+1
         LI,R6    0                 DONT ALLOCATE SPACE EITHER
         B        MOD2
MOD10    LB,R5    R0
         AI,R5    K4
         LW,R5    *R7,R5
         SLS,R5   1
         STS,R2   *R5,R1
         B        *SR4
         PAGE
*                                   MAP EACH SEGMENT AFTER IT HAS BEEN
*                                   MODIFIED.
MAP      EQU      %
         AW,R7    R1
         BAL,SR4  RDRFDF
         MTB,-1   *R7
MAP1     BAL,SR4  MAPER
         AI,R7    11
         SW,R7    R1
         CW,R7    -1,R1
         BGE      MODEXIT
         LW,R5    NOIDD
         BNEZ     MAP               MAP NEXT SEGMENT IF NO MODS
         B        MOD8              ELSE PROCESS MODS FOR NEXT SEGMENT
MODEXIT  EQU      %
         DO       MODE=1
         LW,R9    LOCWD        TEST TO DETERMINE IF REF/DEF
         CW,R9    Y008              WAS SHORTENED
         BAZ      NO%WR             ...IT WASN'T
         CI,R9    X'10'             IS IT A LIB. LOAD MODULE
         BANZ     NO%WR             THEN REF/DEF WASN'T SHORTENED
         LW,R5    R1           PLACE TREE ADDRESS INTO R5.
         AI,R5    -1           POSITION R5 TO TREE COUNT.
         LW,R6    *R5          PLACE TREE LENGTH INTO R6.
         AI,R6    1
         STW,R6   *R5
         SLS,R6   2
         LI,R7    TXTREE
         CAL1,1   WRITELM      WRITE OUT TREE FOR THIS LOAD MODULE.
NO%WR    EQU      %
         FIN
         PLW,R5   *R0
         PLW,SR4  *R0
         B        *SR4
RDRFDF   EQU      %
         MTB,1    *R7
         LB,R4    *R7
         LI,R5    0
         STB,R5   *R7,R4
         LW,R5    RFDFBAS
         LW,R6    RFDFDIS,R7
         AND,R6   MN16
         SLS,R6   -14
         CI,SR1   0
         BNE      NOREAD            B IF WRITE MODE SET
         DO       MODE=1
         PSW,SR4  *R0
         BAL,SR4  CHKLM
         PLW,SR4  *R0
         FIN
         CAL1,1   READLM
NOREAD   B        *SR4
RDDBUG   GEN,8,24 X'10',M:DIC
         DATA     X'38000010'
         DATA     X'80000005',140,X'80000009'
PRECORD  GEN,8,24 X'1D',M:DIC
         DATA     X'C0000000'
         DATA     1
         DATA     NOMOD
MESCONST DATA     X'1B40E77D'
ERRTEXT  TEXT     ''' NON-BRANCHING REFS'
         TEXT     ''' BRANCHING REFS     '
UTBLMSG  TEXT     ''' OVERLAY-CAUSING REFS ENCOUNTERED'
SVL      TEXT     ' SEV. LEV.'
NOMODMSG DATA     X'2540D4D6'
         TEXT     'DIFY COMMANDS IGNORE'
XMEMMSG  TEXT     'D IN XMEM       '
LIBMSG   TEXT     'D FOR LIB LMN   '
         PAGE
**************************************
***** REGISTER USAGE CONVENTIONS *****
**************************************
*
*  MAJOR PROCESSING ROUTINES:   BAL,R15  MAJOR
*                                        ARGUMENTS IN ANY REGISTER
*  UTILITY ROUTINES         :   BAL,R11  UTILITY
*                                        ARGUMENTS/RESULTS IN R5-R10
*                                        R0-R4 UNUSED
*                                        R11 LINK
*                                        R12-R15 UNUSED
*  I/O REQUESTS:  R5 <-- BUFFER ADDRESS
*                 R6 <-- BUFFER SIZE
*                 R7 <-- RECORD KEY ADDRESS
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         PAGE
**************************************
***** LOAD MAP PROCESSOR CONTROL *****
**************************************
*
*  NOTES: 1. THIS SECTION IS THE CONTROL PORTION OF THE PROCESSOR.
*            ALL OTHER MAJOR ROUTINES ARE CALLED FROM HERE.
*
**********************************
***** OUTPUT BUFFER POINTERS *****
**********************************
BALLBUF  EQU       BA(LLBUF)         BA(M:LL DCB BUFFER)
BFL%%    EQU       BA(LLBUF)+0       TRIM LEFT  =28
BFR%%    EQU       BA(LLBUF)+71      TRIM RIGHT
BFHDNGS  EQU       BA(LLBUF)+30      HEADINGS
BFACN    EQU       BA(LLBUF)+39      ACN
BFROOT   EQU       BA(LLBUF)+49      '<ROOT>'
BFTYPLM  EQU       BA(LLBUF)+57      LM TYPE
BFLMN    EQU       BA(LLBUF)+39      LMN
BFBIAS   EQU       BA(LLBUF)+62      BIAS
BFSGN    EQU       BA(LLBUF)+39      SEG NAME
BFSGSZ   EQU       BA(LLBUF)+62      SEGSIZE
BFDEFS   EQU      BA(LLBUF)+20  DESCRIPTION OF DEFS.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
***************************
***** TEXT DATA SIZES *****
***************************
SZ%%     EQU       31
SZHDNGS  EQU       42
SZTYPLM  EQU       11
SZROOT   EQU       6
SZDEFS   EQU      61
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         PAGE
MAPER    EQU      %
         LCI       0                 SAVE THE REGISTERS
         PSM,R0   *R0
         STW,R1   TREEADR           PNTR TO 1ST WD OF TREE TABLES
         STW,R7   CSEGADR           PNTR TO 1ST WD OF THIS SEG'S TREE
         DO       MODE=1
         LW,R9    LOCWD        CHECK IF UNUSED DEFS ARE TO BE
         CW,R9    Y008              REMOVED...
         BAZ      DO%MAP            ...THEY AREN'T
         CI,R9    X'10'             IS THIS A LIB. LOAD MODULE?
         BAZ      DEL%DEF           NO, SO WE CAN SHORTEN STACK
         LI,R5    RDEF%MSG          YES, SKEAP OF IT
         CAL1,2   PRINT        LIBRARY LOAD MODULE.
         B        DO%MAP
DEL%DEF  EQU      %
         LW,R8    RFDFBAS      SET REGISTERS 6 AND 7 TO BEGINNING
         LW,R9    RFDFBAS      OF REF/DEF STACK.
         LW,D2    CSEGADR
         AI,D2    6
         LH,R3    *D2   R3=SIZE OF REF/DEF TABLE.
         STW,R3   ENDRFDF      SAVE SIZE
         LI,R2    0
         LI,R3    0
NXT%ENT  EQU      %
         LB,R4    *R8          LOAD NUMBER OF WORDS INTO R4
         LW,R5    *R8
         AND,R5   Y000F        PERFORM CHECK TO DETERMINE
         SLS,R5   -16          IF THE ENTRY IN THE REF/DEF
         CI,R5    8            STACK IS A DEF ENTRY.
         BE       CHK%DEF      DEF FOUND.
         CI,R5    0
         BNE      MVE%ENT      NOT DEF
         AI,R8    1            CHECK FOR ADEF.
         LW,R5    *R8
         AI,R8    -1
         CI,R5    0
         BE       MVE%ENT      ADEF FOUND
CHK%DEF  EQU      %
         LI,R5    2
         AND,R5   *R8               IS THIS AN UNUSED DEF
         BEZ      UP%R6        YES--UNUSED DEF ENCOUNTERED.
MVE%ENT  EQU      %
         STB,R4   R9
         SLS,R9   2
         SLS,R8   2
         MBS,R8   0
         SLS,R9   -2
         SLS,R8   -2
         AW,R2    R4
         B        TST%END
UP%R6    EQU      %
         AW,R8    R4
TST%END  EQU      %
         AW,R3    R4
         CW,R3    ENDRFDF      HAVE WE REACHED END OF STACK.
         BL       NXT%ENT      NO.
         LW,R4    R7
         AI,R4    6            PLACE NEW RFDFSTACK SIZE
         STH,R2   *R4          INTO THE TREE TABLE.
         MTB,1    *R7
         LB,R4    *R7
         LI,R5    0
         STB,R5   *R7,R4
         LW,R5    RFDFBAS      BASE OF REF/DEF STACK.
         LW,R6    RFDFDIS,R7
         AND,R6   MN16
         SLS,R6   -14
         CAL1,1   WRITELM
         MTB,-1   *R7               RESTORE PROPER SEGNAME SIZE
DO%MAP   EQU      %
         FIN
         LW,R3    RFDFDIS,R7
         LH,R3    R3
         AW,R3    RFDFADR
         STW,R3   ENDRFDF           END OF RFDFSTK + 1
         SW,R7    R1
         STW,R7   CSEGNO            DISP OF SEG'S TREE INTO TABLES
         BAL,R11  CLRBUF            INIT LL BUFFER
         PAGE
         LC       VAL%SW            DO WE MAP AT ALL
         BEZ      LINE3
* * * * * * * * * * * * * * * * * *
LINE0    LW,R2    CSEGNO            PRINT LINES 0,1 IF ROOT
         BNEZ     LINE2
LINE01   BAL,R11   MOVE%%            SET UP FOR LINE 0
         FILBUF,R4 BA(TXLN0),0,SZHDNGS,BFHDNGS    LINE 2 HEADING TO BUF
         LC       VAL%SW
         BCR,8    TOF               SEND TOP OF FORM IF BATCH
         LI,R4    'B'               SPACE 2 LINES FOR UC
         STW,R4   LLBUF+3
TOF      EQU      %
         LI,R4    '1'
         STB,R4   LLBUF
         BAL,R11  WRTCLRO
         B        LINE11
* * * * * * * * * * * * * * * * * *
MOVE%%  FILBUF,R6  BA(TX%%),0,SZ%%,BFL%%
         FILBUF,R6  BA(TX%%),0,SZ%%,BFR%%
         B        *R11
* * * * * * * * * * * * * * * * * *
LINE11   EQU      %
         BAL,R11   MOVE%%
         FILBUF,R4 BA(TXLN1),0,SZHDNGS,BFHDNGS
         LW,R2    LOCCT
         AI,R2    USACTDIS
         SLS,R2   2                 ACCT NO. - BYTE RES.
         FILBUF,R4 *R2,0,8,BFACN          'ACCTNMBR' TO LLBUF
         FILBUF,R4 BA(TXROOT),0,SZROOT,BFROOT     '<ROOT>' TO LLBUF
         LW,R7    START
         BAL,R11  BINHEX
         BAL,R11  LJADDR
         FILBUF,R4 %R8,0,SZADDR,BFBIAS  /  START ADDR TO LLBUF
         BAL,R11  WRTCLRO
LINE2    BAL,R11   MOVE%%          **SET UP AND PRINT LINE 2**
         LW,R2    CSEGNO
         BEZ      LINE21
         LI,R4     '1'               ELSE NEW PAGE
         STB,R4    LLBUF
         LC       VAL%SW            IF ONLINE, SPACE 2
         BCR,8    %+3
         LI,R4    'B'
         STW,R4   LLBUF+3
LINE21   FILBUF,R4 BA(TXLN2),0,SZHDNGS,BFHDNGS  /  HEADING TO LLBUF
         LW,R7    LOADBAS           GET BIAS
         BAL,R11   BINHEX
         BAL,R11   LJADDR
         FILBUF,R4 %R8,0,SZADDR,BFBIAS          /  BIAS TO LLBUF
         LW,R2    LOCCT
         AI,R2    LMNDIS
         LB,R3    *R2
         LW,R4    *R2               IF ID TYPE NAME
         LI,R5    X'FFF00'          DONT PRINT IT
         CS,R4    USID
         BE       SKIPLMN
         SLS,R2   2                 LMN NAME, BYTE RES.
         FILBUF,R4 *R2,1,*R3,BFLMN
SKIPLMN  EQU      %
         MTW,0    LIBFLG            NO BIAS FOR LIBS
         BEZ      NOTLIB1
         FILBUF,R4 BA(TXLN2+2),,12,BFBIAS-5  COVER W BLANKS
NOTLIB1  RES
         BAL,R11  WRTCLRO
* * * * * * * * * * * * * * * * * *
LINE3    EQU      %
         LW,R11   LOCWD
         CW,R11   Y003              ARE WE GOING TO DO A MAP
         BANZ     %+3               YES: GIVE 'EM THE WORKS
         CW,R11   Y02               ARE WE TO INHIBIT SIZE SUMM
         BANZ     REFORM            YES
         BAL,R11  MOVE%%
         FILBUF,R4 BA(TXLN3),0,SZHDNGS,BFHDNGS  /  HEADING TO LLBUF
         LC       VAL%SW            ARE WE MAPPING
         BNEZ     NOSKIPPY          YES: DONT SPACE FOR LINE3
         LI,R4    'B'               OTHERWISE SKIP 2 LINES
         BCR,8    %+2               IS LL A TERMINAL
         STW,R4   LLBUF+3
         STB,R4   LLBUF
NOSKIPPY EQU      %
LINE31   LW,R2    CSEGADR
         MTW,0    LIBFLG            IF LIBRARY, PUT OUT NAME
         BEZ      NOTLIB2
         FILBUF,R4 BA(LIBT),,3,BFSGN-6 PUT LIBN
         LI,R2    M:LM+23
NOTLIB2  LB,R3    *R2
         LW,R4    0,R2              IF ID TYPE NAME, DONT PRINT
         SLS,R2   2                 IT
         LI,R5    X'FFF00'
         CS,R4    USID
         BE       SKIPSEGN
         FILBUF,R4 *R2,1,*R3,BFSGN              /  SEG NAME TO LLBUF
SKIPSEGN EQU      %
         LI,R2     10              **DETERMINE SEGMENT SIZE**
         LI,R5     0
LINE32   AH,R5    *CSEGADR,R2       ACCUM SUM OF PT SIZES FROM TREE
         AI,R2     4
         CI,R2     18
         BLE       LINE32
         INT,R5   R5                CLEAR GARBAG BITS
         SLS,R5    1                 DW SIZE TO WORDS
         MTW,0    CSEGNO            IZZIT THE ROOT WE GOT HERE???
         BNEZ     SIZEOK            NOPE, SO 00 SIZE WILL BE OK
         LI,R4    11
         LH,R4    *CSEGADR,R4       GET ROOT 00 BASE
         SLS,R4   1                 MAKE IT A WORD ADDRESS
         SW,R4    LOADBAS
         AW,R5    R4                ALLOW FOR TCB, F4:COM, CORELIB DATA
SIZEOK   EQU      %
         LI,R4     0
         DW,R4    D1024             SEG SIZE IN R5
         STW,R5    R7                WHOLE 'K' TO R7
         SLD,R4   -32
         DW,R4    D103              FRACTION 'K' IN R5  (DEC)
         LB,R5     BNHX%TAB,R5
         STB,R5    R5                SET UP SIZE AS DECIMAL QTY=XXX.X
         LI,R3     3                 CONVERT WHOLE K TO DECIMAL
LINE33   LI,R6     0
         DW,R6    D10
         LB,R6     BNHX%TAB,R6
         STB,R6    R4,R3
         BDR,R3    LINE33
         LI,R6     '.'               INSERT DEC PT
         STB,R6    R4
         SCS,R4    8                 XXX.X IN R4R5
         FILBUF,R6 %R4,0,5,BFSGSZ               /  SEG SIZE TO LLBUF
         BAL,R11  WRTCLRO
         LC       VAL%SW
         BEZ      LINE4        B IF MAP OPTION NOT SPECIFIED.
LINE3A   LW,R4    CSEGNO
         BNEZ     LINE4             PRNT FLG DEFINITIONS IF ROOT
         FILBUF,R4 BA(TXLN3A),0,SZDEFS,BFDEFS
         BAL,R11  WRTCLRO
* * * * * * * * * * * * * * * * * *
LINE4    FILBUF,R4 BA(TXPTLN4),0,42,BALLBUF
         BAL,R11   WRTCLR
         FILBUF,R4 BA(TXPTLN4A),0,39,BALLBUF
         BAL,R11  WRTCLR
         FILBUF,R4 BA(TXPTLN4B),0,39,BALLBUF
         BAL,R11  WRTCLR
* * * * * * * * * * * * * * * * * *
         BAL,R15   SEGEVAL         **EVALUATE SEG SUMMARY DATA**
         LI,R2     3
         MTW,0    LIBFLG            IF LIB, ONLY ONE CSECT TYPE
         BEZ      %+2
         LI,R2    1
NEXT567  EQU      %
         BAL,R11   VALMOVE           MOVE TEXT & SUMMARY DATA
         BAL,R11   WRTCLR            WRITE THE LINE
         BDR,R2    NEXT567           DO NEXT LINE
* * * * * * * * * * * * * * * * * *
REFORM   BAL,R15   PREPROC         **PREPROCESS THE RFDF STACK**
         LI,R2     3                 SET PSMA INDEX
REFORM1  EQU      %
         BAL,R15   PSMALIST        **LIST PREF'S, SREF'S, DDEF'S**
         LW,R15   LOCWD
         CW,R15   Y02               IS SS BIT SET IN LOCCT
         BAZ      %+2               NO, LIST SREF'S
         AI,R2    -1                YES: SKIP SREF'S CAUSE HE'S PROBABLY
         BDR,R2   REFORM1           ...ONLINE & DOESN'T CARE.
         LC       VAL%SW
         BEZ      ENDMAP            BRANCH IF MAP NOT SPECIFIED.
         LI,R2     4
         BAL,R15   PSMALIST          LIST THE ADEF'S
         BAL,R15  SORTMAP           SORT BY NAME AND VALUE
* * * * * * * * * * * * * * * * * *
         BAL,R15  MAPLISTN          PRINT NAME SORT MAP IF REQ'D
         BAL,R15  MAPLISTV          AND VALUE ONE
ENDMAP   EQU      %
         LCI      0
         PLM,R0   *R0
         B        *SR4
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
TX%%     TEXT      ' ******************************'
TXLN0    TEXT      '****  SIGMA 5/6/7/9  LOAD MODULE MAP  ****'
TXLN1    TEXT      '*** ACN=                  START=       ***'
TXLN2    TEXT      '**  LMN=                   BIAS=        **'
TXLN3    TEXT      '*   SGN=                   SIZE=     K   *'
TXLN3A   TEXT     '"+"=DBLE DEF "-"=LIB DEF "*"=UNUSED DEF ',;
                  '"@"=UNUSED LIB DEF   '
TXPTLN4  TEXT     'A ************ PROTECTION TYPES ************'
TXPTLN4A TEXT     '       00 DATA  01 PROCEDURE  10 STATIC'
TXPTLN4B TEXT     '       -------  ------------  ---------'
TXHILN5  TEXT     '  HIGH:'
TXLOLN6  TEXT     '  LOW :'
TXSZLN7  TEXT     '  SIZE:'
TXROOT   TEXT     '<ROOT>'
SOFM     TEXTC    ' OUT OF ROOM TO SORT NAMES..SOME DELETED'
LIBT     TEXT     'LIB'
GOFM     TEXT     'DISPLACED DEF DELETED:  '
         PAGE
***************************************
***** REF/DEF STACK PREPROCESSING *****  BAL,R15  PREPROC
***************************************           NO ARGUMENTS
*
*  NOTES: 1. IRRELEVANT ENTRIES (TO MAP) ARE DELETED(IE: SET TYPE=X'F')
*              EG: -ENTRIES <3 WORDS IN LENGTH
*                  -RESOLUTION NOT ONE IN %RESOL TABLE
*                  -DEF'S WITH POINTERS TO ANOTHER TREE TABLE
*                     (THESE ARE ALSO MOVED TO DISPLACED DEF STACK)
*                  -C/DSEC ENTRIES WITH SIZE=0
*                  -ENTRIES OTHER THAN TYPES 0,1,2,3,6,8,B.
*         2. VALUE IS SET ABS OR WORD ADDR+BTD(AAAAAAAA OR 0AAAAA0B)
*         3. CONTROL WORD IS RE-FORMATTED
*              EG: -BIT 11 IS RESET (0)
*                  -BIT 10 IS SET FOR ADEF'S
*                                  **RESOLUTION TABLE**
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
%RESOL   DATA      X'01000000'       BYTE -  SLD,R  -2
         DATA      X'00010000'       HALF -  SLD,R  -1
         DATA      X'00000100'       WORD -  SLD,R   0
         DATA      X'00000001'       DBL  -  SLD,R   1
         DATA      X'0'              ABS
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
%TYPE    B         %DEF            **PROCESSING CONTROL TABLE**
         B         %PREF
         B         %SREF
         B         %DSEC
         B         %DELETE
         B         %DELETE
         B         %CSEC
         B         %DELETE
         B         %DDEF
         B         %DELETE
         B         %DELETE
         B         %DSEC
         B         %DELETE
         B         %DELETE
         B        %PSEC
         B         %DELETE
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
%RESOLVE SLD,R4   -2               **RESOLVE VALUE EXU'S**
         SLD,R4   -1
         SLD,R4    0
         SLD,R4    1
         SLD,R4   0
* * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
PREPROC  EQU       %               **ENTERED HERE**
         PSW,R15  *R0
         LW,R1     RFDFADR         R1 <--ADDR OF CURRENT RFDF ENTRY
* * * * * * * * * * * * * * * * * *
PRCLOOP  LB,R2    *R1              **CHECK FOR IRRELEVANT ENTRY**
         CI,R2     2
         BLE       %DELETE           <3 WORD ENTRY
         LW,R4     2,R1              GET RESOL WORD
         LI,R3     5
         CW,R4     %RESOL-1,R3       CHECK RESOLUTION
         BE        PRCOK           R3 <-- RESOLUTION INDEX
         BDR,R3    %-2
         B        %DELETE0
PRCOK    LW,R6    *R1              **RES & SIZE OK - GET TYPE**
         AND,R6   Y000F
         SLS,R6   -16              R6 <-- ENTRY TYPE
         B         %TYPE,R6        **GO TO RESPECTIVE TYPE PROC**
* * * * * * * * * * * * * * * * * *
%DEF     EQU       %               **DEF'S, DDEF'S, & ADEF'S**
         DO       MODE=1
         LW,R4    *R1          HAVE WE ENCOUNTERED
         AND,R4   M1           A LIBRARY DEF--?
         BEZ      RESET        NO
         LW,R4    LOCWD        ARE LIB DEFS
         AND,R4   Y00008       TO BE PRINTED?
         BEZ      %DELETE      NO.
         LW,R4    *R1          HAVE WE ENCOUNTERED
         CI,R4    2                 ...AN UNUSED DEF HERE.
         BANZ     RESET             NO. ITS BEEN USED (AND WHO HASN'T)
         LW,R4    LOCWD
         AND,R4   M1           ARE UDEFS TO BE PRINTED?
         BEZ      %DELETE           NO
RESET    EQU      %
         FIN
%DDEF    EQU      %
         LW,R4    *R1                GET CONTROL WORD
         AND,R4   YFFCFFFFF         RESET ADEF AND LISTED BITS
         CI,R3     5
         BE        %ADEF             ADEF (RES WD =0)
         STW,R4   *R1              R4 <--CONTROL WORD
         BAL,R11   PRCRESLV          RESOLVE VALUE, SET ROSOL WD ZERO
         B         %DSPLCHK
* * * * * * * * * * * * * * * * * *
%ADEF    OR,R4    Y002              SET THE ADEF BIT
         STW,R4   *R1              R4 <--CONTROL WORD
         LI,R5     0
         STW,R5    2,R1              RESET RESOL WD TO ZERO
* * * * * * * * * * * * * * * * * *
%DSPLCHK AND,R4   XFFFC             **CHECK FOR DISPL DEF**
         BEZ       PRCNXT            NO
         LW,R3     TREEADR         **YES - MOVE DEF AND FLAG TREE TABLE*
         LW,R5    -1,R3
         CI,R5    KC
         BLE      %DELETE           DON'T FLAG DISPLACED DEFS
         SLS,R4   -2
         CW,R4    CSEGNO            DONT MOVE IF NOT REALLY DISPLACED
         BE       PRCNXT
         AW,R3     R4                POINTER TO DEF'S TREE
         LI,R4    KN1
         STW,R4    10,R3           **SET FLAG IN TREE**
         LW,R4     R1
         LW,R5     NXTDISP           WA(NEXT DISPL DEF LOC)
         SW,R5     R2                BUILD DISPL DEF STACK FROM TOP DOWN
         STW,R5    NXTDISP           UPDATE NXTDISP POINTER
         CW,R5     ENDRFDF
         BG        PRCDDD
         LI,R15    %DELETE
         B         PRCDSP4
PRCDDD   EQU       %
         MOVE,R4  R2,R5
         B         %DELETE           DELETE ENTRY FROM CURRENT STACK
* * * * * * * * * * * * * * * * * *
%DSEC    EQU      %
         LW,R4    *R1
         AND,R4   Y002              IS DOUBLE DEF'ED DSECT FLAG SET
         BEZ      %CSEC             NOPE.
         LW,R4    =X'180002'        YEP: MARK IT AS A USED DBL DEF...
         LW,R5    M24               ...SO'S IT'LL SHOW UP ON THE MAP
         STS,R4   *R1               AS A DOUBLE DEF AND NOT LEAVE THE
         B        %DDEF             USER WITH A GHOSTLY SEVERITY 4.
%PSEC    EQU      %                 **PSECTS,**
%CSEC    EQU       %               **CSEC'S & DSEC'S HERE**
         LW,R4    *R1                GET SIZE
         AND,R4   M16
         BEZ       %DELETE           DELETE ZERO SIZE ENTRY
         LI,R4     0
         LW,R5    Y003
         STS,R4   *R1
         BAL,R11   PRCRESLV          RESOLVE VALUE & SET RES WD ZERO
         B         PRCNXT
* * * * * * * * * * * * * * * * * *
%PREF    EQU       %               **SKIP PREF'S  **
%SREF    EQU       %               **SKIP SREF'S  **
PRCNXT   EQU       %               **GET NEXT ENTRY*
         AW,R1     R2
         CW,R1     ENDRFDF          CHECK END RFDF STACK
         BGE       PRCDISPL         END - GO AND GET ANY DISPLACED DEFS
         B         PRCLOOP
* * * * * * * * * * * * * * * * * *
%DELETE0 LH,R6    *R1               GET TYPE
         AND,R6   M8
         CI,R6    K2                PREF
         BNE      %DELETE           NO
         STW,R3   2,R1              SET RESOLUTION WD=0
         B        %PREF
%DELETE  LW,R5    Y003F             **IRRELEVANT ENTRIES DELETED HERE**
         STS,R5   *R1                ENTRY DELETED
         B         PRCNXT
* * * * * * * * * * * * * * * * * *
PRCRESLV LI,R5     0               **RESOLVE VALUE WORD**
         LW,R4     1,R1
         EXU       %RESOLVE-1,R3     SHIFT VALUE AS REQUIRED TO WA
         SLS,R5   -6                BYTE DISP
         MTW,0    LIBFLG            IF LIBRARY, SUBTRACT BIAS
         BEZ      %+2
         SW,R4    LOADBAS
         SLD,R4   8                 FORMAT 0AAAAA0B
         STW,R4    1,R1            **NEW VALUE**
         LI,R4     0
         STW,R4    2,R1            **RESOL = 0**
         LW,R4     0,R1              RESTORE CONTROL WORD TO R4
         B        *R11
* * * * * * * * * * * * * * * * * *
PRCDISPL LW,R3    TREEADR           DON'T MOVE DISPLACED DEFS TO
         LW,R4    -1,R3               HIGH CORE
         CI,R4    KC
         BLE      PRCEXIT
         LW,R3    CSEGADR           **CHK FOR ANY DISPL DEF'S**
         LW,R4     10,R3           **AND RETRIEVE IF ANY, ELSE EXIT**
         BEZ       PRCEXIT
         LW,R1     NXTDISP         R1 <--CURRENT DISPL DEF
         LW,R3     CSEGNO
         SLS,R3    2               R3 <--CURR SEG TREE DISPL *4
PRCDSP1  LW,R6     ENDRFDF           R2 <- NEXT AVAIL REF/DEF LOC
         LW,R8     0,R1              NEXT TREE POINTER FROM DEF
         AND,R8   XFFFC             TREE DISPL MASK
         LB,R2     *R1                 SIZE ENTRY
         CW,R8     R3
         BNE       PRCDSP2           NOT FROM CURRENT SEGMENT
         LW,R4     R1
         LW,R5     R6                  WA(NEXT RFDF LOC)
         AW,R5     R2
         CW,R5     NXTDISP
         BLE       PRCDSP3
         LI,R15    PRCDSP2
         B         PRCDSP4
PRCDSP3  EQU       %
         LW,R5    R2
         MOVE,R4  R5,R6
         AWM,R2    ENDRFDF             UPDATE ENDRFDF ADDR
PRCDSP2  AW,R1     R2                  UPDATE DISPL DEF POINTER
         CW,R1    HICORE               END OF DISPL DEFS
         BGE       PRCEXIT           YES
         B         PRCDSP1           NO
* * * * * * * * * * * * * * * * * *
PRCEXIT  EQU      %
         LW,R15   NXTDISP
         STW,R15  LMNSW
         PLW,R15  *R0
         B        *R15
PRCDSP4  EQU       %
PRCDSP5  EQU       %
         FILBUF,R6 BA(GOFM),0,24,BALLBUF
         FILBUF,R6 %R4,,*R2,BALLBUF+25 / PRINT DELETED DEF
        BAL,R11  WRTCLR
         B         *R15
         PAGE
**********************************
***** SORT AND CHAIN REF/DEF *****  BAL,R15  SORTMAP
***** STACK FOR DEF MAP      *****           NO ARGUMENTS
**********************************
*                                        1            2          3
*     REF/DEF ENTRY FORMATS |01234567|89|0|1|2345|67890123456789|0|1|
*     (AFTER PRE-PROCESSING | NO OF  |PT|A|F|TYPE| POINTER TO   |U|L|
*            BY 'PREPROC')  | WORKS  |RY|D|L|F,O,| PROPER TREE  |S|I|
*                           |  IN    |OP|E|A|1,2,|              |D|B|
*                           | ENTRY  |TE|F|G|3,6,|------------------|
*                                    |  | | |8   | DW SIZE OF C/DSEC|
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SORTMAP  EQU       %               **ENTER HERE**
         PSW,R15  *R0
         DO       MODE=1
DOVALSRT EQU      %
         FIN
         LI,R7     0
         STW,R7   MAPCHAIN          INITIALIZE CHAIN HEAD
         STW,R7    NSK
         LW,R7     LISK
         LW,R3    RFDFADR           FIRST ENTRY
         AI,R3    3                 POINT TO TEXT
SRTLOOP  LW,R6    -3,R3             LOOK AT NEXT ENTRY
         AND,R6   Y0037             TYPE MASK
         SCS,R6   16                MUST HAVE 0 OR 2 BITS
         BEV      SRTVALU           I.E.0,3,5,6,21,22,24
*                                   OF WHICH 0,3,6 ARE MEANINGFUL
SRTNXT   LW,R2    -3,R3             GET TO NEXT ENTRY
         LB,R2    R2
         AW,R3    R2
         CW,R3    ENDRFDF
         BLE      SRTLOOP
SRTEXIT0 SW,R7    LISK
         BEZ      SRTEXIT5          NOTHING TO DO
         STW,R7   NSK
         BAL,R15  SSSUBRV           SORT BY VALUE
         LW,SR2   Y0004             WEED OUT CSECTS
         LW,R2    NSK               WHILE CHAINING ENTRIES IN STACK
         LI,R5    MAPCHAIN-2
         LW,R6    LISK
         LW,R7    LISK
SRTXLP   LW,R4    0,R6              GET NEXT ENTRY
         STW,R4   0,R7              MOVE IT DOWN
         AI,R4    -3                MAKE RFDF POINTER
         STW,R4   2,R5
         LW,R5    R4
         CW,SR2   0,R4
         BANZ     %+2               REMOVE CSECTS
         AI,R7    1                 TO NEXT ENTRY
         AI,R6    1
         BDR,R2   SRTXLP
         LC       VAL%SW            IF NO NAME MAP, DONT SORT
         BCR,1    SRTEXIT5
         PLW,R15  *R0               GET SET TO RETURN
SRTEXIT2 RES
         SW,R7    LISK
         BE       *R15              NOTHING TO SORT
         STW,R7   NSK
         PSW,R15  *R0
         BAL,R15  SSSUBR            SORT BY NAME
SRTEXIT5 RES
         PLW,R15  *R0
         B        *R15
SRTVALU  RES
         AI,R7     1
         CW,R7    LMNSW        OUT OF CORE.
         BLE       SRTLNK1              NO
         AI,R7     -1
         LI,R5    SOFM
         CAL1,2   PRINT
         B        SRTEXIT0
SRTLNK1  EQU       %
         STW,R3   -1,R7
         B        SRTNXT
* * * * * * * * * * * * * * * * * *
         PAGE
********************************
***** LIST REF/DEF ENTRIES *****  BAL,R15  PSMALIST
***** SPECIFIED BY TYPE    *****           R2 <-- PSMA TYPE INDEX
********************************
*
*  NOTES: 1. PREF'S, SREF'S, DDEF'S, & ADEF'S ARE LISTED HERE
*         2. TYPE IS SPECIFIED IN R2 ON ENTRY
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
TXPREF TEXT 'A ******** PREF - PRIMARY REFERENCES NOT LOCATED  ********'
TXSREF TEXT 'A ******** SREF - SECONDARY REFERENCES NOT LOADED ********'
TXDDEF TEXT 'A ******** DDEF - DOUBLE/MULTIPLY DEFINED SYMBOLS ********'
TXADEF TEXT 'A ******** ADEF - ABSOLUTE SYMBOL VALUES          ********'
SZTITLE  EQU       58
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
TXTITLE  DATA      BA(TXDDEF),BA(TXSREF),BA(TXPREF)
         DATA     BA(TXADEF),BA(TXDEF)
         DATA      BA(TXSEC)
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
PSMATAB  DATA      X'00080000'     DDEF
         DATA     X'00010000'     SREF
         DATA     X'00020000'     PREF
         DATA      X'00200000'     ADEF
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
PSMALIST EQU       %               **THEY ALL COME IN HERE**
         PSW,R15  *R0
         PSW,R2   *R0
         LI,R3    0
         STW,R3   NSK
         LW,R7     LISK
         LW,R1     RFDFADR         R1  <--CURRENT ENTRY POINTER
         AI,R1    3                 DUMMY THE NAME ADDRESS
         LW,R12   PSMATAB-1,R2      GET REQUIRED TYPE
         LW,R13   Y002F             AND MASK
         BAL,R11  %+1
         CS,R12   -3,R1             IS THIS THE RIGHT TYPE
         BNE      PSMAGET           NO
         FILBUF,R4 (*TXTITLE-1,R2),0,SZTITLE,BALLBUF   /  TYPE HEADER
         BAL,R11   WRTCLR            WRITE HEADER
         LW,R7     LISK
         MTH,1    COLINDX           FORCE BLANK LINE
         LW,R12   PSMATAB-1,R2      RESTORE TYPE LOST IN FILBUF
         BAL,R11  %+3               ADD FIRST, SET RETURN
         CS,R12   -3,R1             CHECK NEXT ENTRY
         BNE      PSMAGET
         AI,R7     1
         CW,R7     NXTDISP         OUT OF CORE
         BLE       PSM1               NO
         AI,R7     -1
         LI,R5    SOFM
         CAL1,2   PRINT
         B        PSMAEXIT          ERROR EXIT ADDRESS
PSM1     EQU       %
         STW,R1    -1,R7
PSMAGET  LW,R3    -3,R1
         LB,R3    R3
         AW,R1     R3
         CW,R1     ENDRFDF
         BLE      *R11              NO, GET NEXT
* * * * * * * * * * * * * * * * * * *
PSMAEXIT EQU       %
         BAL,15    SRTEXIT2          PERFORM SORT
         BAL,15    MAPFIN3           PERFORM LISTING
         PLW,R2   *R0
         PLW,R15  *R0
         B        *R15
* * * * * * * * * * * * * * * * * *
         PAGE
******************************************
***** LIST LOAD MAP OR LIBRARY DEF'S *****  BAL,R15  MAPLIST
******************************************           NO ARGUMENTS
*
*  NOTES:    ROUTINE PRINTS THE APPROPRIATE HEADING AND THEN
*            FOLLOWS THE REF/DEF STACK CHAIN STARTING AT  *MAPCHAIN.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
TXDEF  TEXT  'A *******  DEF - PROGRAM DEFINITIONS MAP           ******'
TXRDEF  TEXT 'A *******  RELOCATABLE DEFINITIONS SORTED BY NAME  ******'
TXSEC   TEXT 'A *******  SECT - PROGRAM SECTIONS MAP             ******'
         DO       MODE=1
RDEF%MSG TEXTC    '*REF/DEF STACK CANNOT BE SHORTENED',;
                  ' ON A LIB LM* '
         FIN
         PAGE
MAPLISTV LC       VAL%SW            DO WE NEED VALLUE MAP
         BCR,2    *R15              NO
         LI,R6    0                 SORT DEFS BY VALUE
         BAL,R14  RMAP2
         B        MAPFIN1
MAPLISTN LC       VAL%SW            DO WE NEED NAME MAP
         BCR,1    *R15              NO
NMAP     LI,R6    1
         BAL,R14  RMAP2             MAP CONT SECTS BY VALUE
         B        MAPFIN4           THEN SORT NAMES AND MAP
RMAP2    EQU      %
         PSW,R15  *R0
         FILBUF,R4 (*TXTITLE+4,R6),0,SZTITLE,BALLBUF
RMAP1    EQU       %
         LI,R1    MAPCHAIN-2        R1 <--NEXT ENTRY POINTER
         BAL,R11   WRTCLR            WRITE HEADING (OR SECT TYPE 2)
         MTH,1    COLINDX           FORCE BLANK LINE
MAPLOOP  LW,R1    2,R1              NEXT ENTRY
         BEZ      MAPFIN            ALL DONE
         LW,R12    0,R1              GET TYPE
         AND,R12  Y0007
         BNEZ      MAPSEC
         CI,R14   NMAP              ONLY FIRST IF NAME MAP
         BL       %+4
         LW,R15   COLINDX
         SW,R15   COLSIZE
         BGZ      MAPLOOP
         BAL,R15   PROCNTRY          **PROCESS DEF (MOVE TO CUR BUFF)
         B         MAPLOOP
*
MAPSEC   RES
         BAL,R15   NUSECT            BUILD C/DSECT CHAIN
         B         MAPLOOP
* * * * * * * * * * * * * * * * * *
MAPFIN   EQU       %
         LW,R11   R14               SET RETURN
         B        WRTCLR            CLEAR THE BUFFER
MAPFIN4  EQU       %
         LW,R5     NSK
         BEZ       MAPFIN1
         FILBUF,R4 BA(TXRDEF),0,SZTITLE,BALLBUF
         BAL,R11   WRTCLR            WRITE SORTED BY NAME HEADING
         BAL,R11  WRTCLR            SKIP A LINE
         BAL,R15   MAPFIN3         PERFORM LISTING
MAPFIN1  EQU       %
         PLW,R15   *R0             GET LINK AND EXIT
         B         *R15
MAPFIN3  EQU       %
         LW,R4     LISK              GET TOURNAMENT AREA LOCATION
         LW,R5     NSK                  AND NUMBER OF SORT KEYS
         BEZ       *R15
         PSW,R15  *R0
MAPFIN2  EQU       %
         LW,R1     0,R4
         AI,R1     -3                COMPUTE INITIAL LOCATION DEF ENTRY
         BAL,R15   PROCNTRY        **PROCESS DEF (MOVE TO CURRENT BUFF)
         AI,R4     1
         BDR,R5    MAPFIN2
         BAL,R11  WRTCLR            SKIP A LINE
         PLW,R15  *R0
         B         *R15            EXIT
* * * * * * * * * * * * * * * * * *
         PAGE
************************************
***** START NEW CSEC/DSEC LINE *****  BAL,R15  NUSECT
***** FOR DEF MAP OR LDEF LIST *****           R1 <-- RFDF ENTRY ADDR
************************************           R2 <-- USER/LIBR/UNKN FLG
*                                                     =0   =1   =2
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
TXCSECT  TEXT     'CSECT'
TXDSECT  TEXT     'DSECT'
TXLDCB   TEXT     'LDCB '
TXPSECT  TEXT     'PSECT'
SECTYPS  DATA     X'6030B',X'E050000'
TXSZLN   TEXT     '-      WDS'
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SZADDR   EQU       5
SZRTHDG  EQU      10
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
BFLSCTAD EQU       BA(LLBUF)+1       LEFT SECTION ADDR
BFLSCTYP EQU       BA(LLBUF)+7       LEFT 'C' OR 'D' CHAR (SECTION)
BFLPROT  EQU       BA(LLBUF)+13      LEFT PROTECTION TYPE IND
BFRTHDG  EQU      BALLBUF+100       SECTION HEADING ON RIGHT OF PAGE
OBFRTHDG EQU      BA(LLBUF)+62
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
NUSECT   EQU       %
         LW,R3    0,R1
         PSW,R15  *R0
         BAL,R11  WRTCLR             PRINT PREVIOUS LINE
         AND,R3   Y000F
         LI,R4    5
         SLS,R3   -16
         CB,R3    SECTYPS,R4
         BE       %+2
         BDR,R4   %-2
         SLS,R4   3
         AI,R4    BA(TXCSECT)-8
         FILBUF,R4 *R4,,5,BFLSCTYP  /TYPE TO LEFT SIDE
         LW,R3     0,R1            **MOVE PROT TYPE TO LLBUF**
         AND,R3   Y00C              GET PT FROM CONTROL WORD
         SLS,R3   -22
         LB,R3     BNHX%TAB,R3
         LI,R4     BFLPROT
         STB,R3    0,R4              PT ON LS PAGE
* * * * * * * * * * * * * * * * * *
         LW,R7     1,R1            **ADDRESS VALUE TO LLBUF**
         SLS,R7   -8                SCRUB BTD
         BAL,R11   BINHEX
         BAL,R11   LJADDR            HEX ADDR IN R8R9
         FILBUF,R6 %R8,0,SZADDR,BFLSCTAD  /  TO LS PAGE
* * * * * * * * * * * * * * * * * *
         LW,R7     0,R1            **SECTION SIZE TO LLBUF**
         AND,R7   M16
         SLS,R7    1                 NO OF WORDS
         BAL,R11   BINHEX
         BAL,R11   LJADDR            HEX SIZE IN R8R9
         LI,R5    BFRTHDG            BATCH SIZE PLACE
         LC       VAL%SW
         BCR,8    NUSECT6
         LI,R5    OBFRTHDG          ONLINE SIZE PLACE
         LW,R11   COLSIZE           START NAMES IN LINE
         STW,R11  COLINDX           WITH THE REST
NUSECT6  RES
         FILBUF,R4 BA(TXSZLN),,SZRTHDG,*R5
         AI,R5    1-SZRTHDG         BACK TO AFTER DASH
         FILBUF,R4 %R8,,SZADDR,*R5  MOVE IN SIZE
* * * * * * * * * * * * * * * * * *
NUSECT7  EQU      %
         LW,R3     0,R1            **PROCESS AS CSEC OR DSEC**
         AND,R3   Y0007             TYPE FROM CONTROL WORD
         CW,R3    Y0006
         BE        NSEXIT            EXIT IF CSECT
         BAL,R15   PROCNTRY        **PROCESS SYMBOL IN DSECT ENTRY**
NSEXIT   PLW,R15  *R0
         B        *R15
         PAGE
***************************************
***** ENTER CURRENT REF/DEF IN LL *****  BAL,R15  PROCNTRY
***** BUFFER & WRITE IF FULL      *****           R1 <-- RFDF ENTRY ADDR
***************************************           R5-R7  VOLATILE
*
*                  REF/DEF VALUE = 0B0AAAAA       B = BYTE DISPL
*                                             AAAAA = WORD ADDR
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
PROCNTRY EQU       %
         PSW,R15  *R0
         LCI      5
         PSM,R1   *R0
         LI,R4     12
         LB,R4    *R1,R4            SYMBOL SIZE
         AW,R4    COLINDX           PLUS CURRENT DISP
         AI,R4    -110+9-1          MAX 110 FOR BATCH
         LC       VAL%SW
         BCR,8    %+2
         AI,R4    110-72            MAX FOR TERMINAL
         LI,R7    9
         LC       LLBUF,R7          IF SECT HEADING, DONT CLOBBER SIZE
         BCR,8    %+2
         AI,R4    11
         BIR,R4   %+2
         BAL,R11  WRTCLR            WONT FIT, START A NEW LINE
         LW,R4     0,R1            **CHECK ENTRY TYPE**
         LW,R7     R4
         AND,R7   Y0003
         CW,R7    Y0003             DSECT
         BE        %+3                  YES
         CW,R4    Y0007             R4 <-- RFDF ENTRY CONTROL WORD
         BANZ      PYEXIT            NO VALUE (PREF OR SREF)
         LW,R7     1,R1
         BAL,R11   BINHEX            R8R9 <-- HEX VALUE '0B0AAAAA'
         CW,R4    Y002              CHECK IF ABS
         BANZ     PYABS             YES, NO MESSAROUN
         AI,R9    -X'F000'          SET END OF ADDRESS FOR ABSVAL
PYABS    RES
         BAL,R11   ABSVAL            YES - CLEAR HI ORDER ZEROES
         OR,R9    TXBLNK            CLEAR BLANK
         LW,R3    COLINDX           WHERE TO START
         AI,R3    BALLBUF+1
         FILBUF,R2 %R8,,8,*R3        MOVE TO BUFFER
         CW,R4    Y0003
         BANZ     PYEXIT            DON'T FLAG IF A DSECT
         LI,R7     C'*'
         CI,R4    2
         BAZ      UNU%FLG
         LI,R7     C' '              USED FLAG
         CW,R4    Y001
         BAZ       %+2
         LI,R7     C'+'              DDEF FLAG
         CI,R4    1
         BAZ      %+2
         LI,R7    C'-'              MARK LIB DEF
         B        ST%FLG
UNU%FLG  EQU      %
         CI,R4    1            IS THIS UNUSED LIB DEF--
         BAZ      ST%FLG       NO
         LI,R7    C'@'         PLACE SYMBOL FOR LIB DEF--
ST%FLG   EQU      %
         AI,R3    1
         STB,R7   0,R3              MOVE TO BUFFER
* * * * * * * * * * * * * * * * * *
PYEXIT   LW,R3    COLINDX           MOVE  THE SYMBOL
         AI,R3    BALLBUF+1+10
         LW,R2    R1
         SLS,R2   2                 ITS ADDRESS(ALMOST)
         LB,R12   3,R2              ITS  SIZE
         FILBUF,R2 *R2,13,*R12,*R3
         SW,R3    COLINDX
         AI,R3    -BALLBUF-1        GET TOTAL ENTRY SIZE
         DW,R3    COLSIZE
         AI,R3    1                 ROUND UP
         MW,R3    COLSIZE
         AWM,R3   COLINDX
         LCI      5
         PLM,R1   *R0
         PLW,R15  *R0
         B        *R15               EXIT
COLSIZE  DATA     21
         PAGE
**************************************
***** BIN/HEX CONVERSION ROUTINE *****  BAL,R11  BINHEX
**************************************
*                                                R7 <-- DATA TO CONV (BIN)
*                                                R8 <-- 1ST HALF HEX
*                                                R9 <-- 2ND HALF HEX
*                                                R11<-- LINK
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
BNHX%TAB TEXT      '0123456789ABCDEF'
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
BINHEX   EQU       %
         LI,R5    -8
BNHX1    LI,R6     0               ** CONVERT DIGIT TO CHAR **
         SLD,R6    4
         LB,R6     BNHX%TAB,R6
         STB,R6    R10,R5
         BIR,R5    BNHX1
         B        *R11
********************************************
***** LEFT JUSTIFY BIN/HEX ADDR RESULT *****  BAL,R11  LJADDR
********************************************           R8R9 <-- HEX VALU
*                                                      R11  <-- LINK
*
LJADDR   SLD,R8    24              **ENTER HERE FOR  DEF OR DDEF**
ABSVAL   LI,R5    -8               **ENTER HERE FOR ADEF**
LJAD1    LB,R6     R10,R5
         BEZ      LJADDRX           END OF AN ADDRESS
         CI,R6     C'0'
         BNE      *R11
         LI,R6     C' '              REPLACE HIGH ZEROES WITH BLANKS
         STB,R6    R10,R5
         BIR,R5    LJAD1
LJADDRX  RES
         AI,R5    -1
         LI,R6    '0'
         STB,R6   R10,R5
         B        *R11
*********************************************
***** WRITE CONTENTS OF LLBUF AND CLEAR *****
*********************************************
*                                    BAL,R11  WRTCLR
*                                             NO ARGUMENTS
WRTCLR   EQU       %
         CAL1,1   WRTLL
CLRBUF   LI,R7    15
         STW,R7   COLINDX           RESET COLINDX
         LW,R9    TXBLNK
         STD,R9   LLBUF-1,R7
         BDR,R7   %-1
         STW,R9   LLBUF
         LC       VAL%SW            IF TERMINAL, START AT ZERO
         BCR,8    %+2
         STW,R7   COLINDX
         B        *R11
WRTLL    GEN,8,24 X'11',M:LL
         DATA     X'34000010',LLBUF,112,0
*
*
WRTCLRO  EQU      %
         LC       VAL%SW
         BCR,8    WRTCLR            YEP
         CAL1,1   WRTLLO            WRITE LESS OF BUFFER TO UC
         B        CLRBUF
WRTLLO   GEN,8,24 X'11',M:LL
         DATA     X'34000010',LLBUF+3,72,3
         PAGE
****************************************
***** SEGMENT SUMMARY CALCULATIONS *****  BAL,R15  SEGEVAL
****************************************           R1 <--CURRENT SEG ADR
*
*  HI & LO BOUNDARIES FOR EACH PROT TYPE & PROT TYPE SIZES
*  ARE EVALUATED AND STORED IN TSTACK
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SEGEVAL  EQU       %               **ENTERS HERE**
         LI,R2     9                 10 POINTER
         LI,R3     3                 STORE HEX INDEX
SGLNXT   LW,R4    *CSEGADR,R2       SIZE AND BASE ADDR
         INT,R13   R4                LO BOUND IN R13
         SLS,R4   -16
         CI,R4    0
         BEZ       SGLZERO
         SLS,R4    1                 SIZE IN WORDS
         SLS,R13   1                 DA(LO BOUND)
         LW,R7     R13
         AW,R7     R4
         AI,R7    -1                 HI BOUND IN R7
SEGSTOR  MTW,0    CSEGNO
         BNE      SEG1
         CI,R3    1
         BG       SEG1
         LW,R13   LOADBAS
         LW,R4    R7
         SW,R4    R13
         BEZ      SEG1
         AI,R4    1
SEG1     STW,R7   SEGHI-1,R3        SAVE HI BOUND.
         STW,R13  SEGLO-1,R3        SAVE LO BOUND
         STW,R4   SEGSZ-1,R3        SAVE SIZE
         AI,R2    -2
         BDR,R3    SGLNXT          **PROCESS NEXT PROT TYPE**
         B        *R15
* * * * * * * * * * * * * * * * * *
SGLZERO  SLS,R13  1                 MAKE WORD ADDRESS
         LW,R7    R13               HI BOUND = LO BOUND
         B        SEG1
* * * * * * * * * * * * * * * * * *
         PAGE
*********************************************
*****MOVE REQUESTED SUMMARY TO LL BUFFER*****  BAL,R1  VALMOVE
*********************************************          R5 <-- LINE INDEX
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
BFSGDATA DATA     BA(LLBUF)+8,BA(LLBUF)+20,BA(LLBUF)+32
TXSGINFO DATA      WA(SEGSZ),WA(SEGLO),WA(SEGHI)
TXHDG567 DATA      BA(TXSZLN7),BA(TXLOLN6),BA(TXHILN5)
SZH567   EQU      8
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
VALMOVE  EQU       %               **ENTER HERE**
         PSW,R11  *R0
         FILBUF,R4 (*TXHDG567-1,R2),,SZH567,BALLBUF
         LI,R1    3
         LW,R15   TXSGINFO-1,R2
         AI,R15   -1
VMNEXT   LW,R7    *R15,R1
         MTW,0    SEGSZ-1,R1        IF NO SIZE, NOTHING ELSE
         BEZ      VMNXT
         BAL,R11  BINHEX
         BAL,R11  LJADDR
         FILBUF,R4 %R8,,5,(*BFSGDATA-1,R1)  /     MOVE TO LLBUF
VMNXT    RES
         BDR,R1   VMNEXT            DO NEXT PROT. TYPE
         PLW,R11  *R0
         B        *R11               EXIT
* * * * * * * * * * * * * * * * * *
         PAGE
******************************************************************
*  SHELL SORT SUBROUTINE
*     CALLING SEQUENCE
*      BAL,R15 SSSUBR
*        WHERE
*LISK  EQU    INITIAL LOCATION - TOURNAMENT AREA
*NSK   EQU    NUMBER OF SORT KEYS
SSSUBRV  LI,SR2   0                 FORCE VALUE SORT
         B        %+3
SSSUBR    EQU       %
         LW,SR2   LOCWD             DO VALUE SORT IF NONAME TYPE
         SLS,SR2  11
         PSW,D4   *R0
         DO1      MODE=0
         LW,D4    M24
         LW,SR3   NSK                N TO M
          BEZ       SSSXIT           EXIT, N = 0
SSR3      EQU       %
          SLS,SR3  -1                 M/2 TO M
         AI,SR3   0
         BE       SSSXIT            EXIT - SORT FINISHED
         LW,SR4   NSK                N - M TO K
          SW,SR4    SR3
         LW,R3    LISK              1 TO J
         AW,SR4   LISK              K RELATIVE  TO J
SSR4      EQU       %
          LW,R1     R3                  J TO I
SSR2      EQU       %
          LW,R2     R1
          AW,R2     SR3                 I + M
         LW,R6    0,R1
         LW,R7    0,R2
         BIR,SR2  SSR7              SKIP VALUE TEST IIF NAME SORT
         LW,D3    -2,R6
         CW,D3    -2,R7
         BG       SSR5
         BL       SSR1
         LI,D3    X'10000'          PUT DSECTS BEFORE DEFS
         CW,D3    -3,R6
         BANZ     SSR1
         CW,D3    -3,R7
         BANZ     SSR5
SSR7     RES
         DO       MODE=1
         SLD,R6   2
         OR,R7    YFF000001
         CBS,R6   1
         ELSE
         LW,D3    0,R6
         CS,D3    0,R7              COMPARE FIRST 3 CHARACTERS
         BG       SSR5
         BL       SSR1
SSR6     LI,D4    -1                NEXT COMPARES ARE FOUR CHARS
         AI,R6    1
         AI,R7    1
         LW,D3    0,R6
         CS,D3    0,R7
         LW,D4    M24               RESTORE MASK
         FIN
         BL       SSR1
         DO1      MODE=0
         BE       SSR6
         LW,R6    0,R1              RESTORE R6
SSR5     XW,R6    0,R2
         STW,R6   0,R1
          SW,R1     SR3                 I - M TO I
         CW,R1    LISK
         BGE      SSR2              I > 0
SSR1      EQU       %
         AI,R3     1               J + 1 TO J
          CW,R3     SR4
         BL       SSR4              MORE LITTLE LOOP
         B        SSR3
SSSXIT    EQU       %
         PLW,D4   *R0
         B        *D4
Y003     DATA     X'00300000'
YFFCFFFFF DATA    X'FFCFFFFF'
VAL%DEL  DATA     X'FF1FFFFF'
XFFFC    DATA     X'0000FFFC'
Y003F    DATA     X'003F0000'
Y0037    DATA     X'370000'
YFF000001 DATA    X'FF000001'
Y002F    DATA     X'002F0000'
Y04      DATA     X'04000000'
D1024    DATA     X'400'
D103     DATA     X'67'
D10      DATA     X'A'
         END
