***********************************************************************
*M*      TREER    PROCESSES THE TREE AND PTREE CONTROL COMMANDS
***********************************************************************
*
*P*      NAME:    TREER
*P*
*P*      PURPOSE: TO PROCESS THE TREE AND PTREE CONTROL COMMANDS
*P*
*P*      DESCRIPTION: SEE FUNCTION PREAMBLES FOR TREER AND PTREER
*P*
*P*      REFERENCE: BATCH PROCESSING REFERENCE MANUAL
*P*                 DATA BASE TECHNICAL MANUAL
*P*
       CSECT       1
         SYSTEM   SIG7FDP
       PAGE
*                 SYMBOLIC REGISTER DEF'S.
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
SR1      EQU      8
SR2      EQU      9
SR3      EQU      10
SR4      EQU      11
D1       EQU      12
D2       EQU      13
D3       EQU      14
D4       EQU      15
         PAGE
*                 CHANGE STACK POINTER AMOUNT SPEC. BY 1ST ARGUMENT.
*                 SECOND ARGUMENT SPEC. AVAILABLE REGISTER.
BUMP     CNAME
         PROC
LF       LI,AF(2) AF(1)
         MSP,AF(2)  TSTACK
         PEND
*                 PUSH OR PULL N WORDS SPECIFIED BY 1ST ARGUMENT INTO
*                 REG'S STARTING AT 2ND ARGUMENT.
PUSH     CNAME    X'9',X'B'
PULL     CNAME    X'8',X'A'
         PROC
         DO       NUM(AF)=1
LF       GEN,1,7,4,3,17 0,NAME(1),AF(1),0,TSTACK
         ELSE
         DO       AF(1)=1
LF       GEN,1,7,4,3,17  0,NAME(1),AF(2),0,TSTACK
         ELSE
         DO       AF(1)=16
LF       LCI      0
         ELSE
LF       LCI      AF(1)
         FIN
         GEN,1,7,4,3,17  0,NAME(2),AF(2),0,TSTACK
         FIN
         FIN
         PEND
         PAGE
         DEF      TREER             ENTRY POINT TO MODULE FOR PROCESSING
*,*                                 TREE COMMAND
         DEF      PTREER            ENTRY POINT TO MODULE FOR PROCESSING
*,*                                 PTREE COMMAND
         REF      ALOCCT            INPUT-LOCCT ADDRESS TO CREATE TREE
*,*                                 TABLES
         REF      CHARSCAN          GET NEXT ACTIVE CHARACTER FROM CONTROL
*,*                                 COMMAND COMPARE
         REF      BLNKERCD          ERROR CODE CONSTANT
         REF      SYNTXER           ERROR CODE CONSTANT
         REF      ILCHERCD          ERROR CODE CONSTANT
         REF      TSTACK            INPUT/OUTPUT-PRESERVE REGISTERS
         REF      NAMSCAN           GET NAME FROM COMMAND
         REF      CSL               INPUT-OBTAIN LENGTH OF LAST
*,*                                 CHARACTER STRING SCANNED
         REF      PLB               INPUT-USED TO HOLD MOST RECENT
*,*                                 CHARACTER STRING SCANNED
         REF      CHSTSHFT          SHIFT CHARACTER STRING AND INSERT
*,*                                 BYTE COUNT
         REF      NOPGERR           ERROR CODE CONSTANT
         REF      X1FF              CONSTANT
         REF      X1FFFF            CONSTANT
         REF      ROMTADR           INPUT-VERIFY THE MODULE SPECIFIED ON
*,*                                 TREE EXISTS IN ROM TABLE
*,*                                 INPUT-BASE ADDRESS OF ROM TABLE
*,*                                 OUTPUT-LINK IN WORD 7 OF ROM TABLE
*,*                                 ENTRIES WHICH CONTAINS THE NAME OF
*,*                                 THE NEXT ROM IN SEGMENT
         REF      TREETADR          INPUT-BASE ADDRESS OF TREE TABLE
*,*                                 USED TO RETAIN MODULES SPECIFIED
         REF      SEGNAME           EQU; RELATIVE POSITION OF SEGMENT
*,*                                 NAME IN TREE ENTRY
         REF      LINK1STROM        EQU; RELATIVE POSITION IN TREE ENTRY
*,*                                 OF ROM LINK
         REF      LSTROMLINK        EQU; RELATIVE POSITION IN TREE ENTRY
*,*                                 OF LAST ROM LINK
         REF      TTESIZE           EQU; TREE TABLE ENTRY SIZE
         REF      LINKNEXTROM       EQU; RELATIVE POSITION IN ROM ENTRY
*,*                                 OF ROM LINK
         REF      ROMTESIZE         EQU; ROM TABLE ENTRY SIZE
         REF      EOCCSCAN          SCAN TO END OF CONTROL COMMAND
         REF      CJOB              INPUT-JIT ADDRESS
         REF      SCCLF             SET LIST FLAG FOR LL DEVICE
         REF      GETACCN           GET ACCOUNT SPECIFIED ON PTREE
*,*                                 COMMAND
         REF      GETPASSW          GET PASSWORD SOECIFIED ON PTREE
