ASMB,L,C,R HED DBFND SUBROUTINE OF IMAGE/1000 NAM DBFND,7 92069-16138 REV.2026 800121 * * ******************************************************************* * (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-18138 * RELOC: 92069-16138 * * PRGMR: CEJ * ALTERED: JANUARY 21, 1980 FOR SORTED CHAINS FEATURE - CEJ * * ******************************************************************* * * * * Data Base FiND is one of the ten user callable subroutines in the * IMAGE/1000 library. DBFND performs the function of preparing a detail * data set for future chain reads. It does this by using the key item * number and value specified by the user to determine the path in the * detail data set specified by the user and the master to which this path * is linked. It then performs a hashed-read into the master data set * using the key item value to find the entry in the master which has that * key item. The chain information in the master entry's media record * is then used to initialize the current path information in the detail's * Data Set Control Block. * * The calling sequence for DBFND is: * * JSB DBFND * DEF *+7 return point * DEF IBASE data base parameter used in succesful DBOPN call * for the data base in which the set to be ini- * tialized resides. * DEF SET the name or number of the detail data set to * be prepared for chain reads. * DEF MODE DBFND mode = 1 * DEF STAT returned 10 word status array which is of the * form: * 1st word - status code (0 if successful) * 2nd word - zero * 3rd & 4th words - doubleword current record * number set to zero * 5th & 6th words - doubleword count of detail * entries in the chain * 7th & 8th words - doubleword record number of * chain foot * 9th & 10th words - doubleword record number * of chain head * DEF ITEM detail's key item number for desired chain * DEF ARG key item's value for desired chain * SKP *********************************************************************** * * * Run Table for IMAGE/1000 Local machine. * * * * The Run Table is comprised of the following sections: * * * * 1) Data Base Control Block * * 2) Item Table * * 3) Data Set Control Block Table * * 4) Data Set Info Table * * A) Record Definition Table * * B) Path Table * * 5) Sort Table * * 6) Free Record Table * * * * These sections appear in the order described. Details of each * * section follow. * * * *********************************************************************** *** *** * * * Data Base Control Block - one 59 word entry per data base * * * *** *** DBCBS DEC 59 Control Block Size DBNAM DEC 0 Data Base name - 3 words DEC 1 DEC 2 DBSCD DEC 3 Data Base Security Code (FMP) DBCRN DEC 4 Data Base Cartridge Number (FMP) DBDSN DEC 5 Data Base node number (DS/1000) DBRSN DEC 6 Data Base resource number DBICT DEC 7 Data Item Count DBITP DEC 8 Data item table pointer DBSCT DEC 9 Data set count DBSTP DEC 10 Data set control block table pointer DBSOP DEC 11 Sort table pointer DBFRP DEC 12 Free record table pointer DBLMD DEC 13 Data Base lock flag and open mode DBLFG EQU DBLMD 1st byte: lock flag DBMOD EQU DBLMD 2nd byte: open mode DBLVL DEC 14 Access level words - 3 words per level DBFRL EQU DBLVL Free record table length DBOPT DEC 15 Optimal number of DCBs DBMAX DEC 16 Maximum size of a data entry DCBWS DEC 17 DCB storage area * ZERO EQU DBNAM base of zero for future equates *** *** * * * Data Item Table - one 7-word entry per item * * * *** *** ITELN EQU ZERO+7 item table entry length ITNME EQU ZERO item name - 3 words ITINF EQU ZERO+3 item write/read level and type ITRDL EQU ITINF 1st nibble: item read level ITWRL EQU ITINF 2nd nibble: item write level ITTYP EQU ITINF 2nd byte: item type ITSET EQU ZERO+4 set count and 1st set number ITSCT EQU ITSET 1st byte: set count ITSNO EQU ITSET 2nd byte: set number ITWRC EQU ZERO+5 write/read bits and element count ITECT EQU ITWRC 2nd byte: element count ITLNG EQU ZERO+6 item length in words *** *** * * * Data Set Control Block Table - one 17 word entry per set * * * *** *** DSLNG EQU ZERO+17 table entry length DSNME EQU ZERO set name - 3 words DSCRN EQU ZERO+3 cartridge reference number DSINF EQU ZERO+4 W/R bits, set type and media length DSTYP EQU DSINF 1st byte, 2nd nibble: set type DSMDL EQU DSINF 2nd byte: media record length DSDRL EQU ZERO+5 data record length DSFPC EQU ZERO+6 field and path counts DSFCT EQU DSFPC 1st byte: # fields per entry DSPCT EQU DSFPC 2nd byte: # paths per entry DSITP EQU ZERO+7 data set info table entry pointer DSCAP EQU ZERO+8 doubleword data set capacity DSCPN EQU ZERO+10 current path info DSCCT EQU DSCPN 1st byte: search item number DSPAN EQU DSCPN 2nd byte: path # of search item DSRCN EQU ZERO+11 doubleword current record number DSBWN EQU ZERO+13 doubleword previous record number DSFWN EQU ZERO+15 doubleword next record number *** *** * * * Data Set Info Table - one Record Definition Table and one Path * * Table per data set * * * *** *** * * * Record Definition Table - one 1-byte entry per field * * * *** *** RDLNG EQU ZERO+1 entry length (number of words) RDINF EQU ZERO field info (two fields per word) RDIT1 EQU RDINF 1st byte: item # for field n RDIT2 EQU RDINF 2nd byte: item # for field n+1 *** *** * * * Path Table - one 2-word entry per path * * * *** *** PTLNG EQU ZERO+2 entry length PTINF EQU ZERO path information - item & set numbers PTSIN EQU PTINF 1st byte: detail's search item # for path PTDSN EQU PTINF 2nd byte: related set's number PTSRT EQU ZERO+1 sort item for path *** *** * * * Sort Table - one 1-word entry per item and set * * * *** *** STITS EQU ZERO beginning of item entries STSTS NOP beginning of set entries *** *** * * * Free Record Table - one 4-word entry per set * * * *** *** FRLNG EQU ZERO+4 length of entry FRRCT EQU ZERO doubleword free record count FRPTR EQU ZERO+2 doubleword first free record * * *********************************************************************** *** *** * * ENT DBFND EXT .ENTR,.MVW,AIRUN,DBFDI,DBFDS,DBHRD,DBIDS EXT DBRBP,RBFND A EQU 0 B EQU 1 * BASE NOP SET NOP MODE NOP STAT NOP ITEM NOP ARG NOP * * Get true parameter and return point addresses. * DBFND NOP JSB .ENTR DEF BASE * * Make sure all the parameters are there. * LDA ARG SZA,RSS JMP E162 Missing parameter. * * Ask DBIDS to check the data base specified in BASE to see if it is * on a remote machine, and to set up its Run Table as the current Run * Table. * CCA A = -1 signifies not DBOPN calling. JSB DBIDS DEF *+2 DEF BASE,I * JMP E103 Error return - illegal BASE param. JMP LOCAL Local data base return. * JSB RBFND Remote data base return. DEF *+7 Ask RBFND to handle DEF BASE,I this request. DEF SET,I DEF MODE,I DEF STAT,I DEF ITEM,I DEF ARG,I JMP FND7 Return to caller. * * Set should contain a detail data set name. Ask DBFDS to validify the * set reference and, if valid, return us the set's Data Set Control Block * Table entry address (relative to beginning of Run Table). * LOCAL JSB DBFDS DEF *+5 DEF SET,I DEF DSNUM DEF FLAG DEF STADR * LDA DSNUM If DBFDS returned a set number of zero SZA,RSS JMP E100 * LDB FLAG or set the accessibility FLAG > 0 CMB,INB (data set inaccessible) SSB JMP E100 then the user gave us a bad set reference. * * Check if the set is a detail (type code in 2nd nibble of high order * byte of the 5th word of the DSCB). If so, ITEM should contain the * name or number of a key item in the detail data set. Ask DBFDS to * check the validity of the item reference and, if valid, pass us the * item number and Item Table entry address (relative to the beginning of * the Run Table). * LDB AIRUN ADB STADR STB STADR ADB DSTYP LDA B,I If type = 2 (sign bit set after rotate) ALF SSA,RSS the set is a detail. JMP E120 * JSB DBFDI Set is a detail, now check DEF *+5 item for validity. DEF ITEM,I DEF ITNUM DEF FLAG DEF ITADR * LDA ITNUM If DBFDI returned a data item SZA,RSS number of zero JMP E101 ALF,ALF (Put item # in high byte for later.) STA ITNUM * LDB FLAG or set the accessibility FLAG > 0 CMB,INB SSB JMP E101 then the user gave us a bad item reference. * * Now that we have the item's number, check that the Find mode is equal * to 1. If it is, get the data set's path count (low order byte of 7th * word of DSCB) and calculate the Path Table's relative pointer by: * Path Table pointer = Info Table pointer (8th word of DSCB) + * (number of items in data set <> * +1) / 2. * LDA MODE,I CPA D1 RSS JMP E115 * LDB STADR ADB DSFPC LDA B,I AND LOBYT A = # paths for data set. SZA,RSS If # paths = zero JMP E121 data set has no chain to initialize. * STA PTNUM Save path count for later. CMA,INA Use negative # paths STA CNTR for a loop counter. * LDA B,I Calculate address of path table ALF,ALF AND LOBYT A = # items in data set INA add one ARS divide by two INB ADA B,I add in pointer to Info Table ADA AIRUN and resolve with address of Run Table STA PTADR * * Check if item is in the data set's Path Table (and is therefore a key * item) by looping on each entry in the Path Table comparing the item * number to the key item number (in high order byte of entry) for the * path. * FND1 LDA PTADR,I Get next entry's item # AND HIBYT CPA ITNUM and do the compare. JMP FND2 A match! * ISZ PTADR No match - get next entry ISZ PTADR ISZ CNTR if there is one JMP FND1 and try it. * * We fall through loop to here when the item could not be found in the * path table. Return error to user. * JMP E102 * * We come here when a match is found between the user specified item * and a key item. The current Path Table entry has the master's set * number (low order byte). Get it and save for hash read call. Then, * get the path number for this key by adding what is left of the loop * counter to the data set's path count + 1 and save this for a successful * wrap up. * FND2 LDA PTADR,I AND LOBYT STA SET * LDA PTNUM ADA CNTR INA STA PTNUM * * Call DBHRD to find the master's record number countaing the key item * value. DBHRD signifies a successful read by returning a zero in the * ERROR parameter and a zero (TRUE) in the read FLAG. * JSB DBHRD DEF *+7 DEF BASE,I It needs the data base number DEF SET master data set number DEF ARG,I and key item value. DEF FLAG DEF RECRD Returns record number here. DEF ERROR * LDA ERROR If DBHRD encountered an error SZA JMP ERREX return it to the user. * LDA FLAG If it couldn't find a master record SZA with the key item value JMP E107 let the user know. * * Now that we have the record, determine the master's path for this * detail. First we need to get the master's Data Set Control Block. * JSB DBFDS DEF *+5 DEF SET DEF STNUM DEF FLAG DEF MSADR * LDA STNUM If DBFDS returned a zero set number SZA,RSS JMP E160 the Run Table is corrupt. * * Get the master's path count and Path Table address. * (PT address calculated as above for detail.) * LDB AIRUN ADB MSADR ADB DSFPC LDA B,I AND LOBYT CMA,INA Use negative of path count STA CNTR for a loop counter. * LDA B,I ALF,ALF AND LOBYT INA ARS INB ADA B,I ADA AIRUN STA PTADR * * Loop on each entry in the Path Table, calculating an index into the * media record of the master's entry, until the detail's set and key * item numbers are matched by the set and item number in the Path Table * entry. * LDB D5 Set index initially to five * (skips over synonym pointers). LDA ITNUM Merge detail's set and IOR DSNUM item numbers. STA TEMP * FND3 LDA PTADR,I CPA TEMP JMP FND4 Sets matched. * ADB D6 No match - add length of this path's ISZ PTADR pointers to the index ISZ PTADR ISZ CNTR and check next path. JMP FND3 * * We fall through loop here if there is no match - * means we have a corrupt Run Table. * JMP E160 * * Sets matched. B-reg contains proper index. Add it to the record * buffer address to get this path's count and pointers in the master * data set media record. * FND4 LDA DBRBP ADA B STA PTADR * * If path count = zero, this detail has no records on the chain of this * key value. * DLD PTADR,I Path count is a doubleword value. SZB,RSS SZA JMP FND5 JMP E156 * * Path count not zero. Move chain information into the detail's Data * Set Control Block and the status array as follows: * * current search item # -> high order byte of 11th word of DSCB * current path number -> low order byte of 11th word of DSCB * current record # = 0 -> 3rd & 4th words of STAT array * and 12th & 13th words of DSCB * path count -> 5th & 6th words of STAT array * previous record # = * record # of chain foot-> 7th & 8th words of STAT array * and 14th and 15th words of DSCB * next record # = * record # of chain head-> 9th & 10th words of STAT array * and 16th & 17th words of DSCB * FND5 LDA STAT Set TEMP to point to the 2nd INA word of the STATus array. STA TEMP * LDB STADR ADB DSCPN LDA ITNUM } Combined key item number IOR PTNUM ] and path number in DSCB STA B,I * INB Bump place in DSCB to STB STADR record number holders. * CLA CLB STA TEMP,I Pad 2nd word of STAT with a zero ISZ TEMP and bump to current record # holder. * DST STADR,I Current record # = 0. DST TEMP,I * LDA PTADR Path count, chain foot, and chain head LDB TEMP into STAT array. ADB D2 JSB .MVW DEF D6 DEC 0 * LDA PTADR Chain foot and chain head ADA D2 LDB STADR into DSCB ADB D2 JSB .MVW DEF D4 DEC 0 * * Return successful to user. * CLA Zero to status word in STAT. FND6 STA STAT,I FND7 CLA Set ARG to zero for STA ARG param check on next entry. JMP DBFND,I * * Error return points. * ERREX SSA Here on an error from DBHRD, CMA,INA if negative make it positive. JMP FND6 E100 LDA D100 Invalid data set reference. JMP FND6 E101 LDA D101 Invalid data item reference. JMP FND6 E102 LDA D102 Invalid search (key) item. JMP FND6 E103 LDA D103 Improperly opened data base. JMP FND6 E107 LDA D107 No master record with key value. JMP FND6 E115 LDA D115 Illegal DBFND mode. JMP FND6 E120 LDA D120 Data set not a detail JMP FND6 E121 LDA D121 Detail has no paths. JMP FND6 E156 LDA D156 No detail records on chain. JMP FND6 E160 LDA D160 Corrupt Run Table. JMP FND6 E162 LDA D162 Missing parameter. JMP FND6 * * Constants and variables. * D1 EQU ZERO+1 D2 EQU ZERO+2 D4 EQU ZERO+4 D5 EQU ZERO+5 D6 EQU ZERO+6 D100 DEC 100 D101 DEC 101 D102 DEC 102 D103 DEC 103 D107 DEC 107 D115 DEC 115 D120 DEC 120 D121 DEC 121 D156 DEC 156 D160 DEC 160 D162 DEC 162 * LOBYT OCT 377 HIBYT OCT 177400 * FLAG NOP ERROR NOP STNUM NOP DSNUM NOP STADR NOP ITNUM NOP ITADR NOP PTADR NOP CNTR NOP PTNUM NOP RECRD BSS 2 MSADR NOP TEMP NOP END