***********************************************************************
*M*      P2LDV    DECODES LDEV CC AND ADDS TABLE INFO FOR SG:XXX LMN'S
***********************************************************************
*
         SYSTEM   SIG7FDP
         SYSTEM   BPM
*
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
*
*        REFS AND DEFS
         REF      SYNTAX
         REF      GETPGS,GETPGPTR,ENDUSED
         REF      SYMBPTR,SYMBDEV,SYMBTYPE,#LDV,LDVPTR
         REF      SBLTYPTR,TYPMNEAD,TYPMNESZ,BTXPTR,OTXPTR
         REF      GTXPTR,LDVCONST,READSTRG
         REF      PASS2OUT,P2ERR
         REF      LOGIT
         DEF      LDEVICE
         PAGE
*
*        FOPS FOR PROCESSING COMMAND
*
FOP      COM,1,7,8 AF(1),AF(2),AF(3)
KWDTBLO  EQU      %
         DATA KWDTBL-KWDTBLO
         FOP      0,0,3             0 FINDLEFT
         FOP      1,6,20            1 GETSTRG (LABEL)
         FOP      0,1,18            2 WDTBLPTR AT 1,R5
         FOP      1,6,6             3 COMMA
         FOP      1,6,20            4 GETSTRG (ASSIGNMENT)
         FOP      0,1,18            5 WDTBLPTR AT 1,R5
         FOP      1,0,8             6 INTEROPT
         FOP      0,1,1             7 GO TO 1
KWDTBL   EQU      %
         DATA     0                 DUMMY LOCATIONS
         DATA     0
LKWDTBL  EQU      %
         DATA     0
KWDPTR   GEN,15,17 LKWDTBL-KWDTBL,KWDTBLO
*
*        SKELETON TEMP STACK
*
DYNAM    EQU      %
LBPTR    DATA     0                 HIGHEST LOCATION FOR LABEL & ASSGNMNT
         DATA     0                 STARTING LOCATION FOR LABEL & ASSGNMNT
         DO1      36
         DATA     0
#DYNAM   EQU      %-DYNAM
         PZE      WRITERROR
         PAGE
*        LDEVICE ROUTINE
*        UPON ENTRY R3=BASE ADDRESS OF P2CCI DYNAMIC AREA
*                   R7=PLIST ADDRESS
*                   SR1=NEXT ACTIVE CHARACTER (USED BY SYNTAX)
LDEVICE  EQU      %
         PSW,SR1  *R0
         LW,SR2   ENDUSED,R3
         AI,SR2   1
         STW,SR2  LDVPTR,R3
         AI,SR2   8                 ALLOCATE SPACE IN 'PERM' STACK
         STW,SR2  SBLTYPTR,R3       FOR LDEV ENTRIES-MODULE BUILT
         AI,SR2   4                 IN OPLBLT OVERLAY
         CW,SR2   GETPGPTR,R3
         BL       %+3
         LI,R2    GETPGPTR+1
         BAL,R1   GETPGS
         STW,SR2  ENDUSED,R3
         LI,R1    3
         LW,D3    LDVPTR,R3
         LH,D1    DFLDV,R1          STORE DEFAULT C1,L1,P1
         STH,D1   *D3,R1
         BDR,R1   %-2
         LW,D3    SYMBTYPE,R3       ADDRESS OF SYMB TYPE INDEX TBLE
         LW,D2    SYMBPTR,R3        ADDRESS OF SYMB DEVICE TYPE
         LW,D4    SBLTYPTR,R3
         LI,R1    3                 OUTER LOOP FOR 3 DEVICES
         STW,R1   #LDV,R3
LOOP     EQU      %
         LH,D1    DFTYP,R1          GET DEFAULT TYPE
         LW,R2    SYMBDEV,R3        #SYMB DEVICES
         CH,D1    *D2,R2
         BE       GETTYPE
         BDR,R2   %-2
         CW,D1    =X'FFFFC3D7'      IS IT CP
         BNE      ERR7              NO ERROR
         LW,D1    =X'FFFFD3D7'
         B        LOOP+1
