1 " ******************************************************
  2 " *                                                    *
  3 " * Copyright, (C) Honeywell Bull Inc., 1987           *
  4 " *                                                    *
  5 " * Copyright (c) 1986 by Massachusetts Institute of   *
  6 " * Technology and Honeywell Information Systems, Inc. *
  7 " *                                                    *
  8 " * Copyright (c) 1972 by Massachusetts Institute of   *
  9 " * Technology and Honeywell Information Systems, Inc. *
 10 " *                                                    *
 11 " ******************************************************
 12 
 13 "
 14 "         search_ast.alm      -fast AST searcher
 15 "         Jan. 19, 1976 by Bernard Greenberg
 16 "         Modified December 1981 by J. Bongiovanni for new hash table
 17 "         Modified May 1983 by E. N. Kittlitz for check entry.
 18 "
 19 """       search_ast entry
 20 "         astep = search_ast (uid);
 21 "
 22 "         astep = null if UID not active.
 23 "
 24 "
 25 """       check entry
 26 "         astep = search_ast$check (uid, pvid, vtocx, code);
 27 "
 28 "         if astep ^= null, code is 0
 29 "         if astep = null then
 30 "                   if code = 0, segment is just not active
 31 "                   else uid was matched by search, but pvid or vtocx of aste
 32 "                             did not match supplied pvid/vtocx.
 33 
 34           name      search_ast
 35           entry     search_ast,check,hash_in,hash_out
 36 
 37 search_ast:                             "astep = search_ast (uid);
 38           eax1      4
 39           tra       search_ast_join
 40 
 41 check:                                  "astep = search_ast (uid, pvid, vtocx, code);
 42           eax1      10
 43           stz       ap|8,*              zero code
 44 
 45 search_ast_join:
 46           lda       ap|2,*              get uid
 47           tsx0      search              look it up
 48           tra       search_ast_fails    not there
 49           cmpx1     =4,du               search_ast entry?
 50           tze       search_ast_succeeds sure enough
 51           lda       bp|aste.vtocx       double-check the aste
 52           ana       =o777777,dl         just vtocx...
 53           cmpa      ap|6,*              compare with desired vtocx
 54           tnz       search_ast_fails_check oh dear, fooled by scrambled uid
 55           ldq       bp|aste.pvtx_word   and now triple-check
 56           qrl       aste.pvtx_shift     ASTE PVTX in QL
 57           anq       aste.pvtx_mask,dl   nice and tidy
 58           mpy       pvte_size,dl        index into array
 59           lda       pvt$array+pvte.pvid-pvte_size,ql pvt is (1:n). get pvid
 60           cmpa      ap|4,*              compare with pvid supplied
 61           tnz       search_ast_fails_check tricky fellow
 62 
 63 search_ast_succeeds:
 64           spribp    ap|0,x1*            found astep
 65           short_return
 66 
 67 search_ast_fails:
 68           eppbp     null,*              not found
 69           spribp    ap|0,x1*
 70           short_return
 71 
 72 search_ast_fails_check:
 73           lda       error_table_$vtoce_connection_fail
 74           sta       ap|8,*              return code
 75           eppbp     null,*              null return value
 76           spribp    ap|0,x1*
 77           tra       alm_syserr_caller$search_ast_double_uid " returns to our caller
 78 
 79 ^L
 80 hash_in:            "call search_ast$hash_in (astep), uid having been set.
 81 
 82           eppbp     ap|2,*
 83           eppbp     bp|0,*              arg is ptr
 84           lda       bp|aste.uid
 85           tsx0      search              look it up
 86           tra       *+2                 not found
 87           tra       err                 found, this is wrong
 88           ldx2      lb|0,3              get current list head
 89           sarbp     lb|0,3              set new guy
 90           stx2      bp|aste.ht_fp       splice in
 91           short_return
 92 
 93 
 94 hash_out:           "call search_ast$hash_out (astep), uid having been set
 95 
 96           eppbp     ap|2,*
 97           eppbp     bp|0,*
 98           lda       bp|aste.uid
 99           tsx0      search
100           tra       err                 must be found
101           ldx2      bp|aste.ht_fp       save next ptr
102           eax4      0,4                 were we first?
103           tze       were_first
104           stx2      bb|aste.ht_fp,4     thread last to next, not first
105           eax4      0
106           stx4      bp|aste.ht_fp       clear thread
107           short_return
108 
109 were_first:
110           stx4      bp|aste.ht_fp       clear thread
111           stx2      lb|0,3              thread out
112           short_return
113 
114 ^L
115 "
116 "         search -internal procedure to do actual search
117 "         Called with uid in A, returns to call + 1 if not found
118 "         Returns to call + 2 if found, bp and x6 point to ASTE,
119 "         x4 is 0 if first, otherwise x4 -> previous. bb -> sst
120 "         lb -> AST hash table, x3 -> slot in table
121 
122 search:   eppbb     sst$
123           epplb     sst$ast_ht_ptr
124           epplb     lb|0,*              lb -> AST hash table
125           eaq       0,al
126           qrl       18
127           anq       sst$ast_ht_uid_mask
128           eax3      0,ql                get hash index in x3
129           eax4      0                   set first time sw
130 
131           ldx6      lb|0,3              start at head
132           tze       0,0                 if 0, nothing in list
133 lp:       cmpa      bb|aste.uid,6       is this the one?
134           tze       found               yes
135           eax4      0,6                 save prev ptr
136           ldx6      bb|aste.ht_fp,6     move up
137           tnz       lp                  if stuff, loop
138           tra       0,0                 no stuff, not found
139 found:    eppbp     bb|0,6
140           tra       1,0
141 
142 err:      call      alm_syserr_caller$search_ast_hash_error,(null_argl)
143           tra       err
144 
145           even
146 null:     its       -1,1
147 null_argl:zero      0,0
148           zero      0,0
149 ^L
150           include   aste
151 ^L
152           include   pvte
153 
154           end