ASMB,L,C,R
      HED RBPIL UTILITY SUBROUTINE FOR RDBA-IMAGE/1000
      NAM RBPIL,7 92069-16227 REV.1912 790326 
* 
* 
******************************************************************* 
* (C) COPYRIGHT HEWLETT-PACKARD COMPANY 1979. ALL RIGHTS RESERVED.
* NO PART OF THIS PROGRAM MAY BE PHOTOCOPIED, REPRODUCED, OR
* TRANSLATED TO ANOTHER PROGRAM LANGUAGE WITHOUT THE PRIOR WRITTEN
* CONSENT OF HEWLETT-PACKARD COMPANY. 
******************************************************************* 
* 
* 
*     SOURCE:    92069-18227
*     RELOC:     92069-16227
* 
*     PRGMR:     CEJ
* 
* 
******************************************************************* 
* 
* 
* 
*  Process Item List is a subroutine which accepts the item list passed 
*  to an RDBA subroutine by the user's program, parses the item list into 
*  its components and builds an item number or special construct list from
*  them at the beginning of the data buffer.  The item list is either:
* 
*    1)  A number list in which the first word contains an integer count
*        of the number of items in the list and each succeeding word, up
*        to the count number of items, contains an unique item number.
* 
*    2)  A name list which is a list of unique item names concatenated
*        together, separated by commas and terminated by a semi-colon or
*        a blank. 
* 
*    3)  A special construct either:
*        "@ " meaning all items in the data set 
*                    or 
*        "0 " meaning no items. 
* 
*  The information put into the data buffer by RBPIL is the length of the 
*  item list followed by the item number or special construct list.  If 
*  the user passed an item name list, it is converted into an item number 
*  list.  If the user passed an item number list, each item is still checked
*  for validity before being put into the item list in the data buffer. 
* 
*  In addition, RBPIL returns the combined length of all the items in the 
*  item list. 
* 
*  The calling sequence for RBPIL is: 
* 
*          JSB RBPIL
*           DEF *+4 
*           DEF IMLST      item list passed by user 
*           DEF DSADR      pointer to data set's Set Table entry, relative
*                            to start of Run Table
*           DEF LENTH      returned length of items 
*          < error return point > 
*          < normal return point >
* 
      SKP 
**********************************************************************
*                                                                    *
*  Run Table for local machine in Remote Data Base Access            *
*                                                                    *
*  The local copy of the Run Table used by the RDBA master subrou-   *
*  tines consists of the following sections:                         *
*                                                                    *
*    1) Data Base Control Block                                      *
*    2) Data Item Table                                              *
*    3) Data Set Table                                               *
*    4) Sort Table                                                   *
*                                                                    *
*  These sections are in the order stated.  Details of each section  *
*  follow.                                                           *
*                                                                    *
**********************************************************************
***                                                                ***
*                                                                    *
*  Data Base Control Block - one 17 word entry per data base         *
*                                                                    *
***                                                                ***
RDCBS DEC 17        DBCB size 
* 
RDNAM DEC 0         data base name - three words
      DEC 1 
      DEC 2 
RDRBN DEC 3         remote data base number 
      DEC 4 
RDDSN DEC 5         DS node number
      DEC 6 
RDITC DEC 7         data item count 
RDITP DEC 8         data item table pointer 
RDDSC DEC 9         data set count
RDDSP DEC 10        data set table pointer
RDSOP DEC 11        sort table pointer
      DEC 12
RDLMD DEC 13        lock flag/open mode 
RDLFG EQU RDLMD     1st byte: lock flag 
RDMOD EQU RDLMD     2nd byte: open mode 
      DEC 14
RDCBC DEC 15        # of DCBs desired = 0 
RDMDL DEC 16        maximum data length 
* 
ZERO  EQU RDNAM     base of zero for future equates 
***                                                                ***
*                                                                    *
*  Data Item Table - one 5 word entry per item in a 1000 data base   *
*                                                                    *
***                                                                ***
RI1LN EQU ZERO+5    length of a 1000 entry
* 
RI1NM EQU ZERO      item name - 3 words 
RI1NO EQU ZERO+3    item number 
RI1IL EQU ZERO+4    item length 
***                                                                ***
*                                                                    *
*  Data Set Table - one 6 word entry per set in a 1000 data base     *
*                                                                    *
***                                                                ***
RS1LN EQU ZERO+6    length of a 1000 entry
* 
RS1NM EQU ZERO      set name - 3 words
RS1NO EQU ZERO+3    set number
RS1EL EQU ZERO+4    entry length (in words) 
RS1KL EQU ZERO+5    key item length for a master
***                                                                ***
*                                                                    *
*  Sort Table - one 1 word entry per item and per set.  Each entry   *
*               is a pointer to the respective item or set table     *
*               entry relative to the start of the Run Table         *
*                                                                    *
***                                                                ***
      SKP 
