1 " ***********************************************************
  2 " *                                                         *
  3 " * Copyright, (C) Honeywell Bull Inc., 1987                *
  4 " *                                                         *
  5 " * Copyright, (C) Honeywell Information Systems Inc., 1984 *
  6 " *                                                         *
  7 " ***********************************************************
  8           name      bootload_linker
  9 
 10 " Prelinker for collection 1.
 11 " Stolen from pre_link_(1 2), November 1982, by C. Hornig
 12 
 13           include   bootload_equs
 14           include_nolist      slt
 15 " ^L
 16 new_link: bss       ,2
 17 type_pair:bss       ,2
 18 link_ptr: bss       ,2
 19 def_ptr:  bss       ,2
 20 segno:    bss       ,1
 21 linkp:    bss       ,1
 22 limit:    bss       ,1
 23 last_pair:bss       ,1
 24 exp_word: bss       ,1
 25 pass:     bss       ,1
 26 segname:  aci       "",32
 27 ename:    aci       "",32
 28 
 29           segdef    prelink
 30           segdef    segname
 31           segdef    ename
 32 
 33 prelink:
 34           Bpush
 35 
 36           lxl0      slt|slt.first_init_seg        " prelink the init segs
 37           lxl1      slt|slt.last_init_seg
 38           tsx2      scan_sltes
 39 
 40           lxl0      slt|slt.first_sup_seg         " and the sup segs
 41           lxl1      slt|slt.last_sup_seg
 42           tsx2      scan_sltes
 43 
 44           Breturn                                 " that's all, folks
 45 " ^L
 46 scan_sltes:
 47           Bpush
 48 
 49           sxl0      segno
 50           stx1      limit                         " save the limit
 51 
 52 scan_loop:
 53           szn       bootload_info$lot_ptr,*x0
 54           tnz       check_links
 55 
 56 scan_next:
 57           aos       segno                         " next segment
 58           lxl0      segno
 59           cmpx0     limit                         " done?
 60           tmoz      scan_loop                     " no
 61 
 62           Breturn                                 " yes
 63 " ^L
 64 " We have a linkage section.
 65 
 66 check_links:
 67           lprp      seg2,bootload_info$lot_ptr,*x0 " SEG2 -> linkage
 68           spri1     link_ptr
 69           epp       seg,seg2|0,*                  " SEG -> definitions
 70           spri6     def_ptr
 71 
 72           lxl7      seg2|6                        " last link pair
 73           stx7      last_pair
 74 
 75           ldx1      seg2|6                        " X1 -> 1st link pair
 76 
 77 link_loop:
 78           cmpx1     last_pair                     " done?
 79           tpl       scan_next                     " yes
 80 
 81           stx1      linkp
 82           epp       seg2,link_ptr,*               " SEG2 -> linkage
 83           epp       seg,def_ptr,*                 " SEG -> definitions
 84 
 85           lxl7      seg2|0,x1                     " look at tag field
 86           cmpx7     =o46,du                       " FT2?
 87           tnz       next_pair                     " no
 88 
 89 " start work on the link
 90 
 91           ldx7      seg2|1,x1                     " get exp_ptr
 92           lda       seg|0,x7                      " get expression word
 93           sta       exp_word                      " save it
 94 
 95           ldq       seg|1,au                      " get type pair
 96           lda       seg|0,au                      " get type pair
 97           staq      type_pair                     " save it
 98 
 99           tra       *+1,au                        " dispatch
