ASMB,L,C,R HED RBBST UTILITY SUBROUTINE FOR RDBA-IMAGE/1000 NAM RBBST,7 92069-16226 REV.1912 790130 * * ******************************************************************* * (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-18226 * RELOC: 92069-16226 * * PRGMR: CEJ * * ******************************************************************* * * * * Build Sort Table is a subroutine for RBOPN which builds the Sort Table * in the local Run Table for Remote Data Base Access. RBBST builds the * Sort Table by doing a straight sort on the entries, adding a new entry * in the Sort Table immediately before the first entry which has a name * higher in alphabetical order than the entry to be added. (The item * and set sort tables are arranged in ascending alphabetical order based * on their names.) Each entry in the Sort Table is one word long and * contains a pointer to the item's or set's entry in the Item or Set * Table. The Sort Table is built in the order: item sort table, set sort * table. * * One additional function of RBBST is to determine and return the length * in words of the longest entry of any data set in the data base. * * The calling sequence for RBBST is: * * JSB RBBST * DEF *+2 return point * DEF LENTH returned longest entry length * * When RBBST is entered, all of the Run Table except the Sort Table is * assumed to have been built. * 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 * * * *** *** * A EQU 0 B EQU 1 * ENT RBBST EXT .CMW,.ENTR,AIRUN * LENTH NOP * * Get true parameter and return point addresses. * RBBST NOP JSB .ENTR DEF LENTH * * Get the data item count from the DBCB (8th word) and negate it as a * loop counter. * LDB AIRUN ADB RDITC LDA B,I SZA,RSS If no items are accessible, JMP BST5 no sort table to build. CMA,INA STA CNTR1 * * Get the item table pointer from the DBCB (9th word). * INB LDA B,I STA CURNT * * Get the Sort Table pointer from the DBCB (12th word) and resolve it * with the address of the Run Table. * ADB D3 LDA B,I ADA AIRUN STA STADR * * Set sorted count to zero. * CLA STA COUNT * * Put pointer to first item table entry into first location in the Sort * Table. * LDB CURNT STB STADR,I * * Increment sorted count. * BST1 ISZ COUNT * * Get next item's Item Table pointer by adding RI1LN to CURNT pointer. * LDB CURNT ADB RI1LN STB CURNT * * If there is another Item Table entry, ask SORT to put it into proper * position in Sort Table. * ISZ CNTR1 RSS JMP BST2 No more items. * JSB SORT JMP BST1 * * Done with item sort so, set up for set sort. * * Set longest entry length to zero. * BST2 CLA STA LENTH,I * * Get the data set count from the DBCB (10th word) and negate it as a * loop counter. * LDB AIRUN ADB RDDSC LDA B,I * SZA,RSS If no sets, JMP BST5 done with sort. * CMA,INA STA CNTR1 * * Get Set Table pointer from the DBCB (11th word) * INB LDA B,I STA CURNT * * Get set sort table pointer = address of sort table + number of sorted * items. * LDA STADR ADA COUNT STA STADR * * Put first set entry pointer into first location in the Sort Table. * LDB CURNT STB STADR,I * * Set sorted count to one, then go put entry length in LENTH. * CLA,INA STA COUNT * JMP BST4 * * Get next set's Set Table pointer by adding RS1LN to CURNT pointer. * BST3 LDB CURNT ADB RS1LN STB CURNT * * If there is another set, ask SORT to put it into proper position in * Sort Table. * ISZ CNTR1 RSS JMP BST5 No more sets - done with sort. * JSB SORT * * Increment sorted count. * ISZ COUNT * * Get this set's entry length and, if it is longer than the current long- * est entry, put its length into the LENTH parameter. * BST4 LDB CURNT Entry length is in 5th ADB AIRUN word of Set Table entry. ADB RS1EL * LDA B,I CMA,INA ADA LENTH,I SSA,RSS If it is not longer, JMP BST3 just continue with next set. * LDA B,I STA LENTH,I JMP BST3 * * Return to caller when done. * BST5 JMP RBBST,I SKP * * This is the actual sort. * First set up the sort parameters. Use the negative of the number of * entries already in sort table as a counter. * SORT NOP LDA COUNT CMA,INA STA CNTR2 * * Get the actual address of the entry whose pointer (in CURNT) is to be * put in the Sort Table. * LDA CURNT ADA AIRUN STA ENTRY * * Make a copy of the sort table address for easy incrementing. * LDA STADR STA NEXT * * BEGIN SORT * Ask CMW to compare names of the next entry in the sort table and the * entry we want to add. * SORT1 LDB NEXT,I ADB AIRUN B = address of next's name. LDA ENTRY A = address of new entry's name. * JSB .CMW DEF D3 DEC 0 * RSS Names the same JMP SORT2 Next's name > new name. * * Here when names the same or new entry's name > next's name. Get next * entry in Sort Table (if there is one) and continue search for proper * location for new. * ISZ NEXT ISZ CNTR2 JMP SORT1 * * No more entries. The new one belongs at the end of the table (now * pointed to by NEXT). * LDA CURNT STA NEXT,I JMP SORT4 And we are done. * * Here when the new entry's name < next entry's. The new entry belongs * in the entry occupied by next. Put it there and move all the entries * starting with next down one. * SORT2 LDA CURNT * SORT3 LDB NEXT,I Save current entry in next STA NEXT,I and put in new one. * LDA B ISZ NEXT Continue for all ISZ CNTR2 entries in table. JMP SORT3 STA NEXT,I * SORT4 JMP SORT,I Then, return to caller. * * Constants and variables. * D3 EQU ZERO+3 * CNTR1 NOP CURNT NOP STADR NOP COUNT NOP CNTR2 NOP ENTRY NOP NEXT NOP END $END