OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [trunk/] [fp/] [implementation/] [mmix/] [sim.mms] - Blame information for rev 86

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 hellwig
% Stripped-Down Simulator for MMIX, derived from MMIX-SIM
2
% To run it on a program like "foo bar"
3
%   first say "mmix -Dfoo.mmb foo bar"
4
%   then "mmix  sim foo.mmb"
5
 
6
% I apologize for lack of comments; they're in the book though
7
 
8
t  IS   $255
9
lring_size IS 256 % octabytes in the local register ring
10
 
11
         LOC Data_Segment
12
Global   LOC  @+8*256
13
g        GREG Global  % base of 256 global registers
14
Local    LOC  @+8*lring_size
15
l        GREG Local  % base of lring_size local registers
16
         GREG @
17
IOArgs   OCTA 0,BinaryRead
18
Chunk0   IS   @
19
 
20
         LOC #100
21
         PREFIX :Mem:
22
head     GREG   % address of first chunk
23
curkey GREG   % KEY(head)
24
alloc    GREG   % address of next chunk to allocate
25
Chunk    IS   #1000  bytes per chunk, is power of 2
26
addr     IS   $0
27
key    IS   $1
28
test     IS   $2
29
newlink  IS   $3
30
p        IS   $4  % LINK(p)=head
31
t        IS   :t
32
 
33
KEY    IS   0
34
LINK     IS   8
35
DATA     IS   16
36
nodesize  GREG Chunk+3*8   pad with 8 zero bytes
37
mask      GREG Chunk-1
38
 
39
:MemFind ANDN  key,addr,mask
40
         CMPU  t,key,curkey
41
         PBZ   t,4F
42
         BN    addr,:Error
43
         SET   newlink,head
44
1H       SET   p,head
45
         LDOU  head,p,LINK
46
         PBNZ  head,2F
47
         SET   head,alloc
48
         STOU  key,head,KEY
49
         ADDU  alloc,alloc,nodesize
50
         JMP   3F
51
2H       LDOU  test,head,KEY
52
         CMPU  t,test,key
53
         BNZ   t,1B
54
3H       LDOU  t,head,LINK
55
         STOU  newlink,head,LINK
56
         SET   curkey,key
57
         STOU  t,p,LINK
58
4H       SUBU  t,addr,key
59
         LDA   $0,head,DATA
60
         ADDU  $0,t,$0
61
         POP   1,0
62
         PREFIX :
63
 
64
res      IS    $2
65
arg      IS    res+1
66
 
67
ss       GREG  % rS
68
oo       GREG  % rO
69
ll       GREG  % 8*rL
70
gg       GREG  % 8*rG
71
aa       GREG  % rA
72
ii       GREG  % rI
73
uu       GREG  % rU
74
cc       GREG  % rC
75
 
76
lring_mask GREG 8*lring_size-1
77
:GetReg    CMPU   t,$0,gg
78
           BN     t,1F
79
           LDOU   $0,g,$0
80
           POP    1,0
81
1H         CMPU   t,$0,ll
82
           ADDU   $0,$0,oo
83
           AND    $0,$0,lring_mask
84
           LDOU   $0,l,$0
85
           CSNN   $0,t,0
86
           POP    1,0
87
 
88
:StackStore GET  $0,rJ
89
           AND   t,ss,lring_mask        \S82
90
           LDOU  $1,l,t
91
           SET   arg,ss
92
           PUSHJ res,MemFind
93
           STOU  $1,res,0       M[rS]<-l[rS]
94
           ADDU  ss,ss,8
95
           PUT   rJ,$0
96
           POP
97
:StackLoad GET   $0,rJ
98
           SUBU  ss,ss,8                \S83
99
           SET   arg,ss
100
           PUSHJ res,MemFind
101
           LDOU  $1,res,0
102
           AND   t,ss,lring_mask
103
           STOU  $1,l,t
104
           PUT   rJ,$0
105
           POP
106
:StackRoom SUBU  t,ss,oo   idiom in \S81,\S101,\S102
107
           SUBU  t,t,ll
108
           AND   t,t,lring_mask
109
           PBNZ  t,1F
110
           GET   $0,rJ
111
           PUSHJ res,StackStore
112
           PUT   rJ,$0
113
1H         POP
114
 
115
* The main loop
116
loc        GREG      % where the simulator is at
117
inst_ptr   GREG      % where the simulator will be next
118
inst       GREG      % the current instruction being simulated
119
resuming   GREG      % are we resuming an instruction in rX?
120
 
121
Fetch      PBZ   resuming,1F      \S60 (main simulation loop)
122
           SUBU  loc,inst_ptr,4
123
           LDTU  inst,g,8*rX+4
124
           JMP   2F
125
1H         SET   loc,inst_ptr
126
           SET   arg,loc
127
           PUSHJ res,MemFind
128
           LDTU  inst,res,0
129
           ADDU  inst_ptr,loc,4
130
2H         CMPU  t,loc,g
131
           BNN   t,Error   loc>=Data_Segment
132
 
133
op         GREG      % opcode of the current instruction
134
xx         GREG      % X field of the current instruction
135
yy         GREG      % Y field of the current instruction
136
zz         GREG      % Z field of the current instruction
137
yz         GREG      % YZ field of the current instruction
138
f          GREG      % packed information about the current op
139
xxx        GREG      % X field times 8
140
x          GREG      % result, or X operand
141
y          GREG      % Y operand
142
z          GREG      % Z operand
143
xptr       GREG      % location where x should be stored
144
exc        GREG      % arithmetic exceptions
145
 
146
Z_is_immed_bit  IS #1
147
Z_is_source_bit IS #2
148
Y_is_immed_bit  IS #4
149
Y_is_source_bit IS #8
150
X_is_source_bit IS #10
151
X_is_dest_bit   IS #20
152
Rel_addr_bit    IS #40
153
Mem_bit         IS #80
154
 
155
Info IS #1000
156
Done IS Info+8*256
157
info       GREG  Info   % base address for master info table
158
c255    GREG 8*255
159
c256    GREG 8*256
160
 
161
           MOR   op,inst,#8
162
           MOR   xx,inst,#4
163
           MOR   yy,inst,#2
164
           MOR   zz,inst,#1
165
0H  GREG  -#10000
166
           ANDN  yz,inst,0B
167
           SLU   xxx,xx,3
168
           SLU   t,op,3
169
           LDOU  f,info,t
170
           SET   x,0
171
           SET   y,0
172
           SET   z,0
173
           SET   exc,0
174
           AND   t,f,Rel_addr_bit
175
           PBZ   t,1F
176
           PBEV  f,2F            Convert rel to abs, \S70
177
9H  GREG  -#1000000
178
           ANDN  yz,inst,9B   xyz
179
           ADDU  t,yz,9B
180
           JMP   3F