*,*                                 COMMAND
         REF      M:X1              DCB USED FOR READING FILE CONTAINING
*,*                                 TREE COMMAND
         REF      CONTR             EQU; OFFSET INTO PARAMETER TABLE TO
*,*                                 STORE ADDRESS OF READ CONTINUATION
*,*                                 ROUTINE FOR PTREE PROCESSING
         REF      CCP               EQU; OFFSET INTO PARAMETER TABLE
*,*                                 TO SET CURRENT CHARACTER POSITION
         REF      OUTR              EQU; OFFSET INTO PARAMETER TABLE FOR
*,*                                 ADDRESS TO LIST PTREE COMMAND
         REF      CCRSZ             EQU; OFFSET INTO PARAMETER TABLE FOR
*,*                                 RETAINING RECORD SIZE
         REF      CREAD             INPUT-CONTINUATION READ ROUTINE
*,*                                 ADDRESS
         REF      CCLIST            INPUT-OUTPUT ROUTINE ADDRESS
         REF      ACCBUF            EQU; OFFSET INTO JIT FOR J:CCBUF
         REF      CBUF              EQU; OFFSET INTO PARAMETER TABLE
*,*                                 CONTAINING BUFFER ADDRESS USED FOR
*,*                                 READING TREE COMMAND FROM FILE
         REF      Y002              CONSTANT
         REF      RUNFLAG           EQU; DISPLACEMENT IN JIT FOR RUN
*,*                                 FLAG
         REF      Y08               CONSTANT
         REF      Y0C               CONSTANT
         REF      CHTBL             OUTPUT-INCLUDE AND EXCLUDE HYPHEN
*,*                                 IN THE LIST OF LEGAL ALPHANUMERIC
*,*                                 CHARACTERS
         REF      PCCP              EQU; OFFSET INTO PARAMETER TABLE FOR
*,*                                 PREVIOUS CHARACTER POSITION IN
*,*                                 COMMAND BUFFER
         REF      OPNF              OPEN FILE SPECIFIED ON PTREE COMMAND
         REF      ILSEGNCD          ERROR CODE CONSTANT
         REF      YFFFF             MASK
         REF      DUPSEGCD          ERROR CODE CONSTANT
         REF      SERRLF            SET ERROR LISTING FLAGS FOR LOGICAL
*,*                                 DEVICES BEFORE OUTPUTTING ERROR
*,*                                 MESSAGE
         REF      ERRLIST           LIST ERROR MESSAGES BEFORE OUTPUTTING
*,*                                 ERRONEOUS SEGMENT OR ROM NAME
         REF      NOROMCD           ERROR CODE CONSTANT
         PAGE
K0            EQU X'0'
K1            EQU X'1'
K3            EQU X'3'
K6       EQU      X'6'
K8       EQU      X'8'
K10           EQU X'10'
KN1           EQU -X'1'
KBLANK        EQU ' '
KCOMMA        EQU ','
KHYPEN        EQU '-'
KLPAREN       EQU '('
KRPAREN       EQU ')'
BACKLINK      EQU 3
SUBLINK       EQU 4
OVLYLINK      EQU 4
LASTROMLINK EQU   LSTROMLINK
ROMTSIZE EQU      ROMTADR
ARS      EQU      4                                                     741
         PAGE
*F*
*F*      NAME:    TREER
*F*
*F*      PURPOSE: TO PROCESS THE TREE CONTROL COMMAND
*F*
*F*      DESCRIPTION: TREER IS CALLED BY CCIR WHENEVER A TREE CONTROL
*F*               COMMAND IS ENCOUNTERED. THE TREE CONTROL COMMAND IS
*F*               PROCESSED AND OUTPUT ON THE LL DEVICE. INFORMATION
*F*               FROM THE TREE COMMAND IS USED TO GENERATE TREE TABLES
*F*               IN THE LOCCT FOR USE BY THE LOADER. THE TREE TABLES
*F*               REPRESENT THE RELATIONSHIP OF THE SEGMENTS THAT
*F*               COMPRISE AN OVERLAY. UPON COMPLETITION OF PROCESSING
*F*               THE COMMAND, CONTROL IS RETURNED TO CCIR WHICH EXITS
*F*               TO THE LOADER OR LOCCT PROCESSOR.
*F*
*F*      REFERENCE: BATCH PROCESSING REFERENCE MANUAL
*F*                 DATA BASE TECHNICAL MANUAL
*F*
**********************************************************************
*        TREER    PROCESS TREE CONTROL COMMAND                       *
*        ENTER WITH                                                  *
*                 (R5) =  JIT POINTER                                *
*                 (R7) =  ADR OF PARAM LIST                          *
*                 (SR1)= CUR CHAR OR ZERO                            *
*                                                                    *
*                                                                    *
*                                                                    *
**********************************************************************
TREER    EQU      %
         PUSH     SR4
         MTB,1    *R7               MAKE HYPHEN A DELIMITER
         LI,SR4   0
         LI,R1    KHYPEN            ELIMINATE HYPHEN AS A LEGAL
         STB,SR4  CHTBL,R1          ALPHA. CHARACTER
         CI,SR1   KBLANK            CHECK FOR BLANK FOLLOWING COMMAND
         BNE      TREER5            ERROR IF NO BLANK             WORD
         LI,R4    2
         BAL,SR4  SCCLF
         LW,R4    ALOCCT,R5
         LW,D1    ROMTADR,R4        (D1) = BASE ADR OF ROMT
         AND,D1   X1FFFF
         LW,D2    TREETADR,R4       (D2) = BASE ADR OF TREE TABLE
         LW,D3    ROMTSIZE,R4
         SLS,D3   -17
         AW,D3    D1                (D3) = END ADR OF ROMT
         LI,R1    K1
         STW,R1   *D2               SET TREE TABLE HEAD POINTER = 1
         AW,R1    D2                (R1) = ADR OF CUR TREE TABLE ENTRY
         LI,R3    K0                ZER OUT LAST WORD FOR
         LI,R2    R7                EACH ROM ENTRY IN THE
         AW,R2    D1                ROM TABLE. (8TH WORD)