100           tra       next_pair                     " (0) unknown
101           tra       type_1a                       " (1) *|exp,m
102           tra       next_pair                     " (2)
103           tra       type_3a                       " (3)
104           tra       type_4a                       " (4)
105           tra       next_pair                     " (5)
106           tra       type_6a                       " (6)
107 
108 type_1a:  tra       *+1,qu                        " dispatch
109           tra       t1_text
110           tra       t1_link
111           tra       next_pair
112 
113 t1_text:  ldx7      seg2|7                        " get the segment number
114           easp      seg,0,x7                      " pointer
115           spri6     new_link
116           tra       done
117 
118 t1_link:  spri1     new_link                      " linkage ptr
119           tra       done
120 
121 type_3a:  tsx2      find_seg                      " find the segment
122           tra       next_pair
123           spri6     new_link
124           tra       done
125 
126 type_4a:  tsx2      find_seg                      " find the segment
127           tra       next_pair
128           tsx2      find_def
129           tra       next_pair
130           tra       done
131 
132 type_6a:  ldx7      seg|0,ql                      " look at acc length
133           canx7     =o777000,du                   " null?
134           tnz       type_4a
135           tra       type_3a
136 
137 done:     epp       seg2,link_ptr,*               " restore link ptr
138           ldx1      linkp                         " and offset
139           lxl7      seg2|1,x1                     " get the modifier
140           sxl7      new_link+1                    " store it
141           lxl7      exp_word                      " get exp
142           asx7      new_link+1                    " add it in
143 
144           ldaq      new_link                      " get the new ptr
145           staq      seg2|0,x1                     " store it
146 
147 next_pair:
148           ldx1      linkp                         " and offset
149           eax1      2,x1                          " on to the next
150           tra       link_loop
151 " ^L
152 find_seg:
153           Bpush
154 
155           epp       seg,seg|0,qu                  " get ptr to segname
156           lda       seg|0                         " get length
157           arl       9                             " in AU
158           mlr       (pr,rl),(),fill(040)          " copy it
159           desc9a    seg|0(1),au
160           desc9a    segname,32
161 
162           tsx2      bootload_slt_manager$get_seg_ptr
163           arg       segname
164           tra       find_seg_error
165           Breturn   1
166 find_seg_error:
167           Breturn   0
168 " ^L
169 find_def:
170           Bpush
171 
172           stz       pass                          " first pass
173           spri6     new_link                      " save the text pointer
174           lxl7      type_pair+1
175           epp       seg2,def_ptr,*x7              " SEG2 -> ename
176           lda       seg2|0                        " get length
177           arl       9                             " in AU
178           mlr       (pr,rl),(),fill(040)          " copy it
179           desc9a    seg2|0(1),au
180           desc9a    ename,32
181 
182           ldx7      new_link                      " get segment number
183           szn       bootload_info$lot_ptr,*x7     " segment?
184           tze       find_def_error
185 
186           lprp      seg2,bootload_info$lot_ptr,*x7 " get linkage ptr
187           epp       seg,seg2|0,*                  " SEG -> definitions
188           ldx3      seg|0                         " start with first def
189           tze       find_def_error
190 
191 next_def_3:
192           ldx7      seg|2,x3                      " get name ptr
193           epp       seg2,seg|0,x7                 " in SEG2
194           lda       seg2|0                        " get length
195           arl       9                             " in AU
196           cmpc      (pr,rl),(),fill(040)
197           desc9a    seg2|0(1),au
198           desc9a    segname,32
199           tze       found_def3
200 
201           ldx3      seg|1,x3                      " go to next type-3
202           tnz       next_def_3
203 
204 pass_2:   szn       pass                          " already done?
205           tnz       find_def_error                " yes
206 rescan:   ldx3      seg|0                         " start from scratch
207           stc1      pass                          " make full search
208           tra       next_def
209 
210 found_def3:
211           lxl3      seg|2,x3                      " check other defs
212           tze       pass_2
213 
214 next_def: ldx7      seg|2,x3                      " get name ptr
215           epp       seg2,seg|0,x7                 " in SEG2
216           lda       seg2|0                        " get length
217           arl       9                             " in AU
218           cmpc      (pr,rl),(),fill(040)
219           desc9a    seg2|0(1),au
220           desc9a    ename,32
221           tnz       def_no_match
222 
223           lxl7      seg|1,x3                      " get the class
224           anx7      =o7,du
225           tra       *+1,x7                        " dispatch
226           tra       d_text                        " 0
227           tra       d_link                        " 1
228           tra       find_def_error                " 2
229           tra       type_3                        " 3
230           tra       find_def_error                " 4
231 
232 type_3:   szn       pass                          " full search?
233           tze       rescan                        " no
234 
235 def_no_match:
236           ldx3      seg|0,x3                      " get next def
237           tnz       next_def
238           tra       pass_2
239 
240 
241 d_link:   ldx7      new_link
242           lprp      seg2,bootload_info$lot_ptr,*x7 " linkage
243           spri1     new_link
244 
245 d_text:   ldx7      seg|1,x3                      " value
246           asx7      new_link+1
247           Breturn   1
248 
249 find_def_error:
250           tsx2      bootload_error$no_sym
251           Breturn   0
252 
253           end       bootload_linker