forked from qrush/unix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathas26.s
450 lines (419 loc) · 4.74 KB
/
as26.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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
/ a6 -- pdp-11 assembler pass 2
opline:
mov r4,r0
jsr r5,betwen; 0; 177
br 2f
cmp r4,$5
beq opeof
cmp r4,$'<
bne xpr
jmp opl17
xpr:
jsr pc,expres
jsr pc,outw
rts pc
2:
movb symtab(r4),r0
cmp r0,$24
beq xpr
jsr r5,betwen; 5; 32
br xpr
mov symtab+2(r4),-(sp)
mov r0,-(sp)
jsr pc,readop
mov (sp)+,r0
asl r0
mov $adrbuf,r5
clr swapf
mov $-1,rlimit
jmp *1f-10.(r0)
1:
opl5
opl6
opl7
opl10
opl11
opl12
opl13
opl14
opl15
opl16
opl17
opl20
opl21
opl22
opl23
xpr
opl25
opl26
opl27
opl30
opl31
opl32
opeof:
mov $1,line
mov $20,-(sp)
mov $argb,r1
1:
jsr pc,readop
tst r4
bmi 1f
movb r4,(r1)+
dec (sp)
bgt 1b
tstb -(r1)
br 1b
1:
movb $'\n,(r1)+
clrb (r1)+
tst (sp)+
rts pc
opl30: / mpy, dvd etc
inc swapf
mov $1000,rlimit
br opl13
opl14: / flop freg,fsrc
inc swapf
opl5: / flop src,freg
mov $400,rlimit
/double
opl13:
jsr pc,addres
op2a:
mov r2,-(sp)
jsr pc,readop
op2b:
jsr pc,addres
tst swapf
beq 1f
mov (sp),r0
mov r2,(sp)
mov r0,r2
1:
swab (sp)
asr (sp)
asr (sp)
cmp (sp),rlimit
blo 1f
jsr r5,error; 'x
1:
bis (sp)+,r2
bis (sp)+,r2
clr r3
jsr pc,outw
mov $adrbuf,r1
1:
cmp r1,r5
bhis 1f
mov (r1)+,r2
mov (r1)+,r3
mov (r1)+,xsymbol
jsr pc,outw
br 1b
1:
rts pc
opl15: / single operand
clr -(sp)
br op2b
opl12: / movf
mov $400,rlimit
jsr pc,addres
cmp r2,$4 / see if source is fregister
blo 1f
inc swapf
br op2a
1:
mov $174000,(sp)
br op2a
/sob
opl31: / sob
jsr pc,expres
jsr pc,checkreg
swab r2
asr r2
asr r2
bis r2,(sp)
jsr pc,readop
jsr pc,expres
sub dot,r2
neg r2
mov r2,r0
jsr r5,betwen; -2; 175
br 2f
add $4,r2
br 1f
/branch
opl6:
jsr pc,expres
sub dot,r2
mov r2,r0
jsr r5,betwen; -254.; 256.
br 2f
1:
bit $1,r2
bne 2f
cmp r3,dot-2 / same relocation as .
bne 2f
asr r2
dec r2
bic $177400,r2
1:
bis (sp)+,r2
clr r3
jsr pc,outw
rts pc
2:
jsr r5,error; 'b
clr r2
br 1b
/jsr
opl7:
jsr pc,expres
jsr pc,checkreg
br op2a
/ rts
opl10:
jsr pc,expres
jsr pc,checkreg
br 1f
/ sys, emt etc
opl11:
jsr pc,expres
cmp r2,$64.
bhis 0f
cmp r3,$1
ble 1f
0:
jsr pc,errora
1:
bis (sp)+,r2
jsr pc,outw
rts pc
/ .byte
opl16:
jsr pc,expres
jsr pc,outb
cmp r4,$',
bne 1f
jsr pc,readop
br opl16
1:
tst (sp)+
rts pc
/ < (.ascii)
opl17:
jsr pc,readop
mov $1,r3
mov r4,r2
bmi 2f
bic $!377,r2
jsr pc,outb
br opl17
2:
jsr pc,readop
rts pc
/.even
opl20:
bit $1,dot
beq 1f
cmp dot-2,$4
beq 2f / bss mode
clr r2
clr r3
jsr pc,outb
br 1f
2:
inc dot
1:
tst (sp)+
rts pc
opl21: /if
jsr pc,expres
opl22:
oplret:
tst (sp)+
rts pc
/.globl
opl23:
cmp r4,$200
blo 1f
bisb $40,symtab(r4)
jsr pc,readop
cmp r4,$',
bne 1f
jsr pc,readop
br opl23
1:
tst (sp)+
rts pc
opl25:
opl26:
opl27:
mov r0,-(sp)
mov dot-2,r1
asl r1
mov dot,savdot-4(r1)
jsr r5,flush; txtp
jsr r5,flush; relp
mov (sp),r2
add $txtseek-[2*25],r2
mov r2,tseekp
mov (r2),r0
jsr r5,oset; txtp
add $trelseek-txtseek,r2
mov (r2),r0
mov r2,rseekp
jsr r5,oset; relp
mov (sp)+,r0
mov savdot-[2*25](r0),dot
asr r0
sub $25-2,r0
mov r0,dot-2 / new . relocation
tst (sp)+
rts pc
opl32:
cmp r4,$200
blo 1f
mov r4,-(sp)
jsr pc,readop
jsr pc,readop
jsr pc,expres
mov (sp)+,r0
bit $37,symtab(r0)
bne 1f
bis $40,symtab(r0)
mov r2,symtab+2(r0)
1:
tst (sp)+
rts pc
addres:
clr -(sp)
4:
cmp r4,$'(
beq alp
cmp r4,$'-
beq amin
cmp r4,$'$
beq adoll
cmp r4,$'*
bne getx
jmp astar
getx:
jsr pc,expres
cmp r4,$'(
bne 2f
jsr pc,readop
mov r2,(r5)+
mov r3,(r5)+
mov xsymbol,(r5)+
jsr pc,expres
jsr pc,checkreg
jsr pc,checkrp
bis $60,r2
bis (sp)+,r2
rts pc
2:
cmp r3,$24
bne 1f
jsr pc,checkreg
bis (sp)+,r2
rts pc
1:
mov r3,-(sp)
bic $40,r3
mov (sp)+,r3
bis $100000,r3
sub dot,r2
sub $4,r2
cmp r5,$adrbuf
beq 1f
sub $2,r2
1:
mov r2,(r5)+ / index
mov r3,(r5)+ / index reloc.
mov xsymbol,(r5)+ / index global
mov $67,r2 / address mode
bis (sp)+,r2
rts pc
alp:
jsr pc,readop
jsr pc,expres
jsr pc,checkrp
jsr pc,checkreg
cmp r4,$'+
beq 1f
tst (sp)+
beq 2f
bis $70,r2
clr (r5)+
clr (r5)+
mov xsymbol,(r5)+
rts pc
2:
bis $10,r2
rts pc
1:
jsr pc,readop
bis $20,r2
bis (sp)+,r2
rts pc
amin:
jsr pc,readop
cmp r4,$'(
beq 1f
mov r4,savop
mov $'-,r4
br getx
1:
jsr pc,readop
jsr pc,expres
jsr pc,checkrp
jsr pc,checkreg
bis (sp)+,r2
bis $40,r2
rts pc
adoll:
jsr pc,readop
jsr pc,expres
mov r2,(r5)+
mov r3,(r5)+
mov xsymbol,(r5)+
mov (sp)+,r2
bis $27,r2
rts pc
astar:
tst (sp)
beq 1f
jsr r5,error; '*
1:
mov $10,(sp)
jsr pc,readop
jmp 4b
errora:
jsr r5,error; 'a
rts pc
checkreg:
cmp r2,$7
bhi 1f
cmp r1,$1
blos 2f
cmp r3,$5
blo 1f
2:
rts pc
1:
jsr pc,errora
clr r2
clr r3
rts pc
errore:
jsr r5,error; 'e
rts pc
checkrp:
cmp r4,$')
beq 1f
jsr r5,error; ')
rts pc
1:
jsr pc,readop
rts pc