ZERROMT  STW,R3   *R2
         AI,R2    K8
         CW,R2    D3
         BL       ZERROMT
         LI,R2    K0
         STW,R2   BACKLINK,R1       SET LINKS IN
         STW,R2   SUBLINK,R1                    CUR TREE
         STW,R2   LSTROMLINK,R1                        TABLE =0
TREER1   EQU      %
         BAL,SR4  GETROMNAME        GET ROM NAME FROM TREE CC
         B        TREER7            ILLEGAL ROM NAME
         PUSH     8,D1
         LI,SR2   KHYPEN
         BAL,SR4  CHARSCAN          CHECK FOR HYPEN FOLLOWING ROM NAME
         BCS,8    TREER6            ERROR IF NO HYPEN
         LI,SR2   KLPAREN
         BAL,SR4  CHARSCAN          CHECK FOR LEFT PAREN FOLLOWING
         BCR,8    TREER2                                    THE HYPEN
         PULL     8,D1
         B        TREER1            GET NEXT ROM NAME
*
TREER2   EQU      %
         PULL     8,D1
         LI,R0    K0                SET ENTRY COUNT = 0
         BAL,SR4  RTR               GO TO RECURSIVE TREE ROUTINE
         B        TREER7            TREE CC ERROR
TREER4   EQU      %
         LI,R2    TTESIZE
         AI,R2    -1
         AWM,R2   *D2
         LI,SR2   '.'
         BAL,SR4  CHARSCAN
         BCR,8    TREER4A
         CI,SR1   X'26'
         BE       TREER4A
         CI,SR1   X'15'
         BNE      TREER6A
TREER4A  EQU      %
         PUSH     D3                SAVE ROMT END ADDRESS
         BAL,SR4  EOCCSCAN
*
         PULL     D3                INDICATE AN ERROR IF ROM ON LOAD CC
         LW,R1    D1                NOT INCLUDED IN TREE
         AI,R1    -1
TREER4B  EQU      %
         AI,R1    8                 CHECK LAST WORD IN EACH ROM TABLE
         CW,R1    D3                WHICH INDICATES IF ROM WAS USED
         BGE      TREER4C
         LH,R2    *R1               HAS ROM BEEN POINTED TO
         BNEZ     TREER4B           YES
         PUSH     R1                NO
         LI,R4    X'12'             SET ERROR LIST FLAGS
         BAL,SR4  SERRLF
*E*      MESSAGE: ROM IN EF LIST NOT SPECIFIED IN TREE
         LI,SR3   NOROMCD
         BAL,SR4  ERRLIST           OUTPUT ERROR MESSAGE
         PULL     SR3               PUT ROM ADDRESS IN SR3
         AI,SR3   -7
         B        TREER7            ABORT
*
TREER4C  EQU      %
         LW,R1    *D2
         CI,R1    11                SI TREE 1 SEG LONK;G
         BLE      NORMEX            I.E. !TREE A-B-C
         PUSH     2,R5
         AW,R1    D2
         AI,D2    1
         LW,R3    D2                R3=PTR TO ROOT NAME
         LW,D2    R1
         AI,D2    -10               D2=PTR TO LAST SEG
*                                   NAME IN TREE TABLE
NXSGNM1  LW,R4    R3                R3=PTR TO SEG NAME
*
         AI,R4    11                FIXED DURING SEARCH
NXSGNM2  LB,R5    *R3               R5=TEXTC OF FIX NAME
         CB,R5    *R4
         BNE      NXTRNAM           IF TECTX SIZES NOT=
*                                   SKIP TO NEXT SUBS. NAME
         AI,R5    -1                SKIP ZEROED BYTE
NXTCHAR  LB,R6    *R3,R5            IF SIZES=, CKH CAHR
         CB,R6    *R4,R5
         BNE      NXTRNAM           IF NOT = CONTINU
         BDR,R5   NXTCHAR
         PULL     2,R5
         PUSH     R4                SAVE SEGMENT ADDRESS
         LI,R4    X'12'             SET ERROR LIST FLAGS
         BAL,SR4  SERRLF