181
2H         ADDU  t,yz,0B
182
3H         CSOD   yz,op,t
183
           SL     t,yz,2
184
           ADDU   yz,loc,t
185
1H         PBNN   resuming,Install_X    Install operands \S71
186
           LDOU   y,g,8*rY       Install special operands \S127
187
           LDOU   z,g,8*rZ
188
           BOD    resuming,Install_Y
189
0H    GREG #C1<<56+(x-$0)<<48+(z-$0)<<40+1<<16+X_is_dest_bit
190
           SET    f,0B           Change to ORI instruction
191
           LDOU   exc,g,8*rX
192
           MOR    exc,exc,#20
193
           JMP    XDest
194
Install_X  AND    t,f,X_is_source_bit
195
           PBZ    t,1F
196
           SET    arg,xxx
197
           PUSHJ  res,GetReg
198
           SET    x,res
199
1H         SRU    t,f,5
200
           AND    t,t,#f8
201
           PBZ    t,Install_Z
202
           LDOU   x,g,t      Set x from third op, \S79
203
Install_Z  AND    t,f,Z_is_source_bit
204
           PBZ    t,1F
205
           SLU    arg,zz,3
206
           PUSHJ  res,GetReg
207
           SET    z,res
208
           JMP    Install_Y
209
1H         CSOD   z,f,zz     Z_is_immed_bit
210
           AND    t,op,#f0
211
           CMPU   t,t,#e0
212
           PBNZ   t,Install_Y
213
           AND    t,op,#3    Set z as immediate wyde, \S78
214
           NEG    t,3,t
215
           SLU    t,t,4
216
           SLU    z,yz,t
217
           SET    y,x
218
Install_Y  AND    t,f,Y_is_immed_bit
219
           PBZ    t,1F
220
           SET    y,yy
221
           SLU    t,yy,40
222
           ADDU   f,f,t
223
1H         AND    t,f,Y_is_source_bit
224
           BZ     t,1F
225
           SLU    arg,yy,3
226
           PUSHJ  res,GetReg
227
           SET    y,res          (end of \S71)
228
1H         AND    t,f,X_is_dest_bit
229
           BZ     t,1F
230
XDest      CMPU   t,xxx,gg      Install X as dest, \S80
231
           BN     t,3F
232
           LDA    xptr,g,xxx
233
           JMP    1F
234
2H         ADDU   t,oo,ll
235
           AND    t,t,lring_mask
236
           STCO   0,l,t
237
           INCL   ll,8
238
           PUSHJ  res,StackRoom
239
3H         CMPU   t,xxx,ll
240
           BNN    t,2B
241
           ADD    t,xxx,oo
242
           AND    t,t,lring_mask
243
           LDA    xptr,l,t
244
1H         AND    t,f,Mem_bit
245
           PBZ    t,1F
246
           ADDU   arg,y,z
247
           CMPU   t,op,#A0
248
           BN     t,2F
249
           CMPU   t,arg,g
250
           BN     t,Error
251
2H         PUSHJ  res,MemFind
252
1H         SRU    t,f,32
253
           PUT    rX,t
254
           PUT    rM,x
255
           PUT    rE,x
256
0H    GREG   #30000
257
           AND    t,aa,0B
258
           ORL    t,U_BIT<<8  enable underflow trip
259
           PUT    rA,t
260
0H    GREG   Done
261
           PUT    rW,0B
262
           RESUME
263
 
264
MulU       MULU   x,y,z
265
           GET    t,rH
266
           STOU   t,g,8*rH
267
           JMP    XDone
268
 
269
Div        DIV    x,y,z
270
           JMP    1F
271
DivU       PUT    rD,x
272
           DIVU   x,y,z
273
1H         GET    t,rR
274
           STO    t,g,8*rR
275
           JMP    XDone
276
 
277
Cswap      LDOU  z,g,8*rP
278
           LDOU  y,res,0
279
           CMPU  t,y,z
280
           BNZ   t,1F
281
           STOU  x,res,0
282
           JMP   2F
283
1H         STOU  y,g,8*rP
284
2H         ZSZ   x,t,1
285
           JMP   XDone
286
 
287
BTaken     ADDU   cc,cc,4
288
PBTaken    SUBU   cc,cc,2
289
           SET    inst_ptr,yz
290
           JMP    Update
291
 
292
Go         SET    x,inst_ptr
293
           ADDU   inst_ptr,y,z
294
           JMP    XDone
295
 
296
PushGo     ADDU   yz,y,z
297
PushJ      SET    inst_ptr,yz
298
           CMPU   t,xxx,gg
299
           PBN    t,1F
300
           SET    xxx,ll
301
           SRU    xx,xxx,3
302
           INCL   ll,8
303
           PUSHJ  0,StackRoom
304
1H         ADDU   t,xxx,oo
305
           AND    t,t,lring_mask
306
           STOU   xx,l,t
307
           ADDU   t,loc,4
308
           STOU   t,g,8*rJ
309
           INCL   xxx,8
310
           SUBU   ll,ll,xxx
311
           ADDU   oo,oo,xxx
312
           JMP    Update
313
 
314
Pop        SUBU   oo,oo,8
315
           BZ     xx,1F
316
           CMPU   t,ll,xxx
317
           BN     t,1F
318
           ADDU   t,xxx,oo
319
           AND    t,t,lring_mask
320
           LDOU   y,l,t
321
1H         CMPU   t,oo,ss
322
           PBNN   t,1F
323
           PUSHJ  0,StackLoad
324
1H         AND    t,oo,lring_mask
325
           LDOU   z,l,t
326
           AND    z,z,#ff
327
           SLU    z,z,3
328
1H         SUBU   t,oo,ss
329
           CMPU   t,t,z
330
           PBNN   t,1F
331
           PUSHJ  0,StackLoad actually gamma=beta possible here!
332
           JMP    1B
333
1H         ADDU   ll,ll,8
334
           CMPU   t,xxx,ll
335
           CSN    ll,t,xxx
336
           ADDU   ll,ll,z
337
           CMPU   t,gg,ll
338
           CSN    ll,t,gg
339
           CMPU   t,z,ll
340
           BNN    t,1F
341
           AND    t,oo,lring_mask
342
           STOU   y,l,t
343
1H         LDOU   y,g,8*rJ
344
           SUBU   oo,oo,z
345
           4ADDU  inst_ptr,yz,y
346
           JMP    Update
347
 
348
Save       BNZ    yz,Error     \S102
349
           CMPU   t,xxx,gg
350
           BN     t,Error
351
           ADDU   t,oo,ll
352
           AND    t,t,lring_mask
353
           SRU    y,ll,3
354
           STOU   y,l,t
355
           INCL   ll,8
356
           PUSHJ  0,StackRoom
357
           ADDU   oo,oo,ll
358
           SET    ll,0
359
1H         PUSHJ  0,StackStore
360
           CMPU   t,ss,oo
