ASMB,L,C,R HED DBDEX UTILITY SUBROUTINE FOR IMAGE/1000 NAM DBDEX,7 92069-16146 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-18146 * RELOC: 92069-16146 * * PRGMR: CEJ * * ******************************************************************* * * * * Deallocate EXtras is a utility subroutine for DBCLS. Its function is * to trim off any extra words in the record buffer and dealocate any * DCBs needed solely by the data base being closed. We will deallocate * only DCBs that are not currently in use even if the DCBs are extra to * other data bases. * * All parameters used by DBDEX are global. * * The calling sequence for DBDEX is: * * JSB DBDEX * DEF *+1 return point * * * ENT DBDEX EXT .ENTR,AIRUN,DBDCP,DBDCT,DBDMX,DBRBL,DBRBP,DBRTM EXT DBRTP,RETBF,TRIM * A EQU 0 B EQU 1 * * First we want to determine the maximum record buffer size and number * of DCBs needed by any other data base open to the program. We do this * by looping through all the entries in the Run Table pointer table and * for each entry which contains a Run Table pointer (entry NE 0) which * is not the same as the pointer to the current Run Table, we compare * the optimal number of DCBs (16th word of DBCB) and maximum entry length * (17th word of DBCB) to those which we have already saved. If greater * than the saved, we replace that saved with this Run Table's value. * DBDEX NOP JSB .ENTR DEF DBDEX * * Set up for loop. * LDA DBRTP Get address of R.T. STA PTRAD pointer table. * LDA DBRTM Use negative of number of CMA,INA entries in table as STA CNTR the loop counter. * CLA A zero to both STA MXLEN saved length STA #DCBS and number of DCBs * * BEGIN LOOP * DEX1 LDA PTRAD,I SZA,RSS JMP DEX3 * CPA AIRUN JMP DEX3 * ADA DBOPT First compare # of DCBs. LDB A,I CMB,INB ADB #DCBS SSB,RSS JMP DEX2 * LDB A,I STB #DCBS * DEX2 INA Then, the entry length. LDB A,I CMB,INB ADB MXLEN SSB,RSS JMP DEX3 * LDB A,I STB MXLEN * DEX3 ISZ PTRAD Continue for all Run ISZ CNTR Table pointer table entries. JMP DEX1 * * END LOOP * * Now determine the amount of the record buffer we want to keep and trim * off rest by : * EXTRA = MXLEN - length needed by data base being closed * IF (EXTRA.GE.0) THEN skip trim * ELSE Call TRIM with amount to keep = MXLEN. * LDA AIRUN ADA DBMAX LDB A,I CMB,INB ADB MXLEN SSB,RSS JMP DEX4 * JSB TRIM DEF *+3 DEF DBRBP DEF MXLEN * SSA If TRIM gave us an error JMP DEXER memory has been destroyed. * LDA MXLEN Else, set record buffer length STA DBRBL to new length. * * Finally, determine the number of DCBs we want to deallocate and for * each DCB to deallocate find an unused DCB and call RETBF, then signi- * fy in the DCB pointer table that the entry is empty by: * EXTRA = #DCBS - DCB allocated count * IF (EXTRA.GE.0) THEN Return to caller * ELSE FOR i = 1 to -(EXTRA) * WHILE an entry remains in DCB pointer table DO * IF (entry in pointer table shows an unused DCB i.e. if first * word of entry .EQ. zero) * THEN Deallocate DCB pointed to by entry * END WHILE * END FOR * * Each entry in the DCB pointer table looks like: * word +---------------------------------+ * 1 | data base # | data set # |-> -1 if DCB unused * ----------------------------------- 0 if entry empty * 2 | DCB address | * +---------------------------------+ * 15 8 7 0 bit * DEX4 LDB DBDCT CMB,INB ADB #DCBS B = EXTRA SSB,RSS JMP DEXE * * Set up loop * STB CNTR Major loop counter = -(EXTRA) * LDB DBDMX Minor loop counter= CMB,INB negative of # of entries STB CNTR2 in DCB pointer table. * LDB DBDCP Get address of DCB STB PTRAD pointer table. * * BEGIN MAJOR LOOP * * BEGIN MINOR LOOP * DEX5 LDA PTRAD,I Does this entry contain ISZ PTRAD an unused DCB? SSA JMP DEX7 * DEX6 ISZ PTRAD No - get next entry address ISZ CNTR2 if there is another JMP DEX5 and try it. * * END OF MINOR LOOP * JMP DEXE * DEX7 JSB RETBF Yes - deallocate its DCB. DEF *+2 DEF PTRAD,I * SSA If any error, JMP DEXER memory is bad. * CCA Set first word of ADA PTRAD pointer table entry CLB to zero (unused entry). STB A,I * CCA ADA DBDCT Decrement the DCB count. STA DBDCT * ISZ CNTR If more to deallocate JMP DEX6 go try. * * END OF MAJOR LOOP * * * Return to caller (DBCLS). * DEXE ISZ DBDEX DEXER JMP DBDEX,I * * Constants and variables. * DBOPT DEC 15 DBMAX DEC 16 * #DCBS NOP MXLEN NOP CNTR NOP CNTR2 NOP PTRAD NOP END END$