GETTYPE  LB,R4    *D3,R2            GET TYPEMNEMONIC INDEX
         STB,R4   *D4,R1            STORE IN SB:LTY
         LW,D2    LDVCONST,R3       STORE LDEV INDEX COMPUTED INTO
         AW,D2    R1                OB:B,O,G TX TABLES
         LW,D1    BTXPTR,R3
         STB,D2   *D1,R4
         LW,D1    OTXPTR,R3
         STB,D2   *D1,R4
         LW,D1    GTXPTR,R3
         STB,D2   *D1,R4
         LW,D2    SYMBPTR,R3
         BDR,R1   LOOP
         PLW,SR1  *R0
         LW,R5    *R0
         AI,R5    3
         STW,R5   LBPTR+1           START OF STORAGE AREA
         AI,R5    #DYNAM            SET UP TO PNT TO STACK
         STW,R5   LBPTR             END OF STORAGE AREA
         LI,R1    #DYNAM            SIZE OF TEMP STACK
         LI,R2    DYNAM             START OF TEMP STACK
         LW,R4    KWDPTR
         BAL,SR4  SYNTAX
*        UPON RETURN R5 = ADDRESS OF GENERATED TEMP STACK TABLE
         LI,R2    0
         AI,R5    2                 SET POINTER TO STACK AREA
         LW,D3    LDVPTR,R3         ADDRESS OF LDVTABLE
         LW,D1    SBLTYPTR,R3       ADDRESS OF SB:LTY TABLE
         LW,D4    SYMBTYPE,R3       SYMB TYPE TABLE
         LW,D2    SYMBPTR,R3        SYMBIONT DEVICE TABLE
CHKLOOP  EQU      %
         LW,R6    SYMBDEV,R3
         LW,SR1   *R5,R2            GET LDEV FIRST ENTRY
         BEZ      LOOPEND+3         ALL THROUGH
         AND,SR1  =X'0000FFFF'
         CH,SR1   =X'40400000'
         BNE      ERR8
         LW,SR1   *R5,R2
         SAS,SR1  -16
         AI,R2    1
         LW,SR2   *R5,R2            GET CORRESP DEVICE
         SAS,SR2  -16
         LW,R4    #LDV,R3           # LDEVS ALREADY IN
         AI,R4    1
         CH,SR1   YD5D6             CANT BE NO
         BE       ERR3              ERROR
         CH,SR1   YC3F1             CANT BE C1
         BE       ERR5              ERROR
         LW,R1    R4                SAVE 4
         CH,SR1   *D3,R1            IF THIS LDEV ALREADY IN
         BNE      %+5
         CI,R1    3
         BG       ERR2
         AI,R4    -1
         B        SYMBCHK+1
         BDR,R1   %-6               NO
         LW,R1    TYPMNESZ,R3       GET # TYPMNE
         LW,SR3   TYPMNEAD,R3       GET START OF TYPMNE TABLE
         CH,SR1   *SR3,R1
         BE       ERR3              CAN'T BE IN TYPMNE TABLE
         BDR,R1   %-2
SYMBCHK  LW,1     4
         CI,R4    15
         BLE      %+2
         B        ERR1
         CH,SR2   *D2,R6
         BE       %+3               YES
         BDR,R6   %-2
         B        ERR4              NOT SYMBIONT-ERROR
         LB,R6    *D4,R6            GET TYPMNE INDEX
         STB,R6   *D1,R1
         STH,SR1  *D3,R1
         STW,R4   #LDV,R3           STORE INCREMENTED LDVS
         LW,SR1   LDVCONST,R3       STORE LDV ENTRY IN OB B,O,G TX
         AW,SR1   R4
         LW,SR2   BTXPTR,R3
         LB,R1    *SR2,R6           GET CURRENT ENTRY
         CW,R1    LDVCONST,R3       IS IT ALREADY AN LDEV ENTRY
         BG       LOOPEND
         STB,SR1  *SR2,R6
         LW,SR2   OTXPTR,R3
         STB,SR1  *SR2,R6
         LW,SR2   GTXPTR,R3
         STB,SR1  *SR2,R6
LOOPEND  AI,R2    1
         CI,R2    30
         BL       CHKLOOP
         LW,SR3   LDVCONST,R3       SET UP LDEV DEFAULT
         AI,SR3   2                 TO L1
         LW,R6    SYMBDEV,R3        #SYMB DEVICES
         LW,D1    SYMBTYPE,R3       SYMB DEVICE TYPE TABLE