361
           PBNZ   t,1B
362
           SUBU   y,gg,8
363
4H         ADDU   y,y,8
364
1H         SET    arg,ss     \S103
365
           PUSHJ  res,MemFind
366
           CMPU   t,y,8*(rZ+1)
367
           LDOU   z,g,y
368
           PBNZ   t,2F
369
           SLU    z,gg,56-3
370
           ADDU   z,z,aa
371
2H         STOU   z,res,0
372
           INCL   ss,8
373
           BNZ    t,1F
374
           CMPU   t,y,c255
375
           BZ     t,2F
376
           CMPU   t,y,8*rR
377
           PBNZ   t,4B
378
           SET    y,8*rP
379
           JMP    1B
380
2H         SET    y,8*rB
381
           JMP    1B
382
1H         SET    oo,ss
383
           SUBU   x,oo,8
384
           JMP    XDone
385
 
386
Unsave     BNZ    xx,Error    \S104
387
           BNZ    yy,Error
388
           ANDNL  z,#7
389
           ADDU   ss,z,8
390
           SET    y,8*(rZ+2)
391
1H         SUBU   y,y,8
392
4H         SUBU   ss,ss,8      \S105
393
           SET    arg,ss
394
           PUSHJ  res,MemFind
395
           LDOU   x,res,0
396
           CMPU   t,y,8*(rZ+1)
397
           PBNZ   t,2F
398
           SRU    gg,x,56-3
399
           SLU    aa,x,64-18
400
           SRU    aa,aa,64-18
401
           JMP    1B
402
2H         STOU   x,g,y
403
3H         CMPU   t,y,8*rP
404
           CSZ    y,t,8*(rR+1)
405
           CSZ    y,y,c256
406
           CMPU   t,y,gg
407
           PBNZ   t,1B
408
           PUSHJ  0,StackLoad
409
           AND    t,ss,lring_mask
410
           LDOU   x,l,t
411
           AND    x,x,#ff
412
           BZ     x,1F
413
           SET    y,x
414
2H         PUSHJ  0,StackLoad
415
           SUBU   y,y,1
416
           PBNZ   y,2B
417
           SLU    x,x,3
418
1H         SET    ll,x
419
           CMPU   t,gg,x
420
           CSN    ll,t,gg
421
           SET    oo,ss
422
           PBNZ   uu,Update
423
           BZ     resuming,Update
424
           JMP    AllDone
425
 
426
Get        CMPU   t,yz,32
427
           BNN    t,Error
428
           STOU   ii,g,8*rI
429
           STOU   cc,g,8*rC
430
           STOU   oo,g,8*rO
431
           STOU   ss,g,8*rS
432
           STOU   uu,g,8*rU
433
           STOU   aa,g,8*rA
434
           SR     t,ll,3
435
           STOU   t,g,8*rL
436
           SR     t,gg,3
437
           STOU   t,g,8*rG
438
           SLU    t,zz,3
439
           LDOU   x,g,t
440
           JMP    XDone
441
 
442
Put        BNZ    yy,Error
443
           CMPU   t,xx,32
444
           BNN     t,Error
445
           CMPU   t,xx,rC
446
           BN     t,PutOK
447
           CMPU   t,xx,rF
448
           BN     t,1F
449
PutOK      STOU   z,g,xxx
450
           JMP    Update
451
1H         CMPU   t,xx,rG
452
           BN     t,Error
453
           SUB    t,xx,rL
454
           PBP    t,PutA
455
           BN     t,PutG
456
PutL       SLU    z,z,3     \S98, PUT rL
457
           CMPU   t,z,ll
458
           CSN    ll,t,z
459
           JMP    Update
460
0H    GREG   #40000
461
PutA       CMPU   t,z,0B    \S100, PUT rA
462
           BNN    t,Error
463
           SET    aa,z
464
           JMP    Update
465
PutG       SRU    t,z,8
466
           BNZ    t,Error
467
           CMPU   t,z,32
468
           BN     t,Error
469
           SLU    z,z,3
470
           CMPU   t,z,ll
471
           BN     t,Error
472
           JMP    2F
473
1H         SUBU   gg,gg,8
474
           STCO   0,g,gg
475
2H         CMPU   t,z,gg
476
           PBN    t,1B
477
           SET    gg,z
478
           JMP    Update
479
 
480
Resume     SLU    t,inst,40    \S125
481
           BNZ    t,Error
482
           LDOU   inst_ptr,g,8*rW
483
           LDOU   x,g,8*rX
484
           BN     x,Update
485
           SRU    xx,x,56
486
           SUBU   t,xx,2
487
           BNN    t,1F
488
           PBZ    xx,2F
489
           SRU    y,x,28   rop=1 (RESUME_CONT)
490
           AND    y,y,#f
491
           SET    z,1
492
           SLU    z,z,y
493
           ANDNL  z,#70cf
494
           BNZ    z,Error
495
1H         BP     t,Error
496
           SRU    t,x,13
497
           AND    t,t,c255
498
           CMPU   y,t,ll
499
           BN     y,2F
500
           CMPU   y,t,gg
501
           BN     y,Error
502
2H         MOR    t,x,#8
503
           CMPU   t,t,#F9  RESUME
504
           BZ     t,Error
505
           NEG    resuming,xx
506
           CSNN   resuming,resuming,1
507
           JMP    Update
508
 
509
Sync       BNZ    xx,Error
510
           CMPU   t,yz,4
511
           BNN    t,Error
512
           JMP    Update
513
 
514
Trip       SET    xx,0
515
           JMP    TakeTrip
516
 
517
Trap       STOU   inst_ptr,g,8*rWW
518
0H    GREG   #8000000000000000
519
           ADDU   t,inst,0B
520
           STOU   t,g,8*rXX
521
           STOU   y,g,8*rYY
522
           STOU   z,g,8*rZZ
523
           SRU    y,inst,6
524
           CMPU   t,y,4*11
525
           BNN    t,Error
526
           LDOU   t,g,c255
527
0H    GREG  @+4
528
           GO     y,0B,y
529
           JMP    SimHalt
530
           JMP    SimFopen
531
           JMP    SimFclose
532
           JMP    SimFread
533
           JMP    SimFgets
534
           JMP    SimFgetws
535
           JMP    SimFwrite
536
           JMP    SimFputs
537
           JMP    SimFputws
538
           JMP    SimFseek
539
           JMP    SimFtell
540
 
541
:GetArgs   GET   $0,rJ
542
           SET   y,t
543
           SET   arg,t
544
           PUSHJ res,MemFind
545
           LDOU  z,res,0        z = virtual address of buffer
546
           SET   arg,z
547
           PUSHJ res,MemFind
548
           SET   x,res          x = physical address of buffer
549
           STO   x,IOArgs
550
           SET   xx,Mem:Chunk
551
           AND   zz,x,Mem:mask