*E*      MESSAGE: DUPLICATE SEGMENT NAMES
         LI,SR3   DUPSEGCD
         BAL,SR4  ERRLIST           LIST ERROR MESSAGE
         PULL     SR3               PUT SEGMENT ADDRESS IN SR3
         MTB,-1   *SR3              NAME TO BE OUTPUT BEFORE ABORTING
         B        TREER7
NXTRNAM  AI,R4    11
         CW,R4    R1
         BLE      NXSGNM2
*
         AI,R3    11
         CW,R3    D2
         BL       NXSGNM1
NMOREX   PULL     2,R5
NORMEX   EQU      %
         PULL     SR4
         AI,SR4   K1
         B        TREER7A           NORMAL EXIT
*
TREER5   EQU      %
*E*      MESSAGE: EXPECTED BLANK MISSING
         LI,SR3   BLNKERCD
         B        TREER7
TREER6   EQU      %
         PULL     8,D1
         CI,SR1   '.'
         BE       TREER4
         CI,SR1   X'26'
         BE       TREER4
         CI,SR1   X'15'
         BE       TREER4
TREER6A  EQU      %
         LI,SR3   SYNTXER
TREER7   EQU      %
         PULL     SR4
         LI,R4    2
TREER7A  EQU      %
         PUSH     SR4
         MTB,-1   *R7               ELIMINATE HYPHEN AS A DELIMITER
         LI,SR4   3
         LI,R1    KHYPEN            MAKE HYPHEN A LEGAL ALPHA.
         STB,SR4  CHTBL,R1          CHARACTER
         PULL     SR4
         B        *SR4              RETURN
         PAGE
**********************************************************************
*        RTR      RECURSIVE TREE  ROUTINE                            *
*                 BUILDS ALL ENTRIES IN TREE TABLE EXCEPT FOR        *
*                 ROOT SEGMENT.                                      *
*                 ROUTINE IS CALLED WHEN LEFT PAREN IS ENCOUNTERED.  *
*                 ROUTINE IS EXITED WHEN RIGHT PAREN OR ERROR        *
*                 IS ENCOUNTERED.                                    *
*        ENTER WITH                                                  *
*                 (R0) =  RTR IN COUNT                               *
*                 (R1) =  ADR OF CURRENT TREE TABLE ENTRY            *
*                 (R2) =  ADR OF CUR BACK LINK TREE TABLE ENTRY      *
*                 (R3) =  ADR OF CUR OVERLAY LINK TREE TABLE ENTRY   *
*                 (D1) =  BASE ADR  OF ROMT                          *
*                 (D2) =  BASE ADR OF TREE  TABLE                    *
*                 (D3)  =  END ADR OF ROMT                           *
*                                                                    *
**********************************************************************
RTR      EQU      %
         PUSH     SR4
         PUSH     8,D1
         LI,SR2   KLPAREN
         BAL,SR4  CHARSCAN          CHECK FOR REDUNDANT LEFT PAREN
         BCR,8    RTR7              SYNTAX ERROR
         PULL     8,D1
         STW,R1   R2                (R2) = ADR OF CUR BACK LINK TTE
         LI,R4    TTESIZE
         AWM,R4   *D2
         LW,R1    *D2               (R1) = ADR OF CUR TREE TABLE ENTRY
         AW,R1    D2
         STW,R1   D4                                           (ACTTE)
         SW,D4    D2                STORE ACTTE
         AI,D4    KN1
         SLS,D4   K10                          INTO
         STS,D4   SUBLINK,R2                     SUBLINK OF BACK LINK
RTR1     EQU      %
         LI,R0    K0                SET
         STW,R0   BACKLINK,R1          LINKS
         STW,R0   SUBLINK,R1                IN
         STW,R0   LASTROMLINK,R1              CTTE(CUR TREE TABLE ENTRY)
         STW,R2   D4
         SW,D4    D2
         AI,D4    KN1
         STS,D4   BACKLINK,R1       SET BACK LINK IN  CTTE
*
RTR2     EQU      %
         BAL,SR4  GETROMNAME        GET ROM  NAME
         B        RTR10             ILLEGAL ROM NAME
         PUSH     8,D1
         LI,SR2   KHYPEN
         BAL,SR4  CHARSCAN          CHECK FOR HYPEN AFTER ROM NAME
         BCS,8    RTR6
         LI,SR2   KLPAREN
         BAL,SR4  CHARSCAN          CHECK FOR LEFT PAREN AFTER HYPEN
         BCR,8    RTR5
         PULL     8,D1
         B        RTR2              GET NEXT ROM NAME IN SEGMENT
*
RTR5     EQU      %
         PULL     8,D1
         PUSH     3,R1
         BAL,SR4  RTR               ENTER RECURSIVE TREE ROUTINE
         B        RTR9
         PULL     3,R1
         PUSH     8,D1
RTR6     EQU      %
         LI,SR2   KRPAREN
         BAL,SR4  CHARSCAN          CHECK FOR RIGHT PAREN
         BCR,8    RTR4              BRANCH IF RIGHT PAREN
         LI,SR2   KCOMMA
         BAL,SR4  CHARSCAN          CHECK FOR COMMA
         BCS,8    RTR8              BRANCH IF NOT COMMA
         PULL     8,D1
         STW,R1   R3                SET OVLAY LINK = ACTTE
         LI,R4    TTESIZE
         AWM,R4   *D2
         LW,R1    *D2
         STW,R1   D4
         AI,D4    KN1
         AW,R1    D2
         STS,D4   OVLYLINK,R3       STORE ACTTE INTO OVERLAY TTE
         B        RTR1