CHKASG   LW,SR2   BTXPTR,R3
         LB,R1    *D1,R6            GET DEVICE TYPE BYTE
         LB,SR1   *SR2,R1           GET OB TABLE ENTRY
         CW,SR1   LDVCONST,R3       IS IT SET TO LDEV ENTRY
         BL       %+3               NO
         BDR,R6   %-4               ALL DONE
         B        WRITERROR         YES
         STB,SR3  *SR2,R1           STORE DEFAULT IN BTX TABLE
         LW,SR2   OTXPTR,R3
         STB,SR3  *SR2,R1
         LW,SR2   GTXPTR,R3
         STB,SR3  *SR2,R1
         LW,SR2   TYPMNEAD,R3       GET TYPE MNEMONIC IN ERROR
         AI,R1    1                 ADJUST TO TABLE VALUE
         LH,SR2   *SR2,R1
         AND,SR2  =X'0000FFFF'
         OR,SR2   =X'40400000'
         STW,SR2  ERR6M+1
         LI,D3    ERR6M
         BAL,SR4  LOGIT             PUT ERROR IN T:P2SI    & LP
         BDR,R6   CHKASG
WRITERROR  LI,R1  -#DYNAM
         MSP,R1   *R0
         B        READSTRG
         PAGE
ERR1     EQU      %
         LI,D3    ERR1M
         BAL,SR4  LOGIT             PUT ERROR IN T:P2SI    & LP
         B        LOOPEND+3
ERR1M    TEXTC    '*** > 15 LDEV ENTRIES - ADDITIONAL ONES IGNORED'
ERR2     EQU      %
         AND,SR1  =X'0000FFFF'
         OR,SR1   =X'40400000'
         STW,SR1  ERR2M+1
         LW,SR1   D3
         LI,D3    ERR2M
RET2LOOP BAL,SR4  LOGIT             PUT ERROR IN T:P2SI    & LP
         LW,D3    SR1
         B        LOOPEND
ERR2M    TEXTC    '***XXXX  NAME DUPLICATED-FIRST ONE USED'
ERR3     EQU      %
         AND,SR1  =X'0000FFFF'
         OR,SR1   =X'40400000'
         STW,SR1  ERR3M+1
         LW,SR1   D3
         LI,D3    ERR3M
         B        RET2LOOP
ERR3M    TEXTC    '***XXXX  NAME A DEVICE TYPE- NAME IGNORED'
ERR4     EQU      %
         AND,SR2  =X'0000FFFF'
         OR,SR2   =X'40400000'
         STW,SR2  ERR4M+1
         LW,SR1   D3
         LI,D3    ERR4M
         B        RET2LOOP
ERR4M    TEXTC    '***XXXX DEVICE TYPE NOT SYMBIONT-ENTRY IGNORED'
ERR5     EQU      %
         AND,SR1  =X'0000FFFF'
         OR,SR1   =X'40400000'
         STW,SR1  ERR5M+1
         LW,SR1   D3
         LI,D3    ERR5M
         B        RET2LOOP
ERR5M    TEXTC    '***XXXX CANNOT BE ASSIGNED - ENTRY IGNORED'
ERR6M    TEXTC    '***XXXX SYMBIONT TYPE NOT SPECIFIED',;
                  ' - DEFAULT TO L1'
ERR7     AND,D1   =X'0000FFFF'
         OR,D1    =X'40400000'
         STW,D1   ERR7M+1
         M:PRINT  (MESS,ERR7M)
         M:PRINT  (MESS,ERR7M2)
         MTW,1    P2ERR,R3          INCREMENT ERROR COUNT
         B        PASS2OUT          ABORT PASS2
ERR7M    TEXTC    '***XXXX DEVICE NOT DEFINED'
ERR7M2   TEXTC    '*** PASS2 UNABLE TO CONTINUE'
ERR8     LW,SR1   *R5,R2
         STW,SR1  ERR8M+1
         LW,SR1   D3                SAVE D3 IN SR1
         LI,D3    ERR8M
         BAL,SR4  LOGIT             PUT ERROR IN T:P2SI
         LW,D3    SR1
         AI,R2    1
         B        LOOPEND
ERR8M    TEXTC    '***XXXX LABEL MORE THAN 2 CHARACTERS.  IT',;
                  ' WILL BE IGNORED.'
DFLDV    DATA,2   0,'C1','L1','P1'
         BOUND    4
DFTYP    DATA,2   0,'CR','LP','CP'
         BOUND    4
YD5D6    DATA     X'D5D60000'       NO
YC3F1    DATA     X'C3F10000'       C1
         END