552
           SUB   xx,xx,zz       xx = bytes from x to chunk end
553
           ADDU  arg,y,8
554
           PUSHJ res,MemFind
555
           LDOU  zz,res,0       zz = size of buffer
556
           STOU  zz,IOArgs+8
557
           PUT   rJ,$0
558
           POP
559
 
560
           GREG  @
561
:SimInst   LDA   t,IOArgs
562
           JMP   DoInst
563
SimFinish  LDA   t,IOArgs
564
SimFclose  GETA  $0,TrapDone
565
:DoInst    PUT   rW,$0
566
           PUT   rX,inst
567
           RESUME
568
 
569
SimFopen   PUSHJ 0,GetArgs
570
           ADDU  xx,Mem:alloc,Mem:nodesize
571
           STOU  xx,IOArgs   % we'll copy the file name here
572
           SET   x,xx
573
1H         SET   arg,z
574
           PUSHJ res,MemFind
575
           LDBU  t,res,0
576
           STBU  t,x,0
577
           INCL  x,1
578
           INCL  z,1
579
           PBNZ  t,1B
580
           GO    $0,SimInst
581
3H         STCO  0,x,0     % clean up the copied string
582
           CMPU  z,xx,x
583
           SUB   x,x,8
584
           PBN   z,3B
585
           JMP   TrapDone
586
 
587
TrapDone   STO    t,g,8*rBB    "RESUME 1" works this way
588
           STO    t,g,c255
589
           JMP    Update
590
 
591
SimFread   PUSHJ  0,GetArgs
592
           SET    y,zz   number of bytes to read
593
1H         CMP    t,xx,y
594
           PBNN   t,SimFinish
595
           STO    xx,IOArgs+8  oops, we must cross chunk bdry
596
           SUB    y,y,xx
597
           GO     $0,SimInst
598
           BN     t,1F
599
           ADD    z,z,xx
600
           SET    arg,z
601
           PUSHJ  res,MemFind
602
           STOU   res,IOArgs
603
           STO    y,IOArgs+8
604
           ADD    xx,Mem:mask,1
605
           JMP    1B
606
1H         SUB    t,t,y
607
           JMP    TrapDone
608
 
609
SimFgets   PUSHJ  0,GetArgs
610
           CMP    t,xx,zz
611
           PBNN   t,SimFinish     easy if all in one chunk
612
           SET    y,zz  remaining buf size
613
           SET    yy,0  bytes successfully read so far
614
1H         ADD    t,xx,1
615
           STO    t,IOArgs+8   null character spills off end
616
           GO     $0,SimInst
617
           BN     t,TrapDone
618
           ADD    yy,yy,t
619
           CMP    $0,t,xx
620
           SET    t,yy
621
           PBNZ   $0,TrapDone
622
           ADDU   z,z,xx
623
           SET    arg,z
624
           PUSHJ  res,MemFind
625
           SUBU   x,x,1
626
           LDBU   t,x,xx      look at last byte read
627
           CMP    t,t,#0a     is it newline?
628
           BZ     t,1F
629
           SUB    y,y,xx
630
           SET    x,res
631
           STOU   x,IOArgs
632
           STO    y,IOArgs+8
633
           ADD    xx,Mem:mask,1
634
           CMP    t,xx,y
635
           BN     t,1B
636
           GO     $0,SimInst
637
           BN     t,TrapDone
638
2H         ADD    t,yy,t
639
           JMP    TrapDone
640
1H         SET    t,0
641
           STBU   t,res,0
642
           JMP    2B
643
 
644
SimFgetws  PUSHJ  0,GetArgs
645
           ADD    y,zz,zz  remaining buf size (bytes)
646
           CMP    t,xx,y
647
           PBNN   t,SimFinish     easy if all in one chunk
648
           SET    yy,0  wydes successfully read so far
649
1H         ADD    zz,xx,3
650
           SR     zz,zz,1        wydes in current chunk, plus 1
651
           STO    zz,IOArgs+8   null character spills off end
652
           GO     $0,SimInst
653
           BN     t,TrapDone
654
           ADDU   yy,yy,t
655
           SUB    zz,zz,1
656
           CMP    $0,t,zz
657
           SET    t,yy
658
           PBNZ   $0,TrapDone
659
           ADD    z,z,xx
660
           SET    arg,z
661
           PUSHJ  res,MemFind
662
           SUBU   x,x,2
663
           LDWU   t,x,xx      look at last wyde read
664
           CMP    t,t,#0a     is it newline?
665
           BZ     t,1F
666
           SUB    y,y,xx
667
           SET    x,res
668
           STOU   x,IOArgs
669
           SR     t,y,1
670
           STO    t,IOArgs+8
671
           ADD    xx,Mem:mask,1
672
           ANDN   y,y,1
673
           CMP    t,xx,y
674
           BN     t,1B
675
           GO     $0,SimInst
676
           BN     t,TrapDone
677
2H         ADD    t,yy,t
678
           JMP    TrapDone
679
1H         SET    t,0
680
           STWU   t,res,0
681
           JMP    2B
682
 
683
SimFwrite  IS     SimFread    yes it works!
684
 
685
SimFputs   SET    xx,0       this many bytes written
686
           SET    z,t        virtual address of string
687
1H         SET    arg,z
688
           PUSHJ  res,MemFind
689
           SET    t,res      physical address of string
690
           GO     $0,DoInst
691
           BN     t,TrapDone
692
           BZ     t,1F
693
           ADD    xx,xx,t
694
           ADDU   z,z,t
695
           AND    t,z,Mem:mask
696
           BZ     t,1B
697
1H         SET    t,xx
698
           JMP    TrapDone
699
 
700
SimFputws  SET    xx,0       this many wydes written
701
           SET    z,t        virtual address of string
702
1H         SET    arg,z
703
           PUSHJ  res,MemFind
704
           SET    t,res      physical address of string
705
           GO     $0,DoInst
706
           BN     t,TrapDone
707
           BZ     t,1F
708
           ADD    xx,xx,t
709
           2ADDU  z,t,z
710
           AND    t,z,Mem:mask
711
           BZ     t,1B
712
1H         SET    t,xx
713
           JMP    TrapDone
714
 
715
SimFseek   IS    SimFclose
716
SimFtell   IS    SimFclose
717
 
718
  GREG @
719
1H BYTE "Warning: ",0
720
2H BYTE " at location ",0
721
3H BYTE #a,0
722
T0 BYTE "TRIP",0
723
T1 BYTE "integer divide check",0
724
T2 BYTE "integer overflow",0
725
T3 BYTE "float-to-fix overflow",0
726
T4 BYTE "invalid floating point operation",0
727
T5 BYTE "floating point overflow",0
728
T6 BYTE "floating point underflow",0
729
T7 BYTE "floating point division by zero",0
730
T8 BYTE "floating point inexact",0
731
TripType OCTA T0,T1,T2,T3,T4,T5,T6,T7,T8
732
SimHalt    CMP   t,zz,1
733
           BZ    inst,Exit  t=0 on normal exit
