Bell 32V development
[unix-history] / .ref-Research-V7 / usr / mdec / rpuboot.s
CommitLineData
736d93cd
KT
1/ disk boot program to load and transfer
2/ to a unix entry
3
4/ entry is made by jsr pc,*$0
5/ so return can be rts pc
6
7core = 28.
8.. = [core*2048.]-512.
9
10/ establish sp and check if running below
11/ intended origin, if so, copy
12/ program up to 'core' K words.
13start:
14 mov $..,sp
15 mov sp,r1
16 cmp pc,r1
17 bhis 2f
18 clr r0
19 cmp (r0),$407
20 bne 1f
21 mov $20,r0
221:
23 mov (r0)+,(r1)+
24 cmp r1,$end
25 blo 1b
26 jmp (sp)
27
28/ clear core to make things clean
292:
30 clr (r0)+
31 cmp r0,sp
32 blo 2b
33
34/ at origin, read pathname,
35/ initialize rp
36
37 clr *$rpcs / selects drive zero
38/ spread out in array 'names', one
39/ component every 14 bytes.
40 mov $names,r1
411:
42 mov r1,r2
432:
44 jsr pc,getc
45 cmp r0,$'\n
46 beq 1f
47 cmp r0,$'/
48 beq 3f
49 movb r0,(r2)+
50 br 2b
513:
52 cmp r1,r2
53 beq 2b
54 add $14.,r1
55 br 1b
56
57/ now start reading the inodes
58/ starting at the root and
59/ going through directories
601:
61 mov $names,r1
62 mov $2,r0
631:
64 clr bno
65 jsr pc,iget
66 tst (r1)
67 beq 1f
682:
69 jsr pc,rmblk
70 br start
71 mov $buf,r2
723:
73 mov r1,r3
74 mov r2,r4
75 add $16.,r2
76 tst (r4)+
77 beq 5f
784:
79 cmpb (r3)+,(r4)+
80 bne 5f
81 cmp r4,r2
82 blo 4b
83 mov -16.(r2),r0
84 add $14.,r1
85 br 1b
865:
87 cmp r2,$buf+512.
88 blo 3b
89 br 2b
90
91/ read file into core until
92/ a mapping error, (no disk address)
931:
94 clr r1
951:
96 jsr pc,rmblk
97 br 1f
98 mov $buf,r2
992:
100 mov (r2)+,(r1)+
101 cmp r2,$buf+512.
102 blo 2b
103 br 1b
104/ relocate core around
105/ assembler header
1061:
107 clr r0
108 cmp (r0),$407
109 bne 2f
1101:
111 mov 20(r0),(r0)+
112 cmp r0,sp
113 blo 1b
114/ enter program and
115/ restart if return
1162:
117 jsr pc,*$0
118 br start
119
120/ get the inode specified in r0
121iget:
122 add $15.,r0
123 mov r0,r5
124 ash $-3.,r0
125 bic $!17777,r0
126 mov r0,dno
127 clr r0
128 jsr pc,rblk
129 bic $!7,r5
130 ash $6,r5
131 add $buf,r5
132 mov $inod,r4
1331:
134 mov (r5)+,(r4)+
135 cmp r4,$inod+64.
136 blo 1b
137 rts pc
138
139/ read a mapped block
140/ offset in file is in bno.
141/ skip if success, no skip if fail
142/ the algorithm only handles a single
143/ indirect block. that means that
144/ files longer than 10+128 blocks cannot
145/ be loaded.
146rmblk:
147 add $2,(sp)
148 mov bno,r0
149 cmp r0,$10.
150 blt 1f
151 mov $10.,r0
1521:
153 mov r0,-(sp)
154 asl r0
155 add (sp)+,r0
156 add $addr+1,r0
157 movb (r0)+,dno
158 movb (r0)+,dno+1
159 movb -3(r0),r0
160 bne 1f
161 tst dno
162 beq 2f
1631:
164 jsr pc,rblk
165 mov bno,r0
166 inc bno
167 sub $10.,r0
168 blt 1f
169 ash $2,r0
170 mov buf+2(r0),dno
171 mov buf(r0),r0
172 bne rblk
173 tst dno
174 bne rblk
1752:
176 sub $2,(sp)
1771:
178 rts pc
179
180cyl = 0.
181read = 4
182go = 1
183
184rpcs = 176710
185rpda = 176724
186rpca = 176722
187rpba = 176720
188/ rp03 disk driver.
189/ low order address in dno,
190/ high order in r0.
191rblk:
192 mov r1,-(sp)
193 mov dno,r1
194 div $20.*10.,r0
195/ add $cyl,r0
196 mov r0,*$rpca
197 clr r0
198 div $10.,r0
199 swab r0
200 bis r1,r0
201 mov r0,*$rpda
202 mov $rpba,r1
203 mov $buf,(r1)
204 mov $-256.,-(r1)
205 mov $read+go,-(r1)
2061:
207 tstb (r1)
208 bge 1b
209 mov (sp)+,r1
210 rts pc
211
212tks = 177560
213tkb = 177562
214/ read and echo a teletype character
215getc:
216 mov $tks,r0
217 inc (r0)
2181:
219 tstb (r0)
220 bge 1b
221 mov tkb,r0
222 bic $!177,r0
223 cmp r0,$'A
224 blo 1f
225 cmp r0,$'Z
226 bhi 1f
227 add $'a-'A,r0
2281:
229
230tps = 177564
231tpb = 177566
232/ print a teletype character
233putc:
234 tstb *$tps
235 bge putc
236 mov r0,*$tpb
237 cmp r0,$'\r
238 bne 1f
239 mov $'\n,r0
240 br putc
2411:
242 rts pc
243
244end:
245inod = ..-1024.
246addr = inod+12.
247buf = inod+64.
248bno = buf+512.
249dno = bno+2
250names = dno+2
251reset = 5