*
*
*
RTR4     EQU      %
         PULL     8,D1
         PULL     SR4
         AI,SR4   K1
         B        *SR4              EXIT
RTR7     EQU      %
*E*      MESSAGE: SYNTAX ERROR
         LI,SR3   SYNTXER           (SR3) = SYNTAX ERROR
         PULL     8,D1
         B        RTR10
RTR8     EQU      %
*E*      MESSAGE: ILLEGAL CHARACTER
*E*      DESCRIPTION: A CHARACTER OTHER THAN A COMMA, HYPHEN, OR
*E*               RIGHT PARENTHESIS FOLLOWED THE ELEMENT FILE
*E*               SPECIFIED ON THE TREE CONTROL COMMAND.
         LI,SR3   ILCHERCD          (SR3) = ILLEGAL CHAR CODE
         PULL     8,D1
         B        RTR10
RTR9     EQU      %
         BUMP     -3,R1
RTR10    EQU      %
         PULL     SR4
         B        *SR4              ERROR EXIT
         PAGE
**********************************************************************
*        GETROMNAME - GETS ROM NAME FROM TREE CC, SEARCHS ROMT       *
*                 FOR THE NAME. IF FOUND, LINKS NAME TO OTHER        *
*                 ROM'S IN SEGMENT AND STORES NAME IN CTTE           *
*                 IF FIRST ROM IN SEGMENT                            *
*                                                                    *
*                                                                    *
*                                                                    *
**********************************************************************
GETROMNAME EQU    %
         PUSH     5,R2
         PUSH     7,SR4
         BAL,SR4  NAMSCAN           GET NAME FROM CC
         BCS,8    GETROMNAME6       BRANCH IF ILLEGAL ALPHANUMERIC
         LW,R1    CSL,R7
         CI,R1    K10               CHECK IF <=10 CHAR
         BG       GETROMNAME6
         LW,R0    R7
         AI,R0    PLB
         LI,R2    K1
         BAL,SR4  CHSTSHFT          INSERT BYTE COUNT
         PULL     7,SR4
*
         LW,R3    R1                CHECK IF ROOM FOR 2 ENTRIES IN PAGE
         AI,R3    22
         AND,R3   X1FF
         CI,R3    20                IS MORE CORE NEEDED FOR CTTE
         BG       GETRMNM0A         NO
         PUSH,2   SR1
         LI,R3    1                 YES, GET ANOTHER PAGE
         OR,R3    Y08
         CAL1,8   3
         BCS,8    GETROMNAME8       DID WE GET ONE
         PULL,2   SR1               YES
GETRMNM0A EQU     %
         LW,R3    D1
         LI,R4    PLB
         AW,R4    R7
*
GETROMNAME1 EQU   %
         LB,R5    *R3
         CB,R5    *R4               COMPARE LENGTHS
         BNE      GETROMNAME5
*
GETROMNAME2 EQU   %
         LB,R6    *R3,R5
         CB,R6    *R4,R5            COMPARE NAME'S
         BNE      GETROMNAME5
         BDR,R5   GETROMNAME2
         SW,R3    D1
         AI,R3    1
         STW,R3   R5
         XW,R3    LSTROMLINK,R1     UPDATE LINK TO LAST ROM IN CTTE
         BNEZ     GETROMNAME4       CHECK IF 1ST ROM IN SEG
         PUSH     3,R3
         SLS,R5   K10
         STS,R5   LINK1STROM,R1
         LCI      K3
         LM,R4    PLB,R7
         STM,R4   SEGNAME,R1        STORE NAME IN CTTE
         LW,R4    R1
         AI,R4    SEGNAME
         MTB,1    *R4               INCREMENT SEGNAME BYTE COUNT
         LB,R5    *R4
         LI,R6    K0
         STB,R6   *R4,R5            SET LAST BYTE = 0
         PULL     3,R3
*
GETROMNAME4 EQU   %
         LI,R6    K1                R%=DISP+1 OF FOUND ROM
         LW,R2    R5                    IN ROM TABLE
         AI,R2    K6                D1-ADDRESS OF START OF ROM TABLE
         AW,R2    D1
         CH,R6    *R2               LOOK IN LEFT HALF FOR
         BLE      CHKON             THE POINTER-TO FLAG
*                                   FLAG=0 NEVER B4 PTD-TO
*                                       =1 PTD-TO 1-TIME B4
*                                       =2 PTD-TO AND MOVED
         STH,R6   *2
GETRMNM4A EQU     %
         CI,R3    0                 IF THIS IS THE FIRST ROM IN SEGMENT,
         BE       GETROMNAME4C      DON'T SET LINK TO NEXT ROM
         AI,R3    -1
         AW,R3    D1
         OR,R5    LINKNEXTROM,R3
         STW,R5   LINKNEXTROM,R3