734
           BNZ   t,Error
735
           CMPU  t,loc,#90
736
           BNN   t,Error    Halt 1 from loc<#90 gives warning
737
           LDA   t,1B
738
           TRAP  0,Fputs,StdErr
739
           SR    x,loc,1
740
           LDA   t,TripType
741
           LDOU  t,t,x
742
           TRAP  0,Fputs,StdErr
743
           LDA   t,2B
744
           TRAP  0,Fputs,StdErr
745
           LDOU  x,g,8*rW
746
           SUBU  x,x,4
747
           SRU   arg,x,32
748
           PUSHJ res,OutTetra
749
           SET   arg,x
750
           PUSHJ res,OutTetra
751
           LDA   t,3B
752
           TRAP  0,Fputs,StdErr
753
           LDOU  t,g,c255
754
           JMP   TrapDone
755
 
756
Error      NEG    t,22       catch-22
757
Exit       TRAP   0,Halt,0
758
 
759
s IS $1
760
0H GREG #0008000400020001
761
:OutTetra MOR t,$0,0B
762
     SLU s,t,4
763
     XOR t,s,t
764
0H GREG #0f0f0f0f0f0f0f0f
765
     AND t,t,0B
766
0H GREG #0606060606060606
767
     ADDU t,t,0B
768
0H GREG #0000002700000000
769
     MOR s,0B,t
770
0H GREG #2a2a2a2a2a2a2a2a
771
     ADDU t,t,0B
772
     ADDU s,t,s
773
     STOU s,g,c255
774
     GETA t,OctaArgs
775
     TRAP 0,Fwrite,StdErr
776
     POP  0
777
 
778
O   IS  Done-4
779
           LOC    Info
780
 JMP Trap+@-O; BYTE 0,5,0,#0a  TRAP
781
 FCMP x,y,z; BYTE 0,1,0,#2a  FCMP
782
 FUN x,y,z; BYTE 0,1,0,#2a  FUN
783
 FEQL x,y,z; BYTE 0,1,0,#2a  FEQL
784
 FADD x,y,z; BYTE 0,4,0,#2a  FADD
785
 FIX  x,0,z; BYTE 0,4,0,#26  FIX
786
 FSUB x,y,z; BYTE 0,4,0,#2a  FSUB
787
 FIXU x,0,z; BYTE 0,4,0,#26  FIXU
788
 FLOT x,0,z; BYTE 0,4,0,#26  FLOT
789
 FLOT x,0,z; BYTE 0,4,0,#25  FLOTI
790
 FLOTU x,0,z; BYTE 0,4,0,#26  FLOTU
791
 FLOTU x,0,z; BYTE 0,4,0,#25  FLOTUI
792
 SFLOT x,0,z; BYTE 0,4,0,#26  SFLOT
793
 SFLOT x,0,z; BYTE 0,4,0,#25  SFLOTI
794
 SFLOTU x,0,z; BYTE 0,4,0,#26  SFLOTU
795
 SFLOTU x,0,z; BYTE 0,4,0,#25  SFLOTUI
796
 FMUL x,y,z; BYTE 0,4,0,#2a  FMUL
797
 FCMPE x,y,z; BYTE 0,4,rE,#2a  FCMPE
798
 FUNE x,y,z; BYTE 0,1,rE,#2a  FUNE
799
 FEQLE x,y,z; BYTE 0,4,rE,#2a  FEQLE
800
 FDIV x,y,z; BYTE 0,40,0,#2a  FDIV
801
 FSQRT x,0,z; BYTE 0,40,0,#26  FSQRT
802
 FREM x,y,z; BYTE 0,4,0,#2a  FREM
803
 FINT x,0,z; BYTE 0,4,0,#26  FINT
804
 MUL x,y,z; BYTE 0,10,0,#2a  MUL
805
 MUL x,y,z; BYTE 0,10,0,#29  MULI
806
 JMP MulU+@-O; BYTE 0,10,0,#2a  MULU
807
 JMP MulU+@-O; BYTE 0,10,0,#29  MULUI
808
 JMP Div+@-O; BYTE 0,60,0,#2a  DIV
809
 JMP Div+@-O; BYTE 0,60,0,#29  DIVI
810
 JMP DivU+@-O; BYTE 0,60,rD,#2a  DIVU
811
 JMP DivU+@-O; BYTE 0,60,rD,#29  DIVUI
812
 ADD x,y,z; BYTE 0,1,0,#2a  ADD
813
 ADD x,y,z; BYTE 0,1,0,#29  ADDI
814
 ADDU x,y,z; BYTE 0,1,0,#2a  ADDU
815
 ADDU x,y,z; BYTE 0,1,0,#29  ADDUI
816
 SUB x,y,z; BYTE 0,1,0,#2a  SUB
817
 SUB x,y,z; BYTE 0,1,0,#29  SUBI
818
 SUBU x,y,z; BYTE 0,1,0,#2a  SUBU
819
 SUBU x,y,z; BYTE 0,1,0,#29  SUBUI
820
 2ADDU x,y,z; BYTE 0,1,0,#2a  2ADDU
821
 2ADDU x,y,z; BYTE 0,1,0,#29  2ADDUI
822
 4ADDU x,y,z; BYTE 0,1,0,#2a  4ADDU
823
 4ADDU x,y,z; BYTE 0,1,0,#29  4ADDUI
824
 8ADDU x,y,z; BYTE 0,1,0,#2a  8ADDU
825
 8ADDU x,y,z; BYTE 0,1,0,#29  8ADDUI
826
 16ADDU x,y,z; BYTE 0,1,0,#2a  16ADDU
827
 16ADDU x,y,z; BYTE 0,1,0,#29  16ADDUI
828
 CMP x,y,z; BYTE 0,1,0,#2a  CMP
829
 CMP x,y,z; BYTE 0,1,0,#29  CMPI
830
 CMPU x,y,z; BYTE 0,1,0,#2a  CMPU
831
 CMPU x,y,z; BYTE 0,1,0,#29  CMPUI
832
 NEG x,0,z; BYTE 0,1,0,#26  NEG
833
 NEG x,0,z; BYTE 0,1,0,#25  NEGI
834
 NEGU x,0,z; BYTE 0,1,0,#26  NEGU
835
 NEGU x,0,z; BYTE 0,1,0,#25  NEGUI
836
 SL x,y,z; BYTE 0,1,0,#2a  SL
837
 SL x,y,z; BYTE 0,1,0,#29  SLI
838
 SLU x,y,z; BYTE 0,1,0,#2a  SLU
839
 SLU x,y,z; BYTE 0,1,0,#29  SLUI
840
 SR x,y,z; BYTE 0,1,0,#2a  SR
