ASMB,L,C,R
      HED DBCBI IMAGE/1000 UTILITY SUBROUTINE 
      NAM DBCBI,7 92069-16152 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-18152
*     RELOC:     92069-16152
* 
*     PRGMR:     CEJ
* 
* 
******************************************************************* 
* 
* 
* 
*  Compute Buffer Index determines the index of the specified item into 
*  the buffer parameter (ibuf) passed by the user to an IMAGE subroutine. 
* 
*  DBCBI searches through the information table (TEMPX) set up by DBPIL 
*  calculating the index as follows:
* 
*    Index = 0 + word length of all items preceding the specified item in 
*            the information table. 
* 
*  The calling sequence for DBCBI is: 
* 
*               JSB DBCBI 
*                DEF *+3       return point 
*                DEF ITEM      data item number 
*                DEF INDEX     returned index into ibuf parameter,
*                                -1 if item not in information table
* 
      EXT .ENTR,TEMPX 
      ENT DBCBI 
A     EQU 0 
B     EQU 1 
* 
ITEM  NOP 
INDEX NOP 
* 
*  Get true addresses of parameters and return point. 
* 
DBCBI NOP 
      JSB .ENTR 
       DEF ITEM 
* 
*  Initialize search parameters.
* 
      CLA 
      STA TOTAL     Zero to running length. 
      CMA 
      STA INDEX,I   -1 to INDEX 
* 
      LDA TEMPX     Set up information table address
      STA NEXT        for loop. 
* 
*  Loop on each entry in information table until a zero item number is
*  found or the specified item is found, adding each item's length to 
*  the running length.
* 
CBI1  LDA NEXT,I    Get next item number. 
      SZA,RSS       If zero - return unsuccessful to caller.
      JMP CBI3
* 
      AND LOBYT 
      CPA ITEM,I    If same as specified item - 
      JMP CBI2        return successful to user.
* 
      ISZ NEXT      Else get address of length of item
      LDA NEXT,I      then get length and add to
      ADA TOTAL       running length. 
      STA TOTAL 
* 
      ISZ NEXT      Get next entry
      ISZ NEXT
      JMP CBI1        and check it. 
* 
*  When (if) item found, put running length in INDEX. 
* 
CBI2  LDA TOTAL 
      STA INDEX,I 
CBI3  JMP DBCBI,I     and return. 
* 
*  Constants and variables
* 
LOBYT OCT 377 
TOTAL NOP 
NEXT  NOP 
      END 
                                                                                    