BSD 1 development
[unix-history] / fpterp / fp1.s
CommitLineData
fde98a2d
BJ
1/ fp1 -- floating point simulator
2
3rti = 2
4bpt = 3
5fetchi = 61.
6
7m.ext = 200 / long mode bit
8m.lngi = 100 / long integer mode
9
10.globl fptrap, fpjsr, _reenter
11.globl ac0, ac1, ac2, ac3
12
132:
14 bpl 1f
15 jsr pc,1f
16 bis $10,sps
17 rts pc
181:
19 bne 1f
20 jsr pc,1f
21 bis $4,sps
22 rts pc
231:
24 bvc 1f
25 jsr pc,1f
26 bis $2,sps
27 rts pc
281:
29 bcc 1f
30 jsr pc,1f
31 bis $1,sps
32 rts pc
331:
34 mov $140000,sps
35 rts pc
36fpjsr:
37 jsr pc,2b
38 mov (sp),-(sp)
39 mov sps,2(sp)
40 add $2,(sp)
41fptrap:
42 dec _reenter
43 bge 1f
44 4 / _reentered!
451:
46 mov (sp)+,spc
47 mov (sp)+,sps
48 mov r0,sr0
49 mov $sr1,r0
50 mov r1,(r0)+
51 mov r2,(r0)+
52 mov r3,(r0)+
53 mov r4,(r0)+
54 mov r5,(r0)+
55 mov sp,(r0)+
56 sub $8,sp / room for double push
57 mov r0,-(sp) / ???
58 mov (r0),r0
59 sub $2,r0
60 sys fetchi
61 mov r0,r5 / instruction
62 mov (sp)+,r0 / ???
63 clr trapins
64 mov r5,r4
65 bic $7777,r4
66 cmp r4,$170000
67 beq 1f
68 jmp badins
69lookahead:
70 add $2,spc
71 mov ssp,sp
72 sub $8,sp
731:
74 bic $100000,fpsr / clear fp error
75 bic $170000,r5
76 mov r5,r4
77 bit $7000,r4
78 bne class3
79 bit $700,r4
80 bne class2
81 cmp r4,$12
82 blos 1f
83 jmp badins
841:
85 asl r4
86 jmp *1f(r4)
87
88 .data
891:
90 i.cfcc / 170000
91 i.setf / 170001
92 i.seti / 170002
93 badins
94 badins
95 badins
96 badins
97 badins
98 badins
99 i.setd / 170011
100 i.setl / 170012
101 .text
102
103class2:
104 cmp r5,$400
105 bge 1f
106 mov $0f,r1
107 jsr pc,fsrc
108 .data
1090: mod0rx; mod242
110 .text
111 br 2f
1121:
113 mov $0f,r1
114 jsr pc,fsrc
115 .data
1160: mod0f; mod24f
117 .text
1182:
119 mov r3,r5
120 asl r4
121 asl r4
122 clrb r4
123 swab r4
124 asl r4
125 jsr pc,*1f(r4)
126 jmp sret
127
128 .data
1291:
130 badins / 1700xx
131 i.ldfps / 1701xx
132 i.stfps / 1702xx
133 badins / 1703xx - stst
134 i.clrx / 1704xx
135 i.tstx / 1705xx
136 i.absx / 1706xx
137 i.negx / 1707xx
138 .text
139
140class3:
141 cmp r5,$5000
142 blt 1f
143 mov r5,r2
144 clrb r2
145 cmp r2,$6400
146 blt 2f
147 sub $1400,r2
1482:
149 cmp r2,$5000
150 bne 2f
151 mov $0f,r1
152 jsr pc,fsrc
153 .data
1540: mod0rx; mod242
155 .text
156 br 3f
1572:
158 cmp r2,$5400
159 bne 2f
160 mov $0f,r1
161 jsr pc,fsrc
162 .data
1630: mod0ra; mod24i
164 .text
165 br 3f
1662:
167 mov $0f,r1
168 jsr pc,fsrc
169 .data
1700: mod0f; mod24d
171 .text
172 br 3f
1731:
174 mov $0f,r1
175 jsr pc,fsrc
176 .data
1770: mod0f; mod24f
178 .text
1793:
180 jsr pc,freg
181 mov r2,r5
182 clrb r4
183 swab r4
184 asl r4
185 jsr pc,*1f(r4)
186 br sret
187
188 .data
1891:
190 badins / 1700xx
191 badins / 1704xx
192 i.mulx / 1710xx
193 i.modx / 1714xx
194 i.addx / 1720xx
195 i.ldx / 1724xx
196 i.subx / 1730xx
197 i.cmpx / 1734xx
198 i.stx / 1740xx
199 i.divx / 1744xx
200 i.stexp / 1750xx
201 i.stcxj / 1754xx
202 i.stcxy / 1760xx
203 i.ldexp / 1764xx
204 i.ldcjx / 1770xx
205 i.ldcyx / 1774xx
206 .text
207
208i.cfcc:
209 mov fpsr,r0
210 bic $!17,r0
211 mov r0,sps
212 br ret
213
214i.setf:
215 bic $m.ext,fpsr
216 br ret
217
218i.setd:
219 bis $m.ext,fpsr
220 br ret
221
222i.seti:
223 bic $m.lngi,fpsr
224 br ret
225
226i.setl:
227 bis $m.lngi,fpsr
228 br ret
229
230badins:
231 inc trapins
232 br ret
233
234sret:
235 mov $fpsr,r0
236 bic $17,(r0)
237 tst (r5)
238 bpl 1f
239 bis $10,(r0)
240 br ret
2411:
242 bne ret
243 bis $4,(r0)
244
245ret:
246 tst trapins
247 bne 1f
248 mov spc,r0
249 sys fetchi
250 mov r0,r5
251 mov r5,r4
252 bic $7777,r4
253 cmp $170000,r4
254 jeq lookahead
2551:
256 mov $sr1,r0
257 mov (r0)+,r1
258 mov (r0)+,r2
259 mov (r0)+,r3
260 mov (r0)+,r4
261 mov (r0)+,r5
262 mov (r0)+,sp
263 mov sr0,r0
264 mov sps,-(sp)
265 mov spc,-(sp)
266 tst trapins
267 bne 1f
268 inc _reenter
269 rti
2701:
271 bpt
272
273freg:
274 mov r5,r2
275 bic $!300,r2
276 asr r2
277 asr r2
278 asr r2
279 add $ac0,r2
280 rts pc
281
282fsrc:
283 mov r5,r3
284 bic $!7,r3 / register
285 asl r3
286 add $sr0,r3
287 mov r5,r0
288 bic $!70,r0 / mode
289 asr r0
290 asr r0
291 jmp *1f(r0)
292
293 .data
2941:
295 mod0
296 mod1
297 mod2
298 mod3
299 mod4
300 mod5
301 mod6
302 mod7
303 .text
304
305mod24f:
306 mov $4,r0
307 bit $m.ext,fpsr
308 beq 1f
309 add $4,r0
3101:
311 rts pc
312
313mod24d:
314 mov $8,r0
315 bit $m.ext,fpsr
316 beq 1f
317 sub $4,r0
3181:
319 rts pc
320
321mod242:
322 mov $2,r0
323 rts pc
324
325mod24i:
326 mov $2,r0
327 bit $m.lngi,fpsr
328 beq 1f
329 add $2,r0
3301:
331 rts pc
332
333mod0:
334 jmp *(r1)+
335
336mod0f:
337 sub $sr0,r3 / get fp ac
338 cmp r3,$6*2
339 bhis badi1
340 asl r3
341 asl r3
342 add $ac0,r3
343 tst (r1)+
344 rts pc
345
346mod0ra:
347 bit $m.lngi,fpsr
348 bne badi1
349
350mod0r:
351 cmp r3,$ssp
352 bhis badi1
353mod0rx:
354 tst (r1)+
355 rts pc
356
357mod1:
358 cmp r3,$spc
359 beq badi1
360 mov (r3),r3
361 br check
362
363mod2:
364 cmp r3,$spc
365 bne 1f
366/ $n
367 mov (r3),r0
368 sys fetchi
369 mov r0,pctmp
370 mov $2,r0
371 add r0,(r3)
372 mov $pctmp,r3
373 br check
374/ (rn)+
3751:
376 mov (r3),-(sp)
377 jsr pc,*2(r1)
378 add r0,(r3)
379 mov (sp)+,r3
380 br check
381
382mod3:
383 cmp r3,$spc
384 bne 1f
385/ *$n
386 mov r0,-(sp)
387 mov (r3),r0
388 sys fetchi
389 add $2,(r3)
390 mov r0,r3
391 mov (sp)+,r0
392 br check
393/ *(rn)+
3941:
395 mov *(r3),-(sp)
396 add $2,(r3)
397 mov (sp)+,r3
398 br check
399
400mod4:
401 cmp r3,$spc / test pc
402 beq badi1
403 jsr pc,*2(r1)
404 sub r0,(r3)
405 mov (r3),r3
406 br check
407
408mod5:
409 cmp r3,$spc
410 beq badi1
411 sub $2,(r3)
412 mov *(r3),r3
413 br check
414
415mod6:
416 mov r0,-(sp)
417 mov spc,r0
418 sys fetchi
419 add $2,spc
420 add (r3),r0 /shouldn't happen separate i and d !!!
421 mov r0,r3
422 mov (sp)+,r0
423 br check
424
425mod7:
426 jsr pc,mod6
427 mov (r3),r3
428 br check
429
430badi1:
431 jmp badins
432
433check:
434 bit $1,r3
435 bne badi1
436 rts pc
437
438setab:
439 mov $asign,r0
440 jsr pc,seta
441 mov r3,r2
442 mov $bsign,r0
443
444seta:
445 clr (r0)
446 mov (r2)+,r1
447 mov r1,-(sp)
448 beq 1f
449 blt 2f
450 inc (r0)+
451 br 3f
4522:
453 dec (r0)+
4543:
455 bic $!177,r1
456 bis $200,r1
457 br 2f
4581:
459 clr (r0)+
4602:
461 mov r1,(r0)+
462 mov (r2)+,(r0)+
463 bit $m.ext,fpsr
464 beq 2f
465 mov (r2)+,(r0)+
466 mov (r2)+,(r0)+
467 br 3f
4682:
469 clr (r0)+
470 clr (r0)+
4713:
472 mov (sp)+,r1
473 asl r1
474 clrb r1
475 swab r1
476 sub $200,r1
477 mov r1,(r0)+ / exp
478 rts pc
479
480norm:
481 mov $areg,r0
482 mov (r0)+,r1
483 mov r1,-(sp)
484 mov (r0)+,r2
485 bis r2,(sp)
486 mov (r0)+,r3
487 bis r3,(sp)
488 mov (r0)+,r4
489 bis r4,(sp)+
490 bne 1f
491 clr asign
492 rts pc
4931:
494 bit $!377,r1
495 beq 1f
496 clc
497 ror r1
498 ror r2
499 ror r3
500 ror r4
501 inc (r0)
502 br 1b
5031:
504 bit $200,r1
505 bne 1f
506 asl r4
507 rol r3
508 rol r2
509 rol r1
510 dec (r0)
511 br 1b
5121:
513 mov r4,-(r0)
514 mov r3,-(r0)
515 mov r2,-(r0)
516 mov r1,-(r0)
517 rts pc
518