841
 SR x,y,z; BYTE 0,1,0,#29  SRI
842
 SRU x,y,z; BYTE 0,1,0,#2a  SRU
843
 SRU x,y,z; BYTE 0,1,0,#29  SRUI
844
 BN x,BTaken+@-O; BYTE 0,1,0,#50  BN
845
 BN x,BTaken+@-O; BYTE 0,1,0,#50  BNB
846
 BZ x,BTaken+@-O; BYTE 0,1,0,#50  BZ
847
 BZ x,BTaken+@-O; BYTE 0,1,0,#50  BZB
848
 BP x,BTaken+@-O; BYTE 0,1,0,#50  BP
849
 BP x,BTaken+@-O; BYTE 0,1,0,#50  BPB
850
 BOD x,BTaken+@-O; BYTE 0,1,0,#50  BOD
851
 BOD x,BTaken+@-O; BYTE 0,1,0,#50  BODB
852
 BNN x,BTaken+@-O; BYTE 0,1,0,#50  BNN
853
 BNN x,BTaken+@-O; BYTE 0,1,0,#50  BNNB
854
 BNZ x,BTaken+@-O; BYTE 0,1,0,#50  BNZ
855
 BNZ x,BTaken+@-O; BYTE 0,1,0,#50  BNZB
856
 BNP x,BTaken+@-O; BYTE 0,1,0,#50  BNP
857
 BNP x,BTaken+@-O; BYTE 0,1,0,#50  BNPB
858
 BEV x,BTaken+@-O; BYTE 0,1,0,#50  BEV
859
 BEV x,BTaken+@-O; BYTE 0,1,0,#50  BEVB
860
 PBN x,PBTaken+@-O; BYTE 0,3,0,#50  PBN
861
 PBN x,PBTaken+@-O; BYTE 0,3,0,#50  PBNB
862
 PBZ x,PBTaken+@-O; BYTE 0,3,0,#50  PBZ
863
 PBZ x,PBTaken+@-O; BYTE 0,3,0,#50  PBZB
864
 PBP x,PBTaken+@-O; BYTE 0,3,0,#50  PBP
865
 PBP x,PBTaken+@-O; BYTE 0,3,0,#50  PBPB
866
 PBOD x,PBTaken+@-O; BYTE 0,3,0,#50  PBOD
867
 PBOD x,PBTaken+@-O; BYTE 0,3,0,#50  PBODB
868
 PBNN x,PBTaken+@-O; BYTE 0,3,0,#50  PBNN
869
 PBNN x,PBTaken+@-O; BYTE 0,3,0,#50  PBNNB
870
 PBNZ x,PBTaken+@-O; BYTE 0,3,0,#50  PBNZ
871
 PBNZ x,PBTaken+@-O; BYTE 0,3,0,#50  PBNZB
872
 PBNP x,PBTaken+@-O; BYTE 0,3,0,#50  PBNP
873
 PBNP x,PBTaken+@-O; BYTE 0,3,0,#50  PBNPB
874
 PBEV x,PBTaken+@-O; BYTE 0,3,0,#50  PBEV
875
 PBEV x,PBTaken+@-O; BYTE 0,3,0,#50  PBEVB
876
 CSN x,y,z; BYTE 0,1,0,#3a  CSN
877
 CSN x,y,z; BYTE 0,1,0,#39  CSNI
878
 CSZ x,y,z; BYTE 0,1,0,#3a  CSZ
879
 CSZ x,y,z; BYTE 0,1,0,#39  CSZI
880
 CSP x,y,z; BYTE 0,1,0,#3a  CSP
881
 CSP x,y,z; BYTE 0,1,0,#39  CSPI
882
 CSOD x,y,z; BYTE 0,1,0,#3a  CSOD
883
 CSOD x,y,z; BYTE 0,1,0,#39  CSODI
884
 CSNN x,y,z; BYTE 0,1,0,#3a  CSNN
885
 CSNN x,y,z; BYTE 0,1,0,#39  CSNNI
886
 CSNZ x,y,z; BYTE 0,1,0,#3a  CSNZ
887
 CSNZ x,y,z; BYTE 0,1,0,#39  CSNZI
888
 CSNP x,y,z; BYTE 0,1,0,#3a  CSNP
889
 CSNP x,y,z; BYTE 0,1,0,#39  CSNPI
890
 CSEV x,y,z; BYTE 0,1,0,#3a  CSEV
891
 CSEV x,y,z; BYTE 0,1,0,#39  CSEVI
892
 ZSN x,y,z; BYTE 0,1,0,#2a  ZSN
893
 ZSN x,y,z; BYTE 0,1,0,#29  ZSNI
894
 ZSZ x,y,z; BYTE 0,1,0,#2a  ZSZ
895
 ZSZ x,y,z; BYTE 0,1,0,#29  ZSZI
896
 ZSP x,y,z; BYTE 0,1,0,#2a  ZSP
897
 ZSP x,y,z; BYTE 0,1,0,#29  ZSPI
898
 ZSOD x,y,z; BYTE 0,1,0,#2a  ZSOD
899
 ZSOD x,y,z; BYTE 0,1,0,#29  ZSODI
900
 ZSNN x,y,z; BYTE 0,1,0,#2a  ZSNN
901
 ZSNN x,y,z; BYTE 0,1,0,#29  ZSNNI
902
 ZSNZ x,y,z; BYTE 0,1,0,#2a  ZSNZ
903
 ZSNZ x,y,z; BYTE 0,1,0,#29  ZSNZI
904
 ZSNP x,y,z; BYTE 0,1,0,#2a  ZSNP
905
 ZSNP x,y,z; BYTE 0,1,0,#29  ZSNPI
906
 ZSEV x,y,z; BYTE 0,1,0,#2a  ZSEV
907
 ZSEV x,y,z; BYTE 0,1,0,#29  ZSEVI
908
 LDB x,res,0; BYTE 1,1,0,#aa  LDB
909
 LDB x,res,0; BYTE 1,1,0,#a9  LDBI
910
 LDBU x,res,0; BYTE 1,1,0,#aa  LDBU
911
 LDBU x,res,0; BYTE 1,1,0,#a9  LDBUI
912
 LDW x,res,0; BYTE 1,1,0,#aa  LDW
913
 LDW x,res,0; BYTE 1,1,0,#a9  LDWI
914
 LDWU x,res,0; BYTE 1,1,0,#aa  LDWU
915
 LDWU x,res,0; BYTE 1,1,0,#a9  LDWUI
916
 LDT x,res,0; BYTE 1,1,0,#aa  LDT
917
 LDT x,res,0; BYTE 1,1,0,#a9  LDTI
918
 LDTU x,res,0; BYTE 1,1,0,#aa  LDTU
919
 LDTU x,res,0; BYTE 1,1,0,#a9  LDTUI
920
 LDO x,res,0; BYTE 1,1,0,#aa  LDO