GETROMNAME4C EQU  %
         AI,SR4   K1
         PULL     5,R2
         B        *SR4
*
CHKON    AI,R6    K1
         CH,R6    *R2
         BG       MOVROMEN
         XW,R3    LSTROMLINK,R1
         AI,R3    KN1
         AW,R3    D1                CONTINUE ROMT SEARCH
GETROMNAME5 EQU   %
         AI,R3    ROMTESIZE
         CW,R3    D3                CHECK IF END OF ROMT
         BL       GETROMNAME1
         B        GETROMNAME7
MOVROMEN LW,R6    CJOB
         LW,R4    ALOCCT,R6
         AI,R4    ROMTADR
         PUSH     12,R0
         LW,R1    *R4               ARE WE OUT OF COMMON
         AND,R1   X1FF
         BNEZ     MOVROM5           NO
         LI,R1    1                 YES, GET ANOTHER PAGE
         OR,R1    Y0C
         CAL1,8   1
         BCS,8    GETROMNAME10      DID WE GET ONE
MOVROM5  EQU      %
         LW,R0    *R4
         SLD,R0   -17               ADDRESS IN RT 17 BITS
*
*                                   R5=CURRENT SIZE
         LW,R5    R0
         AI,R0    K8
*
         SLD,R0   17                SINCE ROM IN BUILT
         AI,R0    -8                FROM  UPPER CORE DOWN
*                                   ADJUST OLD ADDRESS IN
*                                   LOCCT TO ACCOMMODATE
*                                   ANOTHER ROM ENTER
         STW,R0   *R4               STORE NEW ROM INFO BACK
*                                   INTO LOCCT
         AND,R0   X1FFFF
         LW,R1    R0                R1=NEW ROMT START AD
MUVLOOP  LW,R4    *D1               MOVE OLD ROMTABLE DOWN
         STW,R4   *R1               BY 8 TO MAKE ROOM FOR
         AI,D1    K1                NEW 8-WORD ENTRY
         AI,R1    K1
         BDR,R5   MUVLOOP
         LW,D1    R0
         LW,R1    D3
         AI,R2    -8                ADJUST R2 SO IT STILL
*                                   PTS TO LAST WORD OF
*                                   FOUND ROM ENTRY
         AI,R1    -8                R1=ROMT END -8
         LI,R6    X'10000'
         AWM,R6   *2                STORE PTD-TO-FLAG INTO
*                                   LAST WORD OF FOUND ROM ENTRY
         AI,R2    -7                R2 PTS TO START
*                                   OF FOUND ROM ENTRY
         LCI      K8                PICK UP THE 8 WORDA OF
         LM,R4    *R2               FOUND ENRT
         LI,SR4   X'10000'          FLAG THE 8TH WORD, B4
         LCI      8
         STM,R4   *R1               STOREING ENTRY INTO THE
*                                   SLOT JUST MADE AVAILABLE
         PULL     12,R0
         LW,R5    D3                CALCULATE DISP+1 OF
         SW,R5    D1                THIS LAST STORE ENTRY
         AI,R5    -7
         STW,R5   LSTROMLINK,R1     LSTROMLINK WORD OF THE
*                                   SEGMENT'S TREE TABLE
         PUSH     5,R1              CHECK IF NEW ROM ENTRY IS A SEGMENT
         LW,R5    D3                NAME
         AI,R5    -8
         LB,R2    *R5
MUVLOOP5 EQU      %
         LB,R4    *R5,R2            IF IT IS, MODIFY LINK IN TREE
         CB,R4    *R1,R2            TO POINT TO NEW ROM ENTRY INSTEAD
         BNE      MUVLOOP9          OF OLD
         BDR,R2   MUVLOOP5
         SW,R5    D1
         AI,R5    1
         SLS,R5   K10
         STW,R5   R4
         LW,R5    YFFFF
         STS,R4   LINK1STROM,R1     STORE LINK IN TREE
MUVLOOP9 EQU      %
         PULL     5,R1
          B        GETRMNM4A
GETROMNAME6 EQU   %
         PULL     7,SR4
GETROMNAME7 EQU   %
         PULL     5,R2
         MTW,-1   PCCP,R7
*E*      MESSAGE: ILLEGAL SEGMENT NAME
*E*      DESCRIPTION: THE SEGMENT NAME WAS NOT SPECIFIED ON THE LOAD
*E*               CONTROL COMMAND, EXCEEDED THE MAXIMUM LENGTH, OR
*E*               CONTAINED AN ILLEGAL ALPHANUMERIC CHARACTER.
         LI,SR3   ILSEGNCD
         B        *SR4              ERROR EXIT
GETROMNAME8 EQU   %
         PULL     2,SR1
GETROMNAME9 EQU   %
         PULL     5,R2
*E*      MESSAGE: CAN'T GET DYNAMIC PAGES
         LI,SR3   NOPGERR           ERROR EXIT
         B        *SR4
GETROMNAME10 EQU  %
         PULL,12  R0
         B        GETROMNAME9
         PAGE                                                           741