A     EQU 0 
B     EQU 1 
* 
      ENT RBPIL 
      EXT .ENTR,AIRUN,DBRBP,NAMR,RBCIT
* 
IMLST NOP 
DSADR NOP 
LENTH NOP 
* 
*  Get true parameter and return point addresses. 
* 
RBPIL NOP 
      JSB .ENTR 
       DEF IMLST
* 
*  Initialize process's parameters. 
* 
      CLA           Zero to combined length 
      STA LENTH,I 
      STA COUNT       and item count. 
* 
      LDA DBRBP     Set up address for item list
      ADA D2          skipping over item list 
      STA LSTAD       length & item count words.
* 
*  Determine if a special construct we recognize is given.  If so, branch 
*  to the appropriate processing locations.  If not, assume the list is 
*  of numbers or names. 
* 
      LDA IMLST,I 
      SSA           If negative first word -
      JMP EREXT       illegal item list.
* 
      CPA /@        If an "@ "
      JMP PIL12       process entire record.
* 
      CPA /0        If an "0 " or an integer zero 
      JMP PIL13 
      SZA,RSS         process no items. 
      JMP PIL13 
* 
      AND HIBYT     Else, if first byte of word is zero - 
      SZA,RSS         this is a number list.  Set number
      CCA,RSS         flag to TRUE (-1).  Else, 
      CLA             set number flag to FALSE (0). 
      STA NFLAG 
* 
*  If this is an item number list, make sure the count specified by the 
*  user is less than 128. 
* 
      SSA,RSS 
      JMP PIL1
* 
      LDB IMLST,I 
      CMB 
      STB CONTR     Counter for later if list okay. 
* 
      INB 
      ADB D128
      SSB 
      JMP EREXT     More than 127 items - illegal list. 
      JMP PIL6
* 
*  For a name list, we will use NAMR to parse the string as we need a 
*  name.  So we need to set up for NAMR.  This means getting the byte 
*  count in the string and setting the starting byte to one.  To get the
*  byte count, we will search each byte in the string until we find a 
*  blank or semi-colon, incrementing the byte count by one for each byte
*  not matching an ending character.
* 
PIL1  CLA           Initialize byte count to zero 
      STA BYCNT 
      INA             and starting byte to one. 
      STA BSTRT 
* 
      LDA M889      Set maximum byte count to -(127*7). 
      STA BMAX      6 bytes per name plus one for separater.
* 
      LDB IMLST     Get address of item list
* 
PIL2  CCA           Set first byte flag to TRUE.
      STA FIRST 
      LDA B,I       Get first byte. 
      ALF,ALF 
* 
PIL3  AND LOBYT 
      CPA SEMI      If a semi-colon 
      JMP PIL5
      CPA ABLNK       or a blank
      JMP PIL5        we are done.
* 
      ISZ BYCNT     Else, increment byte count. 
      ISZ BMAX      If byte count exceeds the max.
      RSS 
      JMP EREXT       a bad item list 
* 
      ISZ FIRST     If we were on first byte
      JMP PIL4
      LDA B,I         get second byte in word 
      JMP PIL3        and check it. 
* 
PIL4  INB           Else get next word and
      JMP PIL2        process its first byte. 
* 
PIL5  LDA BYCNT     At end, if byte count 
      SZA,RSS         is zero,
      JMP EREXT       a bad item list.
      JMP PIL7
* 
*    BEGIN MAIN LOOP FOR NUMBER OR NAME LIST. 
* 
*  This section of code pickes up each item in the list and gets its Item 
*  Table entry, item number and length.  If item found in Item Table, puts
*  the item number in the item list, increments the item count and adds 
*  the item's length to the combined length word. 
* 
PIL6  LDB NFLAG     If a number list
      SSB,RSS 
      JMP PIL7
      ISZ CONTR       then if no more numbers in list,
      RSS 
      JMP PIL11       we are done.