921
 LDO x,res,0; BYTE 1,1,0,#a9  LDOI
922
 LDOU x,res,0; BYTE 1,1,0,#aa  LDOU
923
 LDOU x,res,0; BYTE 1,1,0,#a9  LDOUI
924
 LDSF x,res,0; BYTE 1,1,0,#aa  LDSF
925
 LDSF x,res,0; BYTE 1,1,0,#a9  LDSFI
926
 LDHT x,res,0; BYTE 1,1,0,#aa  LDHT
927
 LDHT x,res,0; BYTE 1,1,0,#a9  LDHTI
928
 JMP Cswap+@-O; BYTE 2,2,0,#ba  CSWAP
929
 JMP Cswap+@-O; BYTE 2,2,0,#b9  CSWAPI
930
 LDUNC x,res,0; BYTE 1,1,0,#aa  LDUNC
931
 LDUNC x,res,0; BYTE 1,1,0,#a9  LDUNCI
932
 JMP Error+@-O; BYTE 0,1,0,#2a  LDVTS
933
 JMP Error+@-O; BYTE 0,1,0,#29  LDVTSI
934
 SWYM 0; BYTE 0,1,0,#0a  PRELD
935
 SWYM 0; BYTE 0,1,0,#09  PRELDI
936
 SWYM 0; BYTE 0,1,0,#0a  PREGO
937
 SWYM 0; BYTE 0,1,0,#09  PREGOI
938
 JMP Go+@-O; BYTE 0,3,0,#2a  GO
939
 JMP Go+@-O; BYTE 0,3,0,#29  GOI
940
 STB x,res,0; BYTE 1,1,0,#9a  STB
941
 STB x,res,0; BYTE 1,1,0,#99  STBI
942
 STBU x,res,0; BYTE 1,1,0,#9a  STBU
943
 STBU x,res,0; BYTE 1,1,0,#99  STBUI
944
 STW x,res,0; BYTE 1,1,0,#9a  STW
945
 STW x,res,0; BYTE 1,1,0,#99  STWI
946
 STWU x,res,0; BYTE 1,1,0,#9a  STWU
947
 STWU x,res,0; BYTE 1,1,0,#99  STWUI
948
 STT x,res,0; BYTE 1,1,0,#9a  STT
949
 STT x,res,0; BYTE 1,1,0,#99  STTI
950
 STTU x,res,0; BYTE 1,1,0,#9a  STTU
951
 STTU x,res,0; BYTE 1,1,0,#99  STTUI
952
 STO x,res,0; BYTE 1,1,0,#9a  STO
953
 STO x,res,0; BYTE 1,1,0,#99  STOI
954
 STOU x,res,0; BYTE 1,1,0,#9a  STOU
955
 STOU x,res,0; BYTE 1,1,0,#99  STOUI
956
 STSF x,res,0; BYTE 1,1,0,#9a  STSF
957
 STSF x,res,0; BYTE 1,1,0,#99  STSFI
958
 STHT x,res,0; BYTE 1,1,0,#9a  STHT
959
 STHT x,res,0; BYTE 1,1,0,#99  STHTI
960
 STO xx,res,0; BYTE 1,1,0,#8a  STCO
961
 STO xx,res,0; BYTE 1,1,0,#89  STCOI
962
 STUNC x,res,0; BYTE 1,1,0,#9a  STUNC
963
 STUNC x,res,0; BYTE 1,1,0,#99  STUNCI
964
 SWYM 0; BYTE 0,1,0,#0a  SYNCD
965
 SWYM 0; BYTE 0,1,0,#09  SYNCDI
966
 SWYM 0; BYTE 0,1,0,#0a  PREST
967
 SWYM 0; BYTE 0,1,0,#09  PRESTI
968
 SWYM 0; BYTE 0,1,0,#0a  SYNCID
969
 SWYM 0; BYTE 0,1,0,#09  SYNCIDI
970
 JMP PushGo+@-O; BYTE 0,3,0,#2a  PUSHGO
971
 JMP PushGo+@-O; BYTE 0,3,0,#29  PUSHGOI
972
 OR x,y,z; BYTE 0,1,0,#2a  OR
973
 OR x,y,z; BYTE 0,1,0,#29  ORI
974
 ORN x,y,z; BYTE 0,1,0,#2a  ORN
975
 ORN x,y,z; BYTE 0,1,0,#29  ORNI
976
 NOR x,y,z; BYTE 0,1,0,#2a  NOR
977
 NOR x,y,z; BYTE 0,1,0,#29  NORI
978
 XOR x,y,z; BYTE 0,1,0,#2a  XOR
979
 XOR x,y,z; BYTE 0,1,0,#29  XORI
980
 AND x,y,z; BYTE 0,1,0,#2a  AND
981
 AND x,y,z; BYTE 0,1,0,#29  ANDI
982
 ANDN x,y,z; BYTE 0,1,0,#2a  ANDN
983
 ANDN x,y,z; BYTE 0,1,0,#29  ANDNI
984
 NAND x,y,z; BYTE 0,1,0,#2a  NAND
985
 NAND x,y,z; BYTE 0,1,0,#29  NANDI
986
 NXOR x,y,z; BYTE 0,1,0,#2a  NXOR
987
 NXOR x,y,z; BYTE 0,1,0,#29  NXORI
988
 BDIF x,y,z; BYTE 0,1,0,#2a  BDIF
989
 BDIF x,y,z; BYTE 0,1,0,#29  BDIFI
990
 WDIF x,y,z; BYTE 0,1,0,#2a  WDIF
991
 WDIF x,y,z; BYTE 0,1,0,#29  WDIFI
992
 TDIF x,y,z; BYTE 0,1,0,#2a  TDIF
993
 TDIF x,y,z; BYTE 0,1,0,#29  TDIFI
994
 ODIF x,y,z; BYTE 0,1,0,#2a  ODIF
995
 ODIF x,y,z; BYTE 0,1,0,#29  ODIFI
996
 MUX x,y,z; BYTE 0,1,rM,#2a  MUX
997
 MUX x,y,z; BYTE 0,1,rM,#29  MUXI
998
 SADD x,y,z; BYTE 0,1,0,#2a  SADD
999
 SADD x,y,z; BYTE 0,1,0,#29  SADDI
1000
 MOR x,y,z; BYTE 0,1,0,#2a  MOR
1001
 MOR x,y,z; BYTE 0,1,0,#29  MORI
1002
 MXOR x,y,z; BYTE 0,1,0,#2a  MXOR
1003
 MXOR x,y,z; BYTE 0,1,0,#29  MXORI
1004
 SET x,z; BYTE 0,1,0,#20  SETH
1005
 SET x,z; BYTE 0,1,0,#20  SETMH
1006
 SET x,z; BYTE 0,1,0,#20  SETML
1007
 SET x,z; BYTE 0,1,0,#20  SETL
