forked from dspinellis/unix-history-repo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
s4.s
334 lines (314 loc) · 3.86 KB
/
s4.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
" s4
alloc: 0
-1
tad s.nfblks
spa
jmp 1f
dac s.nfblks
tad fblksp
jms laci
dac 9f+t
jms copyz; dskbuf; 64
lac 9f+t
jms dskwr
dzm .savblk
lac 9f+t
jmp alloc i
1:
lac s.nxfblk
sna
jms halt " OUT OF DISK
dac s.fblks
jms dskrd
lac dskbuf
dac s.nxfblk
jms copy; dskbuf+1; s.fblks+1; 9
lac d10
dac s.nfblks
jmp alloc+1
free: 0
lmq
lac s.nfblks
sad d10
jmp 1f
tad fblksp
dac 9f+t
lacq
dac 9f+t i
dzm .savblk
isz s.nfblks
jmp free i
1:
lac s.nxfblk
dac dskbuf
jms copy; s.fblks+1; dskbuf+1; 9
lacq
dac s.nxfblk
jms dskwr
dzm .savblk
lac d1
dac s.nfblks
jmp free i
t = t+1
laci: 0
and o17777
tad o200000
dac .+1
lac ..
jmp laci i
betwen: 0
lmq cmq
lac betwen i
dac 9f+t
isz betwen
lacq
tad 9f+t i
sma
jmp 1f
lac betwen i
dac 9f+t
isz betwen
lacq
tad 9f+t i
cma
spa sna
1:
isz betwen
lacq
cma
jmp betwen i
copy: 0
-1
tad copy i
dac 8
isz copy
-1
tad copy i
dac 9
isz copy
-1
tad copy i
cma
dac 9f+t
isz copy
1:
lac 8 i
dac 9 i
isz 9f+t
jmp 1b
jmp copy i
copyz: 0
-1
tad copyz i
dac 8
isz copyz
-1
tad copyz i
cma
dac 9f+t
isz copyz
1:
dzm 8 i
isz 9f+t
jmp 1b
jmp copyz i
t = t+1
putchar: 0
dac 9f+t
cla
jms takeq
jmp putchar i
tad o40001
dac .+4
lac 9f+t
jms putq
lac char
dac q2+1 ..
isz putchar
jmp putchar i
t = t+1
getchar: 0
jms takeq
jmp i getchar
tad o200001
dac .+3
cla
jms putq
lac q2+1 ..
isz getchar
jmp i getchar
takeq: 0
rcl
tad lacq1
dac .+7
tad o640000
dac .+17
tad d1
dac .+14
tad o500000
dac .+5
lac q1 ..
sna
jmp takeq i
dac lnkaddr
sad q1+1 ..
jmp .+5
tad o200000
dac .+1
lac q2 ..
jmp .+3
cla
dac q1+1 ..
dac q1 ..
isz takeq
lac lnkaddr
jmp i takeq
putq: 0
rcl
tad dacq1
dac .+14
tad d1
dac .+13
tad o140000
dac .+1
lac q1-1 ..
sna
jmp .+6
tad o40000
dac .+2
lac lnkaddr
dac q2 ..
jmp .+3
lac lnkaddr
dac q1 ..
dac q1+1 ..
jmp putq i
srcdbs: 0
dac 9f+t+2 "* lmq
-ndskbs
dac 9f+t
law dskbs "* -1 dac 8 written
dac 9f+t+1 "* lacq
1:
jmp srcdbs i
isz 9f+t+1
isz 9f+t
jmp 1b
isz srcdbs
jmp srcdbs i
collapse: 0
cla
jms srcdbs
jmp 1f
law dskbs
1:
dac 0f+1
dac 0f
cma
tad d1
tad edskbsp
and o17777
sna
jmp 0f+3
dac 0f+2
jms copy; 0:..; ..; ..
-65
tad edskbsp
dac 9f+t
tad d1
dac 0f
lac dskaddr
dac 9f+t i
jms copy; dskbuf; 0:..; 64
jmp collapse i
dskrd: 0
jms betwen; d2; d7999
jms halt
sad dskaddr
jmp dskrd i
dac dskaddr
jms srcdbs
jmp 1f
lac dskaddr
jms dskio; 06000
jmp 2f
1:
dzm 9f+t+1 i
law 1
tad 9f+t+1
dac .+2
jms copy; ..; dskbuf; 64
2:
jms collapse
jmp dskrd i
dskwr: 0
jms betwen; d2; d7999
jms halt
jms dskio; 07000
lac dskaddr
jms srcdbs
dzm 9f+t+1 i
jms collapse
jmp dskwr i
t = t+3
dskio: 0
dac dskaddr
cll; idiv; 80
dac 9f+t
lacq
idiv; 10
dac 9f+t+1
lls 22
xor 9f+t+1
als 8
dac 9f+t+1
lac 9f+t
idiv; 10
dac 9f+t
lls 22
xor 9f+t
xor 9f+t+1
xor o200000
dac 9f+t
jms dsktrans; -64; dskbuf; 9f+t; dskio
isz dskio
jmp dskio i
t = t+1
dsktrans: 0
-10
dac 9f+t
1:
-1
tad dsktrans
dac 12
dscs
lac 12 i
dslw
lac 12 i
dslm
lac 12 i
jms laci
dsld
dzm .dskb
lac 12 i
jms laci
jms laci
dsls
lac .dskb
sna
jmp .-2
lac .dske
sma
jmp 12 i
isz 9f+t
jmp 1b
jms halt " 10 disk errors
t = t+1
halt: 0
isz 9f+t
jmp .-1
iof
hlt
jms copy; law; 4096; 4096
hlt; jmp .-1
t = t+1