* 
      ISZ IMLST     Else, pick up next
      LDA IMLST,I     item number.
      STA ITEM
      JMP PIL8
* 
PIL7 JSB NAMR       Else, a name list - 
       DEF *+5        call NAMR to get
       DEF ITEM       next name in list.
       DEF IMLST,I
       DEF BYCNT
       DEF BSTRT
* 
      SSA           If no more names, 
      JMP PIL11       we are done.
* 
PIL8  JSB RBCIT     Ask RBCIT to get the item's 
       DEF *+4        Item Table entry relative 
       DEF ITEM       to beginning of Run Table 
       DEF NUMBR      and item's number.
       DEF DIADR
      JMP EREXT     Invalid item return.
* 
*  Search item list already built for an identical item number.  If a 
*  match is found, item list is illegal.
* 
      LDB DBRBP 
      ADB D2
PIL9  CPB LSTAD     If at end of table, 
      JMP PIL10       everything is fine. 
* 
      LDA B,I       If item number in this entry of table 
      CPA NUMBR       same as item number we are processing,
      JMP EREXT       illegal item list.
      INB           Else try next entry until end of
      JMP PIL9        data in table.
* 
PIL10 LDA NUMBR     Item okay - put it
      STA LSTAD,I     into item list
* 
      ISZ COUNT       increment count and 
      ISZ LSTAD       item list address.
* 
*  Get item's length from fifth word in Item Table entry. 
* 
      LDB RI1IL 
      ADB DIADR 
      ADB AIRUN 
      LDA B,I 
* 
      ADA LENTH,I   Add length to current 
      STA LENTH,I     combined length total.
* 
*  Continue for all items in list.
* 
      JMP PIL6
* 
*    END OF LOOP
* 
*  We come here when all items in list have successfully been processed.
*  Put the item count in the first word of the item number list in the
*  data buffer (actually second word of data buffer), add one to the count
*  and it becomes the item list length.  Branch with this value in the A
*  register to join all the successful item list processes. 
* 
PIL11 LDA COUNT 
      LDB DBRBP 
      INB 
      STA B,I 
* 
      INA 
      JMP JOIN
      SKP 
* 
*  We branch here when the special construct "@ " is passed to us in the
*  item list.  Put this directly into the data buffer's item list, get
*  the length of the data set's data record from its Set Table entry (5th 
*  word) and set it into the length return parameter.  Then, set the length 
*  of the item list in the data buffer to one, and branch with this length
*  in the A register to join all successful item list processing. 
* 
PIL12 LDB DBRBP 
      INB 
      STA B,I       A = "@ " from above ! 
* 
      LDB RS1EL 
      ADB DSADR,I 
      ADB AIRUN 
      LDA B,I 
      STA LENTH,I 
* 
      CLA,INA 
      JMP JOIN
* 
*  We branch here when the special construct "0 " or an item count of zero
*  is passed to us in the item list.  Put this directly into the data buf-
*  fer's item list, leave the combined length word zero, and set the length 
*  of the item list to 1 in the A register and join all successful item list
*  processing.
* 
PIL13 LDB DBRBP 
      INB 
      STA B,I       A = "0 " or zero from above ! 
* 
      CLA,INA 
* 
*  We join all successful processes here to set the itme list length in 
*  the data record, bump the return address to the normal return point
*  and return to the caller.
* 
JOIN  STA DBRBP,I 
      ISZ RBPIL 
EREXT JMP RBPIL,I   (No bump when an error occurs.) 
* 
*  Constants and variables. 
* 
M889  DEC -889
D2    EQU ZERO+2
D128  DEC 128 
* 
/@    ASC 1,@ 
/0    ASC 1,0 
SEMI  OCT 73
ABLNK OCT 40
LOBYT OCT 377 
HIBYT OCT 177400
* 
LSTAD NOP 
NFLAG NOP 
BYCNT NOP 
BSTRT NOP 
FIRST NOP 
BMAX  NOP 
CONTR NOP 
COUNT NOP 
NUMBR NOP 
DIADR NOP 
ITEM  BSS 10
      BSS 0 
      END 
      $END
                                      