*F*
*F*      NAME:    PTREER
*F*
*F*      PURPOSE: TO PROCESS THE PTREE CONTROL COMMAND
*F*
*F*      DESCRIPTION: PTREER IS CALLED BY CCIR WHENEVER A PTREE
*F*               CONTROL COMMAND IS ENCOUNTERED. THE PTREE CONTROL
*F*               COMMAND IS PROCESSED AND OUTPUT ON THE LL DEVICE.
*F*               THE FILE SPECIFIED ON THE COMMAND IS READ TO
*F*               OBTAIN THE TREE CONTROL COMMAND. UPON COMPLETITION
*F*               OF PROCESSING THE COMMAND, CONTROL IS RETURNED TO
*F*               CCIR WHICH EXITS TO THE LOADER OR LOCCT PROCESSOR.
*F*
*F*      REFERENCE: BATCH PROCESSING REFERENCE MANUAL
*F*
*                                                                       741
*        PTREE   -  PROCESSES  PTREE  CONTROL COMMAND                   741
*                                                                       741
*        ENTER WITH  (R5) = JIT ADR                                     741
*                                                                       741
*                                                                       741
PTREER   EQU      %                                                     741
         PUSH     SR4               SAVE SR4                            741
         CI,SR1   ' '               CHECK FOR BLANK AFTER COMMAND FIELD 741
         BNE      PTREER41          NO BLANK, ERROR                     741
         LI,SR2   '('                                                   741
         BAL,SR4  CHARSCAN          CHECK FOR  (                        741
         BCS,8    PTREER41          CHECK IF FOUND                      741
         BAL,SR4  NAMSCAN           GET FILENAME                        741
         BCS,8    PTREER41                                              741
         LW,R0    R7                                                    741
         LW,R1    CSL,R7                                                741
         AI,R0    PLB                                                   741
         LI,R2    1                                                     741
         BAL,SR4  CHSTSHFT          SHIFT FILENAME AND INSERT BYTE COUNT741
         LW,R4    ALOCCT,R5                                             741
         LW,R4    TREETADR,R4                                           741
         LW,R2    CSL,R7                                                741
         AI,R2    4                                              741
         SLS,R2   -2                (R2) = NO. OF WORDS IN FILNAME      741
         STW,R2   D1                                                    741
         AW,D1    R4                                                    741
PTREER2  EQU      %                                                     741
         LW,R3    *R0,R2            MOVE FILE-NAME TO BUFFER            741
         STW,R3   *R4,R2                                                741
         AI,R2    -1                                                    741
         BGEZ     PTREER2                                               741
         PUSH     R4                                                    741
         PUSH     D1                                                    741
         LI,SR2   ','                                                   741
         BAL,SR4  CHARSCAN          CHECK FOR COMMA AFTER NAME          741
         BCS,8    PTREER30                                              741
         BAL,SR4  GETACCN           GET ACCOUNT NUMBER                  741
         BCS,8    PTREER45                                              741
         PULL     D1                                                    741
         LW,R2    PLB,R7            MOVE                                741
         STW,R2   *D1                    ACCOUNT                        741
         LW,R2    PLB+1,R7                       NUMBER                 741
         LI,R1     1                                                    741
         STW,R2   *D1,R1                                                741
         LW,D2    D1                                                    741
         AI,D2    2                                                     741
         PUSH     2,D1                                                  741
         LI,SR2   ','                                                   741
         BAL,SR4  CHARSCAN          CHECK FOR COMMA AFTER ACCN. NO.     741
         BCS,8    PTREER32                                              741
         BAL,SR4  GETPASSW          GET PASSWORD                        741
         BCS,8    PTREER44                                              741
         PULL     D2                                                    741
         LW,R2    PLB,R7            MOVE                                741
         STW,R2   *D2                    PASSWORD                       741
         LW,R2    PLB+1,R7                                              741
         LI,R1    1                                                     741
         STW,R2   *D2,R1                                                741
         PUSH     D2                                                    741
PTREER6  EQU      %                                                     741
         LI,SR2   ')'                                                   741
         BAL,SR4  CHARSCAN          CHECK FOR  )                        741
         BCS,8    PTREER40                                              741
         BAL,SR4  EOCCSCAN          SKIP TO END OF CC                   741
*                                                                       741
         LW,R3    Y002                                                  741
         STS,R3   RUNFLAG,R5        SET RUN FLAG TO PROCESSOR           741
         LI,R3    1                 (R3) = ORG = CONSEC = 1             741
         PULL     2,D1              (D1-D2)=ADR OF ACCN, PASSW OR 0     741
         PULL     R4                (R4) = ADR OF FILENAME              741
         LI,D3    RDTERR            (D3-D4) = ERR/ABN ADR'S             741
         BAL,SR4  OPNF              OPN FILE WITH TREE CC
         LI,R2    0                                                     741
         LW,R3    Y002                                                  741
         STS,R2   RUNFLAG,R5        RESET RUN FLAG IN JIT               741
         CI,SR3   0                 CHECK IF FILE OPENED                741
         BNE      PTREE48                                               741
*                                                                       741
         LI,R2    RDTR              (R2) = ADR OF READ ROUTINE          741
         LI,R3    X'1FFFF'                                              741
         STS,R2   CONTR,R7          STORE ADR IN PLIST                  741
         LI,R2    1                                                     741
         STW,R2   CCP,R7            SET CUR CHAR POS. TO 1              741