1008
 ADDU x,x,z; BYTE 0,1,0,#30  INCH
1009
 ADDU x,x,z; BYTE 0,1,0,#30  INCMH
1010
 ADDU x,x,z; BYTE 0,1,0,#30  INCML
1011
 ADDU x,x,z; BYTE 0,1,0,#30  INCL
1012
 OR x,x,z; BYTE 0,1,0,#30  ORH
1013
 OR x,x,z; BYTE 0,1,0,#30  ORMH
1014
 OR x,x,z; BYTE 0,1,0,#30  ORML
1015
 OR x,x,z; BYTE 0,1,0,#30  ORL
1016
 ANDN x,x,z; BYTE 0,1,0,#30  ANDNH
1017
 ANDN x,x,z; BYTE 0,1,0,#30  ANDNMH
1018
 ANDN x,x,z; BYTE 0,1,0,#30  ANDNML
1019
 ANDN x,x,z; BYTE 0,1,0,#30  ANDNL
1020
 SET inst_ptr,yz; BYTE 0,1,0,#41  JMP
1021
 SET inst_ptr,yz; BYTE 0,1,0,#41  JMPB
1022
 JMP PushJ+@-O; BYTE 0,1,0,#60  PUSHJ
1023
 JMP PushJ+@-O; BYTE 0,1,0,#60  PUSHJB
1024
 SET x,yz; BYTE 0,1,0,#60  GETA
1025
 SET x,yz; BYTE 0,1,0,#60  GETAB
1026
 JMP Put+@-O; BYTE 0,1,0,#02  PUT
1027
 JMP Put+@-O; BYTE 0,1,0,#01  PUTI
1028
 JMP Pop+@-O; BYTE 0,3,rJ,#00  POP
1029
 JMP Resume+@-O; BYTE 0,5,0,#00  RESUME
1030
 JMP Save+@-O; BYTE 20,1,0,#20  SAVE
1031
 JMP Unsave+@-O; BYTE 20,1,0,#02  UNSAVE
1032
 JMP Sync+@-O; BYTE 0,1,0,#01  SYNC
1033
 SWYM x,y,z; BYTE 0,1,0,#00  SWYM
1034
 JMP Get+@-O; BYTE 0,1,0,#20  GET
1035
 JMP Trip+@-O; BYTE 0,5,0,#0a  TRIP
1036
 
1037
Done       AND    t,f,X_is_dest_bit   % doubly defined but OK
1038
           BZ     t,1F
1039
XDone      STOU   x,xptr,0
1040
1H         GET    t,rA
1041
           AND    t,t,#ff
1042
           OR     exc,exc,t
1043
           AND    t,exc,U_BIT+X_BIT  Check for trip, \S123
1044
           CMPU   t,t,U_BIT
1045
           PBNZ   t,1F        branch unless underflow is exact
1046
0H    GREG   U_BIT<<8
1047
           AND    t,aa,0B
1048
           BNZ    t,1F        branch if underflow is enabled
1049
           ANDNL  exc,U_BIT   ignore U if exact and not enabled
1050
1H         PBZ    exc,Update
1051
           SRU    t,aa,8
1052
           AND    t,t,exc
1053
           PBZ    t,4F
1054
           SET    xx,0         Initiate a trip, \S124
1055
           SLU    t,t,55
1056
2H         INCL   xx,1
1057
           SLU    t,t,1
1058
           PBNN   t,2B
1059
           SET    t,#100
1060
           SRU    t,t,xx
1061
           ANDN   exc,exc,t
1062
TakeTrip   STOU   inst_ptr,g,8*rW
1063
           SLU    inst_ptr,xx,4
1064
           INCH   inst,#8000
1065
           STOU   inst,g,8*rX
1066
           AND    t,f,Mem_bit
1067
           PBZ    t,1F
1068
           ADDU   y,y,z
1069
           SET    z,x
1070
1H         STOU   y,g,8*rY
1071
           STOU   z,g,8*rZ
1072
           LDOU   t,g,c255
1073
           STOU   t,g,8*rB
1074
           LDOU   t,g,8*rJ
1075
           STOU   t,g,c255
1076
4H         OR     aa,aa,exc
1077
0H    GREG   #0000000800000004  Update the clocks, \S128
1078
Update     MOR    t,f,0B      $2^{32}$mems + oops
1079
           ADDU   cc,cc,t
1080
           ADDU   uu,uu,1
1081
           SUBU   ii,ii,1
1082
AllDone    PBZ    resuming,Fetch
1083
           CMPU   t,op,#F9   RESUME
1084
           CSNZ   resuming,t,0
1085
           JMP    Fetch
1086
 
1087
OctaArgs   OCTA   Global+8*255,8
1088
Infile     IS     3
1089
Main       LDA    Mem:head,Chunk0
1090
           ADDU   Mem:alloc,Mem:head,Mem:nodesize
1091
           GET    t,rN
1092
           INCL   t,1
1093
           STOU   t,g,8*rN
1094
           LDOU   t,$1,8      argv[1]
1095
           STOU   t,IOArgs
1096
           LDA    t,IOArgs
1097
           TRAP   0,Fopen,Infile
1098
           BN     t,Error
1099
1H         GETA   t,OctaArgs
1100
           TRAP   0,Fread,Infile
1101
           BN     t,9F
1102
           LDOU   loc,g,c255
1103
2H         GETA   t,OctaArgs
1104
           TRAP   0,Fread,Infile
1105
           LDOU   x,g,c255
1106
           BN     t,Error
1107
           SET    arg,loc
1108
           BZ     x,1B
1109
           PUSHJ  res,MemFind
1110
           STOU   x,res,0
1111
           INCL   loc,8
1112
           JMP    2B
1113
9H         TRAP   0,Fclose,Infile
1114
           SUBU   loc,loc,8
1115
           STOU   loc,g,c255  place to UNSAVE
1116
           SUBU   arg,loc,8*13
1117
           PUSHJ  res,MemFind
1118
           LDOU   inst_ptr,res,0   Main
1119
           SET    arg,#90          Get ready to UNSAVE, \S162
1120
           PUSHJ  res,MemFind
1121
           LDTU   x,res,0
1122
           SET    resuming,1       RESUME_AGAIN
1123
           CSNZ   inst_ptr,x,#90
1124
0H    GREG   #FB<<24+255      UNSAVE $255
1125
           STOU   0B,g,8*rX
1126
           SET    gg,c255
1127
           JMP    Fetch
1128
 
1129
 LOC Global+8*rK; OCTA -1
1130
 LOC Global+8*rT; OCTA #8000000500000000
1131
 LOC Global+8*rTT; OCTA #8000000600000000
1132
 LOC Global+8*rV; OCTA #369c200400000000
1133
 
1134
           LOC    U_Handler
1135
           ORL    exc,U_BIT
1136
           JMP    Done

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.