*                                                                       741
         LI,R2    TSTACK+200                                            741
         STW,R2   CBUF,R7                                               741
         CAL1,1   RDTRPL            READ 1ST RECORD                     741
         LI,R2    ARS                                                   741
         LW,R2    M:X1,R2                                               741
         SLS,R2   -17               (R2) = NO. OF WORDS READ            741
         STW,R2   CCRSZ,R7          STORE RECORD SIZE IN PLIST          741
         LI,SR1   0                                                     741
         BAL,SR4  NAMSCAN           GET COMMAND FIELD                   741
         CAL1,1   SETERAB                                               741
         BAL,SR4  TREER             PROCESS TREE COMMAND                741
         B        RDTERR                                                741
         LI,R2    CREAD                                                 741
         LI,R3    X'1FFFF'                                              741
         STS,R2   CONTR,R7          RESTORE CONT. READ ROUT. ADR.       741
         LW,R2    R5                                                    741
         AI,R2    ACCBUF                                                741
         STW,R2   CBUF,R7                                               741
         LI,R2    CCLIST                                                741
         STS,R2   OUTR,R7           SET OUTPUT ROUT. ADR = CCLIST       741
         CAL1,1   CLSMX1                                                741
         PULL     SR4                                                   741
         AI,SR4   1                                                     741
         B        *SR4              EXIT                                741
*                                                                       741
PTREER30 EQU      %                                                     741
         SLD,D1   64                SET (01-D2) = 0                     741
         STW,D1   *TSTACK                                               741
         PUSH     D2                                                    741
         B        PTREER6                                               741
*                                                                       741
PTREER32 EQU      %                                                     741
         LI,D2    0                                                     741
         STW,D2   *TSTACK                                               741
         B        PTREER6                                               741
*                                                                       741
RDTERR   EQU      %                                                     741
         LI,R2    CCLIST                                                741
         STW,R2   OUTR,R7                                               741
         LI,R2    CREAD                                                 741
         LI,R3    X'1FFFF'
         STS,R2   CONTR,R7                                              741
         LW,R2    R5                                                    741
         AI,R2    ACCBUF                                                741
         STW,R2   CBUF,R7                                               741
         CAL1,1   CLSMX1            CLOSE MX1 DCB                       741
*E*      MESSAGE: ERR OPENING, READING OR PROCESSING PTREE FILE
         LI,SR3   RDTERRM                                               741
         PULL     SR4                                                   741
         B        *SR4                                                  741
*                                                                       741
RDTERRM  TEXTC    'ERR OPENING, READING OR PROCESSING PTREE FILE'       741
*                                                                       741
PTREER40 EQU      %                                                     741
         BUMP     -3,R1                                                 741
PTREER41 EQU      %                                                     741
         LI,SR3   SYNTXER
PTREER42 EQU      %                                                     741
     B   TREER6A
*                                                                       741
PTREER44 EQU      %                                                     741
         PULL     R1                                                    741
PTREER45 EQU      %                                                     741
         PULL     2,R1                                                  741
         B        PTREER42                                              741
*                                                                       741
PTREE48  EQU      %                                                     741
         LI,SR3   RDTERRM                                               741
         B        PTREER42                                              741
*                                                                       741
*        READ TREE FILE ROUTINE                                         741
*                                                                       741
*                                                                       741
*                                                                       741
RDTR     EQU      %                                                     741
         LI,R2    TSTACK+200                                            741
         CAL1,1   RDTRPL1                                               741
RDTRERAB EQU      %                                                     741
         LI,R2    0                                                     741
         LB,SR3   SR3                                                   741
         BNEZ     %+2                                                   741
         LI,R2    6                                                     741
         STB,R2   SR3                                                   741
         B        *SR4                                                  741
*                                                                       741
*                                                                       741
*        READ TREE PLIST                                                741
*                                                                       741
*                                                                       741
RDTRPL   EQU      %                                                     741
         GEN,8,24 X'10',M:X1                                            741
         DATA     X'F0000010'                                           741
         DATA     RDTERR                                                741
         DATA     RDTERR                                                741
         GEN,8,24 X'80',R2                                              741
         DATA     80                                                    741
*                                                                       741
SETERAB  EQU      %                                                     741
         GEN,8,24 6,M:X1                                                741
         DATA     X'C0000000'                                           741
         DATA     RDTRERAB                                              741
         DATA     RDTRERAB                                              741
*                                                                       741
RDTRPL1  EQU      %                                                     741
         GEN,8,24 X'10',M:X1                                            741
         DATA     X'F0000010'                                           741
         DATA     RDTRERAB                                              741
         DATA     RDTRERAB                                              741
         GEN,8,24 X'80',R2                                              741
         DATA     80                                                    741
*                                                                       741
*        CLOSE   M:X1   PLIST                                           741
*                                                                       741
CLSMX1   EQU      %                                                     741
         GEN,8,24 X'15',M:X1                                            741
         DATA     X'80000000'                                           741
         DATA     2                                                     741
         END

