This source file includes following definitions.
- elapsedtime
- writeOperands
- readOperands
- read_tra_op
- dump_words
- scu2words
- cu_safe_store
- tidy_cu
- words2scu
- cu_safe_restore
- du2words
- words2du
- initializeTheMatrix
- addToTheMatrix
- display_the_matrix
- fetchInstruction
- traceInstruction
- chkOVF
- tstOVFfault
- executeInstruction
- overflow
- doInstruction
- emCall
- doABSA
- doRCU
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 #include <stdio.h>
35
36 #include "dps8.h"
37 #include "dps8_addrmods.h"
38 #include "dps8_sys.h"
39 #include "dps8_faults.h"
40 #include "dps8_scu.h"
41 #include "dps8_iom.h"
42 #include "dps8_cable.h"
43 #include "dps8_cpu.h"
44 #include "dps8_append.h"
45 #include "dps8_eis.h"
46 #include "dps8_ins.h"
47 #include "dps8_math.h"
48 #include "dps8_opcodetable.h"
49 #include "dps8_decimal.h"
50 #include "dps8_iefp.h"
51 #include "dps8_utils.h"
52
53 #if defined(THREADZ) || defined(LOCKLESS)
54 # include "threadz.h"
55 #endif
56
57 #include "ver.h"
58
59 #define DBG_CTR cpu.cycleCnt
60
61
62
63 static int doABSA (word36 * result);
64 static t_stat doInstruction (void);
65 static int emCall (void);
66
67 #ifdef LOOPTRC
68 void elapsedtime (void)
69 {
70 static bool init = false;
71 static struct timespec t0;
72 struct timespec now, delta;
73
74 if (! init)
75 {
76 init = true;
77 clock_gettime (CLOCK_REALTIME, & t0);
78 }
79 clock_gettime (CLOCK_REALTIME, & now);
80 timespec_diff (& t0, & now, & delta);
81 sim_printf ("%5ld.%03ld", delta.tv_sec, delta.tv_nsec/1000000);
82 }
83 #endif
84
85
86 static void writeOperands (void)
87 {
88 char buf [256];
89 CPT (cpt2U, 0);
90 DCDstruct * i = & cpu.currentInstruction;
91
92 sim_debug (DBG_ADDRMOD, & cpu_dev,
93 "%s (%s):mne=%s flags=%x\n",
94 __func__, disassemble (buf, IWB_IRODD), i->info->mne, i->info->flags);
95
96 PNL (cpu.prepare_state |= ps_RAW);
97
98 word6 rTAG = 0;
99 if (! (i->info->flags & NO_TAG))
100 rTAG = GET_TAG (cpu.cu.IWB);
101 word6 Td = GET_TD (rTAG);
102 word6 Tm = GET_TM (rTAG);
103
104
105
106
107
108 if (Tm == TM_IT && (Td == IT_CI || Td == IT_SC || Td == IT_SCR))
109 {
110
111
112
113
114 #ifdef LOCKLESS
115 word36 tmpdata;
116 core_read(cpu.char_word_address, &tmpdata, __func__);
117 if (tmpdata != cpu.ou.character_data)
118 sim_warn("write char: data changed from %llo to %llo at %o\n",
119 (long long unsigned int)cpu.ou.character_data,
120 (long long unsigned int)tmpdata, cpu.char_word_address);
121 #endif
122
123 switch (cpu.ou.characterOperandSize)
124 {
125 case TB6:
126 putChar (& cpu.ou.character_data, cpu.CY & 077, cpu.ou.characterOperandOffset);
127 break;
128
129 case TB9:
130 putByte (& cpu.ou.character_data, cpu.CY & 0777, cpu.ou.characterOperandOffset);
131 break;
132 }
133
134
135
136
137
138 PNL (cpu.prepare_state |= ps_SAW);
139
140 #ifdef LOCKLESSXXX
141
142 core_write_unlock (cpu.char_word_address, cpu.ou.character_data, __func__);
143 #else
144 Write (cpu.ou.character_address, cpu.ou.character_data, OPERAND_STORE);
145 #endif
146
147 sim_debug (DBG_ADDRMOD, & cpu_dev,
148 "%s IT wrote char/byte %012"PRIo64" to %06o "
149 "tTB=%o tCF=%o\n",
150 __func__, cpu.ou.character_data, cpu.ou.character_address,
151 cpu.ou.characterOperandSize, cpu.ou.characterOperandOffset);
152
153
154
155 cpu.TPR.CA = cpu.ou.character_address;
156 return;
157 }
158
159 write_operand (cpu.TPR.CA, OPERAND_STORE);
160
161 return;
162 }
163
164
165 static void readOperands (void)
166 {
167 char buf [256];
168 CPT (cpt2U, 3);
169 DCDstruct * i = & cpu.currentInstruction;
170
171 sim_debug (DBG_ADDRMOD, &cpu_dev,
172 "%s (%s):mne=%s flags=%x\n",
173 __func__, disassemble (buf, IWB_IRODD), i->info->mne, i->info->flags);
174 sim_debug (DBG_ADDRMOD, &cpu_dev,
175 "%s a %d address %08o\n", __func__, i->b29, cpu.TPR.CA);
176
177 PNL (cpu.prepare_state |= ps_POA);
178
179 word6 rTAG = 0;
180 if (! (i->info->flags & NO_TAG))
181 rTAG = GET_TAG (cpu.cu.IWB);
182 word6 Td = GET_TD (rTAG);
183 word6 Tm = GET_TM (rTAG);
184
185
186
187
188
189 if (Tm == TM_R && Td == TD_DU)
190 {
191 cpu.CY = 0;
192 SETHI (cpu.CY, cpu.TPR.CA);
193 sim_debug (DBG_ADDRMOD, & cpu_dev,
194 "%s DU CY=%012"PRIo64"\n", __func__, cpu.CY);
195 return;
196 }
197
198
199
200
201
202 if (Tm == TM_R && Td == TD_DL)
203 {
204 cpu.CY = 0;
205 SETLO (cpu.CY, cpu.TPR.CA);
206 sim_debug (DBG_ADDRMOD, & cpu_dev,
207 "%s DL CY=%012"PRIo64"\n", __func__, cpu.CY);
208 return;
209 }
210
211
212
213
214
215 if (Tm == TM_IT && (Td == IT_CI || Td == IT_SC || Td == IT_SCR))
216 {
217
218
219
220
221 switch (cpu.ou.characterOperandSize)
222 {
223 case TB6:
224 cpu.CY = GETCHAR (cpu.ou.character_data, cpu.ou.characterOperandOffset);
225 break;
226
227 case TB9:
228 cpu.CY = GETBYTE (cpu.ou.character_data, cpu.ou.characterOperandOffset);
229 break;
230 }
231
232 sim_debug (DBG_ADDRMOD, & cpu_dev,
233 "%s IT read operand %012"PRIo64" from"
234 " %06o char/byte=%"PRIo64"\n",
235 __func__, cpu.ou.character_data, cpu.ou.character_address, cpu.CY);
236
237
238 cpu.TPR.CA = cpu.ou.character_address;
239 return;
240 }
241
242 #ifdef LOCKLESS
243 read_operand (cpu.TPR.CA, ((i->info->flags & RMW) == RMW) ? OPERAND_RMW : OPERAND_READ);
244 #else
245 read_operand (cpu.TPR.CA, OPERAND_READ);
246 #endif
247
248 return;
249 }
250
251 static void read_tra_op (void)
252 {
253 if (cpu.TPR.CA & 1)
254 Read (cpu.TPR.CA, &cpu.CY, OPERAND_READ);
255 else
256 Read2 (cpu.TPR.CA, cpu.Ypair, OPERAND_READ);
257 if (! (get_addr_mode () == APPEND_mode || cpu.cu.TSN_VALID [0] ||
258 cpu.cu.XSF || cpu.currentInstruction.b29 ))
259 {
260 if (cpu.currentInstruction.info->flags & TSPN_INS)
261 {
262 word3 n;
263 if (cpu.currentInstruction.opcode <= 0273)
264 n = (cpu.currentInstruction.opcode & 3);
265 else
266 n = (cpu.currentInstruction.opcode & 3) + 4;
267
268
269
270
271
272 cpu.PR[n].RNR = cpu.PPR.PRR;
273
274
275 if (get_addr_mode () == APPEND_mode)
276 cpu.PR[n].SNR = cpu.PPR.PSR;
277 cpu.PR[n].WORDNO = (cpu.PPR.IC + 1) & MASK18;
278 SET_PR_BITNO (n, 0);
279 #ifdef TESTING
280 HDBGRegPRW (n, "read_tra_op tsp");
281 #endif
282 }
283 cpu.PPR.IC = cpu.TPR.CA;
284
285
286 }
287 sim_debug (DBG_TRACE, & cpu_dev, "%s %05o:%06o\n",
288 __func__, cpu.PPR.PSR, cpu.PPR.IC);
289 if (cpu.PPR.IC & 1)
290 {
291 cpu.cu.IWB = cpu.CY;
292 cpu.cu.IRODD = cpu.CY;
293 }
294 else
295 {
296 cpu.cu.IWB = cpu.Ypair[0];
297 cpu.cu.IRODD = cpu.Ypair[1];
298 }
299 }
300
301 static void dump_words (word36 * words)
302 {
303 sim_debug (DBG_FAULT, & cpu_dev, "CU: P %d IR %#o PSR %0#o IC %0#o TSR %0#o\n",
304 getbits36_1 (words[0], 18), getbits36_18 (words[4], 18),
305 getbits36_15 (words[0], 3), getbits36_18 (words[4], 0), getbits36_15 (words[2], 3));
306 sim_debug (DBG_FAULT, & cpu_dev, "CU: xsf %d rf %d rpt %d rd %d rl %d pot %d xde %d xdo %d itp %d rfi %d its %d fif %d hold %0#o\n",
307 getbits36_1 (words[0], 19),
308 getbits36_1 (words[5], 18), getbits36_1 (words[5], 19), getbits36_1 (words[5], 20), getbits36_1 (words[5], 21),
309 getbits36_1 (words[5], 22), getbits36_1 (words[5], 24), getbits36_1 (words[5], 25), getbits36_1 (words[5], 26),
310 getbits36_1 (words[5], 27), getbits36_1 (words[5], 28), getbits36_1 (words[5], 29), getbits36_6 (words[5], 30));
311 sim_debug (DBG_FAULT, & cpu_dev, "CU: iwb %012"PRIo64" irodd %012"PRIo64"\n",
312 words[6], words[7]);
313 }
314
315 static void scu2words (word36 *words)
316 {
317 CPT (cpt2U, 6);
318 memset (words, 0, 8 * sizeof (* words));
319
320
321
322 putbits36_3 (& words[0], 0, cpu.PPR.PRR);
323 putbits36_15 (& words[0], 3, cpu.PPR.PSR);
324 putbits36_1 (& words[0], 18, cpu.PPR.P);
325 putbits36_1 (& words[0], 19, cpu.cu.XSF);
326
327 putbits36_1 (& words[0], 21, cpu.cu.SD_ON);
328
329 putbits36_1 (& words[0], 23, cpu.cu.PT_ON);
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346 putbits36_12 (& words[0], 24, cpu.cu.APUCycleBits);
347
348
349
350
351 putbits36_1 (& words[1], 0, cpu.cu.IRO_ISN);
352 putbits36_1 (& words[1], 1, cpu.cu.OEB_IOC);
353 putbits36_1 (& words[1], 2, cpu.cu.EOFF_IAIM);
354 putbits36_1 (& words[1], 3, cpu.cu.ORB_ISP);
355 putbits36_1 (& words[1], 4, cpu.cu.ROFF_IPR);
356 putbits36_1 (& words[1], 5, cpu.cu.OWB_NEA);
357 putbits36_1 (& words[1], 6, cpu.cu.WOFF_OOB);
358 putbits36_1 (& words[1], 7, cpu.cu.NO_GA);
359 putbits36_1 (& words[1], 8, cpu.cu.OCB);
360 putbits36_1 (& words[1], 9, cpu.cu.OCALL);
361 putbits36_1 (& words[1], 10, cpu.cu.BOC);
362 putbits36_1 (& words[1], 11, cpu.cu.PTWAM_ER);
363 putbits36_1 (& words[1], 12, cpu.cu.CRT);
364 putbits36_1 (& words[1], 13, cpu.cu.RALR);
365 putbits36_1 (& words[1], 14, cpu.cu.SDWAM_ER);
366 putbits36_1 (& words[1], 15, cpu.cu.OOSB);
367 putbits36_1 (& words[1], 16, cpu.cu.PARU);
368 putbits36_1 (& words[1], 17, cpu.cu.PARL);
369 putbits36_1 (& words[1], 18, cpu.cu.ONC1);
370 putbits36_1 (& words[1], 19, cpu.cu.ONC2);
371 putbits36_4 (& words[1], 20, cpu.cu.IA);
372 putbits36_3 (& words[1], 24, cpu.cu.IACHN);
373 putbits36_3 (& words[1], 27, cpu.cu.CNCHN);
374 putbits36_5 (& words[1], 30, cpu.cu.FI_ADDR);
375 putbits36_1 (& words[1], 35, cpu.cycle == INTERRUPT_cycle ? 0 : 1);
376
377
378
379 putbits36_3 (& words[2], 0, cpu.TPR.TRR);
380 putbits36_15 (& words[2], 3, cpu.TPR.TSR);
381
382
383
384 putbits36_3 (& words[2], 27, (word3) cpu.switches.cpu_num);
385 putbits36_6 (& words[2], 30, cpu.cu.delta);
386
387
388
389 putbits36_3 (& words[3], 18, cpu.cu.TSN_VALID[0] ? cpu.cu.TSN_PRNO[0] : 0);
390 putbits36_1 (& words[3], 21, cpu.cu.TSN_VALID[0]);
391 putbits36_3 (& words[3], 22, cpu.cu.TSN_VALID[1] ? cpu.cu.TSN_PRNO[1] : 0);
392 putbits36_1 (& words[3], 25, cpu.cu.TSN_VALID[1]);
393 putbits36_3 (& words[3], 26, cpu.cu.TSN_VALID[2] ? cpu.cu.TSN_PRNO[2] : 0);
394 putbits36_1 (& words[3], 29, cpu.cu.TSN_VALID[2]);
395 putbits36_6 (& words[3], 30, cpu.TPR.TBR);
396
397
398
399 putbits36_18 (& words[4], 0, cpu.PPR.IC);
400
401
402
403 putbits36_18 (& words[4], 18, cpu.cu.IR);
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 putbits36 (& words[5], 0, 18, cpu.TPR.CA);
441 putbits36 (& words[5], 18, 1, cpu.cu.repeat_first);
442 putbits36 (& words[5], 19, 1, cpu.cu.rpt);
443 putbits36 (& words[5], 20, 1, cpu.cu.rd);
444 putbits36 (& words[5], 21, 1, cpu.cu.rl);
445 putbits36 (& words[5], 22, 1, cpu.cu.pot);
446
447 putbits36_1 (& words[5], 24, cpu.cu.xde);
448 putbits36_1 (& words[5], 25, cpu.cu.xdo);
449 putbits36_1 (& words[5], 26, cpu.cu.itp);
450 putbits36_1 (& words[5], 27, cpu.cu.rfi);
451 putbits36_1 (& words[5], 28, cpu.cu.its);
452 putbits36_1 (& words[5], 29, cpu.cu.FIF);
453 putbits36_6 (& words[5], 30, cpu.cu.CT_HOLD);
454
455
456
457 words[6] = cpu.cu.IWB;
458
459
460
461 words[7] = cpu.cu.IRODD;
462
463
464 if_sim_debug (DBG_FAULT, & cpu_dev)
465 dump_words (words);
466
467 if (cpu.tweaks.isolts_mode)
468 {
469 struct
470 {
471 word36 should_be[8];
472 word36 was[8];
473 char *name;
474 }
475 rewrite_table[] =
476 {
477 { { 0000001400021, 0000000000011, 0000001000100, 0000000000000, 0000016400000, 0110015000500, 0110015011000, 0110015011000 },
478 { 0000001400011, 0000000000011, 0000001000100, 0000000000000, 0000016400000, 0110015000100, 0110015011000, 0110015011000 },
479 "pa865 test-03a inhibit",
480 },
481 { { 0000000401001, 0000000000041, 0000001000100, 0000000000000, 0101175000220, 0000006000000, 0100006235100, 0100006235100 },
482 { 0000000601001, 0000000000041, 0000001000100, 0000000000000, 0101175000220, 0000006000000, 0100006235100, 0100006235100 },
483 "pa870 test-01a dir. fault",
484 },
485 { { 0000000451001, 0000000000041, 0000001000100, 0000000000000, 0000000200200, 0000003000000, 0200003716100, 0000005755000 },
486 { 0000000651001, 0000000000041, 0000001000100, 0000000000000, 0000000200200, 0000003000000, 0200003716100, 0000005755000 },
487 "pa885 test-05a xec inst",
488 },
489 { { 0000000451001, 0000000000041, 0000001000100, 0000000000000, 0000000200200, 0000002000000, 0200002717100, 0110002001000 },
490 { 0000000651001, 0000000000041, 0000001000100, 0000000000000, 0000000200200, 0000002000000, 0200002717100, 0110002001000 },
491 "pa885 test-05b xed inst",
492 },
493 { { 0000000451001, 0000000000041, 0000001000100, 0000000000000, 0000000200200, 0000004004000, 0200004235100, 0000005755000 },
494 { 0000000451001, 0000000000041, 0000001000100, 0000000000000, 0000000200200, 0000004002000, 0200004235100, 0000005755000 },
495 "pa885 test-05c xed inst",
496 },
497 { { 0000000451001, 0000000000041, 0000001000100, 0000000000000, 0000001200200, 0000004006000, 0200004235100, 0000005755000 },
498 { 0000000451001, 0000000000041, 0000001000100, 0000000000000, 0000001200200, 0000004002000, 0200004235100, 0000005755000 },
499 "pa885 test-05d xed inst",
500 },
501 { { 0000000454201, 0000000000041, 0000000000100, 0000000000000, 0001777200200, 0002000000500, 0005600560201, 0005600560201 },
502 { 0000000450201, 0000000000041, 0000000000100, 0000000000000, 0001777200200, 0002000000000, 0005600560201, 0005600560201 },
503 "pa885 test-06a rpd inst",
504 },
505 { { 0000000451001, 0000000000041, 0000001000101, 0000000000000, 0002000200200, 0000003500001, 0200003235111, 0002005755012 },
506 { 0000000651001, 0000000000041, 0000001000101, 0000000000000, 0002000202200, 0000003500000, 0200003235111, 0002005755012 },
507 "pa885 test-06b rpd inst",
508 },
509 { { 0000000450201, 0000000000041, 0000000000101, 0000000000000, 0001776200200, 0002015500001, 0002015235031, 0002017755032 },
510 { 0000000450201, 0000000000041, 0000000000101, 0000000000000, 0001776202200, 0002015500000, 0002015235031, 0002017755032 },
511 "pa885 test-06c rpd inst",
512 },
513 { { 0000000450201, 0000000000041, 0000000000101, 0000000000000, 0001776000200, 0002000100012, 0001775235011, 0001775755012 },
514 { 0000000450201, 0000000000041, 0000000000101, 0000000000000, 0001776000200, 0002000100000, 0001775235011, 0001775755012 },
515 "pa885 test-06d rpd inst",
516 },
517 { { 0000000404202, 0000000000041, 0000000000100, 0000000000000, 0002000202200, 0002000000500, 0001773755000, 0001773755000 },
518 { 0000000400202, 0000000000041, 0000000000100, 0000000000000, 0002000202200, 0002000000100, 0001773755000, 0001773755000 },
519 "pa885 test-10a scu snap (acv fault)",
520 }
521 };
522 int i;
523 for (i=0; i < 11; i++)
524 {
525 if (memcmp (words, rewrite_table[i].was, 8*sizeof (word36)) == 0)
526 {
527 memcpy (words, rewrite_table[i].should_be, 8*sizeof (word36));
528 sim_warn("%s: scu rewrite %d: %s\n", __func__, i, rewrite_table[i].name);
529 break;
530 }
531 }
532 }
533 }
534
535 void cu_safe_store (void)
536 {
537
538
539
540
541 scu2words (cpu.scu_data);
542
543 cpu.cu_data.PSR = cpu.PPR.PSR;
544 cpu.cu_data.PRR = cpu.PPR.PRR;
545 cpu.cu_data.IC = cpu.PPR.IC;
546
547 tidy_cu ();
548
549 }
550
551 void tidy_cu (void)
552 {
553
554
555
556
557 cpu.cu.delta = 0;
558 cpu.cu.repeat_first = false;
559 cpu.cu.rpt = false;
560 cpu.cu.rd = false;
561 cpu.cu.rl = false;
562 cpu.cu.pot = false;
563 cpu.cu.itp = false;
564 cpu.cu.its = false;
565 cpu.cu.xde = false;
566 cpu.cu.xdo = false;
567 }
568
569 static void words2scu (word36 * words)
570 {
571 CPT (cpt2U, 7);
572
573
574
575
576 cpu.PPR.PRR = getbits36_3 (words[0], 0);
577 cpu.PPR.PSR = getbits36_15 (words[0], 3);
578 cpu.PPR.P = getbits36_1 (words[0], 18);
579 cpu.cu.XSF = getbits36_1 (words[0], 19);
580 sim_debug (DBG_TRACEEXT, & cpu_dev, "%s sets XSF to %o\n", __func__, cpu.cu.XSF);
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599 cpu.cu.APUCycleBits = (word12) ((cpu.cu.APUCycleBits & 07770) | (word12) getbits36_3 (words[0], 33));
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633 cpu.TPR.TRR = getbits36_3 (words[2], 0);
634 cpu.TPR.TSR = getbits36_15 (words[2], 3);
635
636
637
638
639 cpu.cu.delta = getbits36_6 (words[2], 30);
640
641
642
643
644
645 cpu.cu.TSN_PRNO[0] = getbits36_3 (words[3], 18);
646 cpu.cu.TSN_VALID[0] = getbits36_1 (words[3], 21);
647 cpu.cu.TSN_PRNO[1] = getbits36_3 (words[3], 22);
648 cpu.cu.TSN_VALID[1] = getbits36_1 (words[3], 25);
649 cpu.cu.TSN_PRNO[2] = getbits36_3 (words[3], 26);
650 cpu.cu.TSN_VALID[2] = getbits36_1 (words[3], 29);
651 cpu.TPR.TBR = getbits36_6 (words[3], 30);
652
653
654
655 cpu.cu.IR = getbits36_18 (words[4], 18);
656 cpu.PPR.IC = getbits36_18 (words[4], 0);
657
658
659
660
661
662 cpu.cu.repeat_first = getbits36_1 (words[5], 18);
663 cpu.cu.rpt = getbits36_1 (words[5], 19);
664 cpu.cu.rd = getbits36_1 (words[5], 20);
665 cpu.cu.rl = getbits36_1 (words[5], 21);
666 cpu.cu.pot = getbits36_1 (words[5], 22);
667
668 cpu.cu.xde = getbits36_1 (words[5], 24);
669 cpu.cu.xdo = getbits36_1 (words[5], 25);
670 cpu.cu.itp = getbits36_1 (words[5], 26);
671 cpu.cu.rfi = getbits36_1 (words[5], 27);
672 cpu.cu.its = getbits36_1 (words[5], 28);
673 cpu.cu.FIF = getbits36_1 (words[5], 29);
674 cpu.cu.CT_HOLD = getbits36_6 (words[5], 30);
675
676
677
678 cpu.cu.IWB = words[6];
679
680
681
682 cpu.cu.IRODD = words[7];
683 }
684
685 void cu_safe_restore (void)
686 {
687 words2scu (cpu.scu_data);
688 decode_instruction (IWB_IRODD, & cpu.currentInstruction);
689 }
690
691 static void du2words (word36 * words)
692 {
693 CPT (cpt2U, 7);
694
695 if (cpu.tweaks.isolts_mode)
696 {
697 for (int i = 0; i < 8; i ++)
698 {
699 words[i] = cpu.du.image[i];
700 }
701 }
702 else
703 {
704 memset (words, 0, 8 * sizeof (* words));
705 }
706
707
708
709 putbits36_1 (& words[0], 9, cpu.du.Z);
710 putbits36_1 (& words[0], 10, cpu.du.NOP);
711 putbits36_24 (& words[0], 12, cpu.du.CHTALLY);
712
713
714
715 if (cpu.tweaks.isolts_mode)
716 words[1] = words[0];
717
718
719
720 putbits36_18 (& words[2], 0, cpu.du.D1_PTR_W);
721 putbits36_6 (& words[2], 18, cpu.du.D1_PTR_B);
722 putbits36_2 (& words[2], 25, cpu.du.TAk[0]);
723 putbits36_1 (& words[2], 31, cpu.du.F1);
724 putbits36_1 (& words[2], 32, cpu.du.Ak[0]);
725
726
727
728 putbits36_10 (& words[3], 0, cpu.du.LEVEL1);
729 putbits36_24 (& words[3], 12, cpu.du.D1_RES);
730
731
732
733 putbits36_18 (& words[4], 0, cpu.du.D2_PTR_W);
734 putbits36_6 (& words[4], 18, cpu.du.D2_PTR_B);
735 putbits36_2 (& words[4], 25, cpu.du.TAk[1]);
736 putbits36_1 (& words[4], 30, cpu.du.R);
737 putbits36_1 (& words[4], 31, cpu.du.F2);
738 putbits36_1 (& words[4], 32, cpu.du.Ak[1]);
739
740
741
742 putbits36_10 (& words[5], 0, cpu.du.LEVEL2);
743 putbits36_24 (& words[5], 12, cpu.du.D2_RES);
744
745
746
747 putbits36_18 (& words[6], 0, cpu.du.D3_PTR_W);
748 putbits36_6 (& words[6], 18, cpu.du.D3_PTR_B);
749 putbits36_2 (& words[6], 25, cpu.du.TAk[2]);
750 putbits36_1 (& words[6], 31, cpu.du.F3);
751 putbits36_1 (& words[6], 32, cpu.du.Ak[2]);
752 putbits36_3 (& words[6], 33, cpu.du.JMP);
753
754
755
756 putbits36_24 (& words[7], 12, cpu.du.D3_RES);
757
758 }
759
760 static void words2du (word36 * words)
761 {
762 CPT (cpt2U, 8);
763
764
765 cpu.du.Z = getbits36_1 (words[0], 9);
766 cpu.du.NOP = getbits36_1 (words[0], 10);
767 cpu.du.CHTALLY = getbits36_24 (words[0], 12);
768
769
770
771
772 cpu.du.D1_PTR_W = getbits36_18 (words[2], 0);
773 cpu.du.D1_PTR_B = getbits36_6 (words[2], 18);
774 cpu.du.TAk[0] = getbits36_2 (words[2], 25);
775 cpu.du.F1 = getbits36_1 (words[2], 31);
776 cpu.du.Ak[0] = getbits36_1 (words[2], 32);
777
778
779
780 cpu.du.LEVEL1 = getbits36_10 (words[3], 0);
781 cpu.du.D1_RES = getbits36_24 (words[3], 12);
782
783
784
785 cpu.du.D2_PTR_W = getbits36_18 (words[4], 0);
786 cpu.du.D2_PTR_B = getbits36_6 (words[4], 18);
787 cpu.du.TAk[1] = getbits36_2 (words[4], 25);
788 cpu.du.F2 = getbits36_1 (words[4], 31);
789 cpu.du.Ak[1] = getbits36_1 (words[4], 32);
790
791
792
793 cpu.du.LEVEL2 = getbits36_1 (words[5], 9);
794 cpu.du.D2_RES = getbits36_24 (words[5], 12);
795
796
797
798 cpu.du.D3_PTR_W = getbits36_18 (words[6], 0);
799 cpu.du.D3_PTR_B = getbits36_6 (words[6], 18);
800 cpu.du.TAk[2] = getbits36_2 (words[6], 25);
801 cpu.du.F3 = getbits36_1 (words[6], 31);
802 cpu.du.Ak[2] = getbits36_1 (words[6], 32);
803 cpu.du.JMP = getbits36_3 (words[6], 33);
804
805
806
807 cpu.du.D3_RES = getbits36_24 (words[7], 12);
808
809 if (cpu.tweaks.isolts_mode)
810 {
811 for (int i = 0; i < 8; i ++)
812 {
813 cpu.du.image[i] = words[i];
814 }
815 }
816 }
817
818 static char *PRalias[] = {"ap", "ab", "bp", "bb", "lp", "lb", "sp", "sb" };
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866 static bool _nodudl[] = {
867
868
869 false, false, false, true, false, false, false, true,
870
871 false, false, false, false, false, false, false, false,
872
873
874 false, false, false, true, false, false, false, true,
875
876 false, false, false, false, false, false, false, false,
877
878
879 false, false, true, false, false, false, false, false,
880
881 false, false, false, false, false, false, false, false,
882
883
884 false, false, false, true, false, false, false, true,
885
886 false, false, false, false, false, false, false, false,
887 };
888
889
890
891
892
893 static bool _nocss[] = {
894
895
896 false, false, false, false, false, false, false, false,
897
898 false, false, false, false, false, false, false, false,
899
900
901 false, false, false, true, false, false, false, true,
902
903 false, false, false, false, false, false, false, false,
904
905
906 false, false, true, false, false, true, false, false,
907
908 true, false, true, false, false, false, false, false,
909
910
911 false, false, false, true, false, false, false, true,
912
913 false, false, false, false, false, false, false, false,
914 };
915
916
917 static bool _noddcss[] = {
918
919
920 false, false, false, true, false, false, false, true,
921
922 false, false, false, false, false, false, false, false,
923
924
925 false, false, false, true, false, false, false, true,
926
927 false, false, false, false, false, false, false, false,
928
929
930 false, false, true, false, false, true, false, false,
931
932 true, false, true, false, false, false, false, false,
933
934
935 false, false, false, true, false, false, false, true,
936
937 false, false, false, false, false, false, false, false,
938 };
939
940
941 static bool _nodlcss[] = {
942
943
944 false, false, false, false, false, false, false, true,
945
946 false, false, false, false, false, false, false, false,
947
948
949 false, false, false, true, false, false, false, true,
950
951 false, false, false, false, false, false, false, false,
952
953
954 false, false, true, false, false, true, false, false,
955
956 true, false, true, false, false, false, false, false,
957
958
959 false, false, false, true, false, false, false, true,
960
961 false, false, false, false, false, false, false, false,
962 };
963
964 static bool _onlyaqxn[] = {
965
966
967 false, false, false, true, true, false, false, true,
968
969 false, false, false, false, false, false, false, false,
970
971
972 false, false, false, true, false, false, false, true,
973
974 false, false, false, false, false, false, false, false,
975
976
977 false, false, true, false, false, false, false, false,
978
979 false, false, false, false, false, false, false, false,
980
981
982 false, false, false, true, false, false, false, true,
983
984 false, false, false, false, false, false, false, false,
985 };
986
987 #ifndef QUIET_UNUSED
988 static bool _illmod[] = {
989
990
991 false, false, false, false, false, false, false, false,
992
993 false, false, false, false, false, false, false, false,
994
995
996 false, false, false, true, false, false, false, true,
997
998 false, false, false, false, false, false, false, false,
999
1000
1001 false, false, true, false, false, false, false, false,
1002
1003 false, false, false, false, false, false, false, false,
1004
1005
1006
1007 false, false, false, true, false, false, false, true,
1008 false, false, false, false, false, false, false, false,
1009 };
1010 #endif
1011
1012
1013
1014 #ifdef MATRIX
1015
1016 static long long theMatrix[1024]
1017 [2]
1018 [2]
1019 [64];
1020
1021 void initializeTheMatrix (void)
1022 {
1023 memset (theMatrix, 0, sizeof (theMatrix));
1024 }
1025
1026 void addToTheMatrix (uint32 opcode, bool opcodeX, bool a, word6 tag)
1027 {
1028
1029 uint _opcode = opcode & 01777;
1030 int _opcodeX = opcodeX ? 1 : 0;
1031 int _a = a ? 1 : 0;
1032 int _tag = tag & 077;
1033 theMatrix[_opcode][_opcodeX][_a][_tag] ++;
1034 }
1035
1036 t_stat display_the_matrix (UNUSED int32 arg, UNUSED const char * buf)
1037 {
1038 long long count;
1039
1040 for (int opcode = 0; opcode < 01000; opcode ++)
1041 for (int opcodeX = 0; opcodeX < 2; opcodeX ++)
1042 {
1043 long long total = 0;
1044 for (int a = 0; a < 2; a ++)
1045 for (int tag = 0; tag < 64; tag ++)
1046 if ((count = theMatrix[opcode][opcodeX][a][tag]))
1047 {
1048
1049 static char result[132] = "???";
1050 strcpy (result, "???");
1051
1052 if (opcodes10 [opcode | (opcodeX ? 01000 : 0)].mne)
1053 strcpy (result, opcodes10[opcode | (opcodeX ? 01000 : 0)].mne);
1054 if (a)
1055 strcat (result, " prn|nnnn");
1056 else
1057 strcat (result, " nnnn");
1058
1059
1060 if (extMods[tag].mod)
1061 {
1062 strcat (result, ",");
1063 strcat (result, extMods[tag].mod);
1064 }
1065 if (result[0] == '?')
1066 sim_printf ("%20"PRId64": ? opcode 0%04o X %d a %d tag 0%02do\n",
1067 count, opcode, opcodeX, a, tag);
1068 else
1069 sim_printf ("%20"PRId64": %s\n", count, result);
1070 total += count;
1071 }
1072 static char result[132] = "???";
1073 strcpy (result, "???");
1074 if (total) {
1075
1076 if (opcodes10 [opcode | (opcodeX ? 01000 : 0)].mne)
1077 strcpy (result, opcodes10[opcode | (opcodeX ? 01000 : 0)].mne);
1078 sim_printf ("%20"PRId64": %s\n", total, result);
1079 }
1080 }
1081 return SCPE_OK;
1082 }
1083 #endif
1084
1085
1086
1087 void fetchInstruction (word18 addr)
1088 {
1089 CPT (cpt2U, 9);
1090
1091 if (get_addr_mode () == ABSOLUTE_mode)
1092 {
1093 cpu.TPR.TRR = 0;
1094 cpu.RSDWH_R1 = 0;
1095
1096 }
1097
1098 if (cpu.cu.rd && ((cpu.PPR.IC & 1) != 0))
1099 {
1100 if (cpu.cu.repeat_first)
1101 {
1102 CPT (cpt2U, 10);
1103
1104 }
1105 }
1106 else if (cpu.cu.rpt || cpu.cu.rd || cpu.cu.rl)
1107 {
1108 if (cpu.cu.repeat_first)
1109 {
1110 CPT (cpt2U, 11);
1111 if (addr & 1)
1112 Read (addr, & cpu.cu.IWB, INSTRUCTION_FETCH);
1113 else
1114 {
1115 word36 tmp[2];
1116 Read2 (addr, tmp, INSTRUCTION_FETCH);
1117 cpu.cu.IWB = tmp[0];
1118 cpu.cu.IRODD = tmp[1];
1119 }
1120 }
1121 }
1122 else
1123 {
1124 CPT (cpt2U, 12);
1125
1126
1127
1128
1129
1130 if ((cpu.PPR.IC & 1) == 0)
1131 {
1132 word36 tmp[2];
1133 Read2 (addr, tmp, INSTRUCTION_FETCH);
1134 cpu.cu.IWB = tmp[0];
1135 cpu.cu.IRODD = tmp[1];
1136 }
1137 else
1138 {
1139 Read (addr, & cpu.cu.IWB, INSTRUCTION_FETCH);
1140 cpu.cu.IRODD = cpu.cu.IWB;
1141 }
1142 }
1143 }
1144
1145 #ifdef TESTING
1146 void traceInstruction (uint flag)
1147 {
1148 char buf [256];
1149 if (! flag) goto force;
1150 if_sim_debug (flag, &cpu_dev)
1151 {
1152 force:;
1153 char * compname;
1154 word18 compoffset;
1155 char * where = lookup_address (cpu.PPR.PSR, cpu.PPR.IC, & compname,
1156 & compoffset);
1157 bool isBAR = TST_I_NBAR ? false : true;
1158 if (where)
1159 {
1160 if (get_addr_mode () == ABSOLUTE_mode)
1161 {
1162 if (isBAR)
1163 {
1164 sim_debug (flag, &cpu_dev, "%06o|%06o %s\n",
1165 cpu.BAR.BASE, cpu.PPR.IC, where);
1166 }
1167 else
1168 {
1169 sim_debug (flag, &cpu_dev, "%06o %s\n", cpu.PPR.IC, where);
1170 }
1171 }
1172 else if (get_addr_mode () == APPEND_mode)
1173 {
1174 if (isBAR)
1175 {
1176 sim_debug (flag, &cpu_dev, "%05o:%06o|%06o %s\n",
1177 cpu.PPR.PSR,
1178 cpu.BAR.BASE, cpu.PPR.IC, where);
1179 }
1180 else
1181 {
1182 sim_debug (flag, &cpu_dev, "%05o:%06o %s\n",
1183 cpu.PPR.PSR, cpu.PPR.IC, where);
1184 }
1185 }
1186 list_source (compname, compoffset, flag);
1187 }
1188 if (get_addr_mode () == ABSOLUTE_mode)
1189 {
1190 if (isBAR)
1191 {
1192 sim_debug (flag, &cpu_dev,
1193 "%d: "
1194 "%05o|%06o %012"PRIo64" (%s) %06o %03o(%d) %o %o %o %02o\n",
1195 current_running_cpu_idx,
1196 cpu.BAR.BASE,
1197 cpu.PPR.IC,
1198 IWB_IRODD,
1199 disassemble (buf, IWB_IRODD),
1200 cpu.currentInstruction.address,
1201 cpu.currentInstruction.opcode,
1202 cpu.currentInstruction.opcodeX,
1203 cpu.currentInstruction.b29,
1204 cpu.currentInstruction.i,
1205 GET_TM (cpu.currentInstruction.tag) >> 4,
1206 GET_TD (cpu.currentInstruction.tag) & 017);
1207 }
1208 else
1209 {
1210 sim_debug (flag, &cpu_dev,
1211 "%d: "
1212 "%06o %012"PRIo64" (%s) %06o %03o(%d) %o %o %o %02o\n",
1213 current_running_cpu_idx,
1214 cpu.PPR.IC,
1215 IWB_IRODD,
1216 disassemble (buf, IWB_IRODD),
1217 cpu.currentInstruction.address,
1218 cpu.currentInstruction.opcode,
1219 cpu.currentInstruction.opcodeX,
1220 cpu.currentInstruction.b29,
1221 cpu.currentInstruction.i,
1222 GET_TM (cpu.currentInstruction.tag) >> 4,
1223 GET_TD (cpu.currentInstruction.tag) & 017);
1224 }
1225 }
1226 else if (get_addr_mode () == APPEND_mode)
1227 {
1228 if (isBAR)
1229 {
1230 sim_debug (flag, &cpu_dev,
1231 "%d: "
1232 "%05o:%06o|%06o %o %012"PRIo64" (%s) %06o %03o(%d) %o %o %o %02o\n",
1233 current_running_cpu_idx,
1234 cpu.PPR.PSR,
1235 cpu.BAR.BASE,
1236 cpu.PPR.IC,
1237 cpu.PPR.PRR,
1238 IWB_IRODD,
1239 disassemble (buf, IWB_IRODD),
1240 cpu.currentInstruction.address,
1241 cpu.currentInstruction.opcode,
1242 cpu.currentInstruction.opcodeX,
1243 cpu.currentInstruction.b29, cpu.currentInstruction.i,
1244 GET_TM (cpu.currentInstruction.tag) >> 4,
1245 GET_TD (cpu.currentInstruction.tag) & 017);
1246 }
1247 else
1248 {
1249 sim_debug (flag, &cpu_dev,
1250 "%d: "
1251 "%05o:%06o %o %012"PRIo64" (%s) %06o %03o(%d) %o %o %o %02o\n",
1252 current_running_cpu_idx,
1253 cpu.PPR.PSR,
1254 cpu.PPR.IC,
1255 cpu.PPR.PRR,
1256 IWB_IRODD,
1257 disassemble (buf, IWB_IRODD),
1258 cpu.currentInstruction.address,
1259 cpu.currentInstruction.opcode,
1260 cpu.currentInstruction.opcodeX,
1261 cpu.currentInstruction.b29,
1262 cpu.currentInstruction.i,
1263 GET_TM (cpu.currentInstruction.tag) >> 4,
1264 GET_TD (cpu.currentInstruction.tag) & 017);
1265 }
1266 }
1267 }
1268
1269 }
1270 #endif
1271
1272 bool chkOVF (void)
1273 {
1274 if (cpu.cu.rpt || cpu.cu.rd || cpu.cu.rl)
1275 {
1276
1277
1278 if ((cpu.rX[0] & 00001) == 0)
1279 return false;
1280 }
1281 return true;
1282 }
1283
1284 bool tstOVFfault (void)
1285 {
1286
1287 if (TST_I_OMASK)
1288 return false;
1289
1290 if (cpu.cu.rpt || cpu.cu.rd || cpu.cu.rl)
1291 {
1292
1293
1294 if ((cpu.rX[0] & 00001) == 0)
1295 return false;
1296 }
1297 return true;
1298 }
1299
1300 #ifdef TESTING
1301 # include "tracker.h"
1302 #endif
1303
1304 t_stat executeInstruction (void) {
1305 #ifdef TESTING
1306 trk (cpu.cycleCnt, cpu.PPR.PSR, cpu.PPR.IC, IWB_IRODD);
1307 #endif
1308 CPT (cpt2U, 13);
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363 DCDstruct * ci = & cpu.currentInstruction;
1364 decode_instruction (IWB_IRODD, ci);
1365 const struct opcode_s *info = ci->info;
1366
1367
1368
1369 const uint ndes = info->ndes;
1370 const bool restart = cpu.cu.rfi;
1371 cpu.cu.rfi = 0;
1372 const opc_flag flags = info->flags;
1373 const enum opc_mod mods = info->mods;
1374 const uint32 opcode = ci->opcode;
1375 const bool opcodeX = ci->opcodeX;
1376 const word6 tag = ci->tag;
1377
1378 #ifdef MATRIX
1379 {
1380 const uint32 opcode = ci->opcode;
1381 const bool opcodeX = ci->opcodeX;
1382
1383 const bool b29 = ci->b29;
1384
1385 const word6 tag = ci->tag;
1386
1387 addToTheMatrix (opcode, opcodeX, b29, tag);
1388 }
1389 #endif
1390
1391
1392
1393 #define likely(x) __builtin_expect ((x), 1)
1394 #define unlikely(x) __builtin_expect ((x), 0)
1395
1396 if (ci->b29)
1397 ci->address = SIGNEXT15_18 (ci->address & MASK15);
1398
1399 L68_ (
1400 CPTUR (cptUseMR);
1401 if (unlikely (cpu.MR.emr && cpu.MR.OC_TRAP)) {
1402 if (cpu.MR.OPCODE == opcode && cpu.MR.OPCODEX == opcodeX) {
1403 if (cpu.MR.ihrrs) {
1404 cpu.MR.ihr = 0;
1405 }
1406 CPT (cpt2U, 14);
1407
1408 do_FFV_fault (1, "OC TRAP");
1409 }
1410 }
1411 )
1412
1413
1414
1415
1416
1417 if (likely (!restart) || unlikely (ndes > 0)) {
1418 cpu.cu.TSN_VALID[0] = 0;
1419 cpu.cu.TSN_VALID[1] = 0;
1420 cpu.cu.TSN_VALID[2] = 0;
1421 cpu.cu.TSN_PRNO[0] = 0;
1422 cpu.cu.TSN_PRNO[1] = 0;
1423 cpu.cu.TSN_PRNO[2] = 0;
1424 }
1425
1426 if (unlikely (restart))
1427 goto restart_1;
1428
1429
1430
1431
1432
1433 cpu.cu.XSF = 0;
1434
1435 cpu.cu.pot = 0;
1436 cpu.cu.its = 0;
1437 cpu.cu.itp = 0;
1438
1439 CPT (cpt2U, 14);
1440
1441 PNL (L68_ (cpu.AR_F_E = false;))
1442
1443
1444 cpu.cu.APUCycleBits &= 07770;
1445
1446
1447
1448
1449
1450
1451 if (unlikely (cpu.isXED)) {
1452 if (flags & NO_XED)
1453 doFault (FAULT_IPR, fst_ill_proc, "Instruction not allowed in XEC/XED");
1454
1455
1456 if (opcode == 0717 && !opcodeX && cpu.cu.xde && cpu.cu.xdo )
1457 doFault (FAULT_IPR, fst_ill_proc, "XED of XED on even word");
1458
1459 if (opcode == 0560 && !opcodeX) {
1460
1461
1462 if (cpu.cu.xde && cpu.cu.xdo )
1463 doFault (FAULT_IPR, (_fault_subtype) {.fault_ipr_subtype=FR_ILL_PROC}, "XED of RPD on even word");
1464
1465
1466 if (!cpu.cu.xde && cpu.cu.xdo && !(cpu.PPR.IC & 1))
1467 doFault (FAULT_IPR, (_fault_subtype) {.fault_ipr_subtype=FR_ILL_PROC}, "XED of RPD on odd word, even IC");
1468 }
1469 } else if (unlikely (cpu.isExec)) {
1470
1471
1472 if (opcode == 0560 && !opcodeX && cpu.cu.xde && !(cpu.PPR.IC & 1))
1473 doFault (FAULT_IPR, (_fault_subtype) {.fault_ipr_subtype=FR_ILL_PROC}, "XEC of RPx on even word");
1474 }
1475
1476
1477
1478 fault_ipr_subtype_ RPx_fault = 0;
1479
1480
1481
1482 if (unlikely (cpu.cu.rpt || cpu.cu.rd || cpu.cu.rl)) {
1483 if (! (flags & NO_TAG)) {
1484
1485
1486
1487 switch (GET_TM (tag)) {
1488 case TM_RI:
1489 if (cpu.cu.rl)
1490 RPx_fault |= FR_ILL_MOD;
1491 break;
1492 case TM_R:
1493 break;
1494 default:
1495
1496 RPx_fault |= FR_ILL_MOD;
1497 }
1498
1499 word6 Td = GET_TD (tag);
1500 if (Td == TD_X0)
1501 RPx_fault |= FR_ILL_MOD;
1502 if (Td < TD_X0)
1503 RPx_fault |= FR_ILL_MOD;
1504 }
1505
1506 DPS8M_ (
1507
1508
1509 if (RPx_fault && !opcodeX && opcode==0413)
1510 doFault (FAULT_IPR, (_fault_subtype) {.fault_ipr_subtype=RPx_fault}, "DPS8M rscr early raise");
1511 )
1512
1513
1514
1515 if (unlikely (cpu.cu.rpt || cpu.cu.rd || cpu.cu.rl)) {
1516 if (flags & NO_RPT)
1517 RPx_fault |= FR_ILL_PROC;
1518 }
1519
1520 if (unlikely (cpu.cu.rl)) {
1521 if (flags & NO_RPL)
1522 RPx_fault |= FR_ILL_PROC;
1523 }
1524
1525 L68_ (
1526
1527
1528
1529 if (RPx_fault && !opcodeX && (opcode==0751 || opcode==0752 || opcode==0551 || opcode==0552 || opcode==0452 || opcode==0674))
1530 RPx_fault |= FR_ILL_MOD;
1531 )
1532 }
1533
1534
1535 if (unlikely (RPx_fault != 0))
1536 doFault (FAULT_IPR, (_fault_subtype) {.fault_ipr_subtype=RPx_fault}, "RPx test fail");
1537
1538
1539
1540
1541 fault_ipr_subtype_ mod_fault = 0;
1542
1543
1544 if (mods == NO_CSS) {
1545 if (_nocss[tag])
1546 mod_fault |= FR_ILL_MOD;
1547 }
1548
1549 else if (mods == NO_DDCSS) {
1550 if (_noddcss[tag])
1551 mod_fault |= FR_ILL_MOD;
1552 }
1553
1554 else if (mods == NO_DLCSS) {
1555 if (_nodlcss[tag])
1556 mod_fault |= FR_ILL_MOD;
1557 }
1558
1559 else if (mods == NO_DUDL) {
1560 if (_nodudl[tag])
1561 mod_fault |= FR_ILL_MOD;
1562 }
1563 else if ((unsigned long long)mods == (unsigned long long)ONLY_AU_QU_AL_QL_XN) {
1564 if (_onlyaqxn[tag])
1565 mod_fault |= FR_ILL_MOD;
1566 }
1567
1568 L68_ (
1569
1570 if (mod_fault)
1571 doFault (FAULT_IPR, (_fault_subtype) {.fault_ipr_subtype=mod_fault}, "Illegal modifier");
1572 )
1573
1574
1575
1576 if (unlikely (flags & PRIV_INS)) {
1577 DPS8M_ (
1578
1579
1580 if (((opcode == 0232 || opcode == 0173) && opcodeX ) || (opcode == 0257))
1581 doFault (FAULT_IPR, (_fault_subtype) {.fault_ipr_subtype=FR_ILL_OP|mod_fault}, "Attempted execution of multics privileged instruction.");
1582 )
1583
1584 if (!is_priv_mode ()) {
1585
1586
1587 bool prv;
1588 DPS8M_ (
1589 prv =((opcode == 0212 || opcode == 0232 || opcode == 0613 || opcode == 0657) && !opcodeX ) ||
1590 ((opcode == 0254 || opcode == 0774) && opcodeX ) ||
1591 (opcode == 0557 || opcode == 0154);
1592 )
1593 L68_ (
1594
1595 prv = ((opcode == 0212 || opcode == 0232 || opcode == 0613 || opcode == 0657) && !opcodeX ) ||
1596 ((opcode == 0254 || opcode == 0774 || opcode == 0232 || opcode == 0173) && opcodeX ) ||
1597 (opcode == 0557 || opcode == 0154 || opcode == 0257);
1598 )
1599 if (prv) {
1600 if (!get_bar_mode ()) {
1601
1602 doFault (FAULT_IPR, (_fault_subtype) {.fault_ipr_subtype=FR_ILL_SLV|mod_fault}, "Attempted execution of multics privileged instruction.");
1603 } else {
1604 doFault (FAULT_IPR, (_fault_subtype) {.fault_ipr_subtype=FR_ILL_OP|mod_fault}, "Attempted execution of multics privileged instruction.");
1605 }
1606 }
1607 doFault (FAULT_IPR, (_fault_subtype) {.fault_ipr_subtype=FR_ILL_SLV|mod_fault}, "Attempted execution of privileged instruction.");
1608 }
1609 }
1610
1611 if (unlikely (flags & NO_BAR)) {
1612 if (get_bar_mode()) {
1613
1614
1615
1616 if (opcode == 0230 && !opcodeX)
1617 doFault (FAULT_IPR, (_fault_subtype) {.fault_ipr_subtype=FR_ILL_SLV|mod_fault}, "Attempted BAR execution of nonprivileged instruction.");
1618 else
1619 doFault (FAULT_IPR, (_fault_subtype) {.fault_ipr_subtype=FR_ILL_OP|mod_fault}, "Attempted BAR execution of nonprivileged instruction.");
1620 }
1621 }
1622
1623 DPS8M_ (
1624
1625 if (unlikely (mod_fault != 0))
1626 doFault (FAULT_IPR, (_fault_subtype) {.fault_ipr_subtype=mod_fault}, "Illegal modifier");
1627 )
1628
1629
1630
1631
1632
1633
1634 restart_1:
1635 CPT (cpt2U, 15);
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648 ci->stiTally = TST_I_TALLY;
1649
1650
1651
1652
1653
1654 #ifndef SPEED
1655
1656
1657
1658 {
1659 traceInstruction (DBG_TRACE);
1660 # ifdef DBGEVENT
1661 int dbgevt;
1662 if (n_dbgevents && (dbgevt = (dbgevent_lookup (cpu.PPR.PSR, cpu.PPR.IC))) >= 0) {
1663 if (dbgevents[dbgevt].t0)
1664 clock_gettime (CLOCK_REALTIME, & dbgevent_t0);
1665 struct timespec now, delta;
1666 clock_gettime (CLOCK_REALTIME, & now);
1667 timespec_diff (& dbgevent_t0, & now, & delta);
1668 sim_printf ("[%d] %5ld.%03ld %s\r\n", dbgevt, delta.tv_sec, delta.tv_nsec/1000000, dbgevents[dbgevt].tag);
1669 }
1670 # endif
1671 # ifdef TESTING
1672 HDBGTrace ("");
1673 # endif
1674 }
1675 #else
1676
1677
1678 # ifdef TESTING
1679 HDBGTrace ("");
1680 # endif
1681 #endif
1682
1683
1684
1685
1686
1687 cpu.du.JMP = (word3) ndes;
1688 cpu.dlyFlt = false;
1689
1690
1691
1692
1693
1694 if (unlikely (cpu.cu.rpt || cpu.cu.rd || cpu.cu.rl)) {
1695 CPT (cpt2U, 15);
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753 sim_debug (DBG_TRACEEXT, & cpu_dev, "RPT/RPD first %d rpt %d rd %d e/o %d X0 %06o a %d b %d\n", cpu.cu.repeat_first, cpu.cu.rpt, cpu.cu.rd, cpu.PPR.IC & 1, cpu.rX[0], !! (cpu.rX[0] & 01000), !! (cpu.rX[0] & 0400));
1754 sim_debug (DBG_TRACEEXT, & cpu_dev, "RPT/RPD CA %06o\n", cpu.TPR.CA);
1755
1756
1757
1758 if (cpu.cu.repeat_first) {
1759 CPT (cpt2U, 16);
1760
1761
1762
1763 bool icOdd = !! (cpu.PPR.IC & 1);
1764 bool icEven = ! icOdd;
1765
1766
1767 if (cpu.cu.rpt || (cpu.cu.rd && icOdd) || cpu.cu.rl)
1768 cpu.cu.repeat_first = false;
1769
1770
1771
1772
1773 if (cpu.cu.rpt ||
1774 (cpu.cu.rd && icEven) ||
1775 (cpu.cu.rd && icOdd) ||
1776 cpu.cu.rl) {
1777 word18 offset = ci->address;
1778 offset &= AMASK;
1779
1780 sim_debug (DBG_TRACEEXT, & cpu_dev, "rpt/rd/rl repeat first; offset is %06o\n", offset);
1781
1782 word6 Td = GET_TD (tag);
1783 uint Xn = X (Td);
1784 sim_debug (DBG_TRACEEXT, & cpu_dev, "rpt/rd/rl repeat first; X%d was %06o\n", Xn, cpu.rX[Xn]);
1785
1786 cpu.TPR.CA = (cpu.rX[Xn] + offset) & AMASK;
1787 cpu.rX[Xn] = cpu.TPR.CA;
1788 #ifdef TESTING
1789 HDBGRegXW (Xn, "rpt 1st");
1790 #endif
1791 sim_debug (DBG_TRACEEXT, & cpu_dev, "rpt/rd/rl repeat first; X%d now %06o\n", Xn, cpu.rX[Xn]);
1792 }
1793
1794 }
1795 }
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805 if (unlikely (ndes > 0)) {
1806 CPT (cpt2U, 27);
1807 sim_debug (DBG_APPENDING, &cpu_dev, "initialize EIS descriptors\n");
1808
1809 if (!restart) {
1810 CPT (cpt2U, 28);
1811 cpu.du.CHTALLY = 0;
1812 cpu.du.Z = 1;
1813 }
1814 for (uint n = 0; n < ndes; n += 1) {
1815 CPT (cpt2U, 29 + n);
1816
1817
1818
1819
1820
1821
1822
1823
1824 cpu.TPR.TRR = cpu.PPR.PRR;
1825 cpu.TPR.TSR = cpu.PPR.PSR;
1826
1827 word18 saveIC = cpu.PPR.IC;
1828 Read (cpu.PPR.IC + 1 + n, & cpu.currentEISinstruction.op[n], INSTRUCTION_FETCH);
1829 cpu.PPR.IC = saveIC;
1830 }
1831 PNL (cpu.IWRAddr = cpu.currentEISinstruction.op[0]);
1832 setupEISoperands ();
1833 }
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843 else {
1844 CPT (cpt2U, 32);
1845 CPT (cpt2U, 33);
1846 if (ci->b29) {
1847 CPT (cpt2U, 34);
1848
1849
1850
1851 word3 n = GET_PRN(IWB_IRODD);
1852 word15 offset = GET_OFFSET(IWB_IRODD);
1853 CPTUR (cptUsePRn + n);
1854
1855 sim_debug (DBG_APPENDING, &cpu_dev, "doPtrReg: PR[%o] SNR=%05o RNR=%o WORDNO=%06o " "BITNO=%02o\n", n, cpu.PAR[n].SNR, cpu.PAR[n].RNR, cpu.PAR[n].WORDNO, GET_PR_BITNO (n));
1856
1857
1858
1859
1860
1861
1862 cpu.TPR.TBR = GET_PR_BITNO (n);
1863
1864 cpu.TPR.TSR = cpu.PAR[n].SNR;
1865 if (ci->info->flags & TRANSFER_INS)
1866 cpu.TPR.TRR = max (cpu.PAR[n].RNR, cpu.PPR.PRR);
1867 else
1868 cpu.TPR.TRR = max3 (cpu.PAR[n].RNR, cpu.TPR.TRR, cpu.PPR.PRR);
1869
1870 sim_debug (DBG_APPENDING, &cpu_dev, "doPtrReg: n=%o offset=%05o TPR.CA=%06o " "TPR.TBR=%o TPR.TSR=%05o TPR.TRR=%o\n", n, offset, cpu.TPR.CA, cpu.TPR.TBR, cpu.TPR.TSR, cpu.TPR.TRR);
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880 } else {
1881
1882 if (!restart) {
1883 CPT (cpt2U, 35);
1884 cpu.cu.TSN_VALID [0] = 0;
1885 cpu.TPR.TBR = 0;
1886 if (get_addr_mode () == ABSOLUTE_mode) {
1887 cpu.TPR.TSR = cpu.PPR.PSR;
1888 cpu.TPR.TRR = 0;
1889 cpu.RSDWH_R1 = 0;
1890 }
1891 }
1892 }
1893
1894
1895 if (!restart)
1896 cpu.cu.CT_HOLD = 0;
1897
1898
1899 cpu.ou.directOperandFlag = false;
1900 cpu.ou.directOperand = 0;
1901 cpu.ou.characterOperandSize = 0;
1902 cpu.ou.characterOperandOffset = 0;
1903 cpu.ou.crflag = false;
1904
1905 if ((flags & PREPARE_CA) || WRITEOP (ci) || READOP (ci)) {
1906 CPT (cpt2L, 1);
1907 do_caf ();
1908 PNL (L68_ (cpu.AR_F_E = true;))
1909 cpu.iefpFinalAddress = cpu.TPR.CA;
1910 }
1911
1912 if (READOP (ci)) {
1913 CPT (cpt2L, 2);
1914 readOperands ();
1915 #ifdef LOCKLESS
1916 cpu.rmw_address = cpu.iefpFinalAddress;
1917 #endif
1918 if (cpu.cu.rl) {
1919 switch (operand_size ()) {
1920 case 1:
1921 cpu.lnk = GETHI36 (cpu.CY);
1922 cpu.CY &= MASK18;
1923 break;
1924
1925 case 2:
1926 cpu.lnk = GETHI36 (cpu.Ypair[0]);
1927 cpu.Ypair[0] &= MASK18;
1928 break;
1929
1930 default:
1931 break;
1932 }
1933 }
1934 }
1935 PNL (cpu.IWRAddr = 0);
1936 }
1937
1938
1939
1940 cpu.useZone = false;
1941 cpu.zone = MASK36;
1942
1943
1944
1945
1946
1947 t_stat ret = doInstruction ();
1948
1949
1950
1951
1952
1953 cpu.last_write = 0;
1954 if (WRITEOP (ci)) {
1955 CPT (cpt2L, 3);
1956 cpu.last_write = cpu.TPR.CA;
1957 #ifdef LOCKLESS
1958 if ((ci->info->flags & RMW) == RMW) {
1959 if (operand_size() != 1)
1960 sim_warn("executeInstruction: operand_size!= 1\n");
1961 if (cpu.iefpFinalAddress != cpu.rmw_address)
1962 sim_warn("executeInstruction: write addr changed %o %d\n", cpu.iefpFinalAddress, cpu.rmw_address);
1963 core_write_unlock (cpu.iefpFinalAddress, cpu.CY, __func__);
1964 # ifdef TESTING
1965 HDBGMWrite (cpu.iefpFinalAddress, cpu.CY, "Write RMW");
1966 # endif
1967 } else
1968 writeOperands ();
1969 #else
1970 writeOperands ();
1971 #endif
1972 }
1973
1974 else if (flags & PREPARE_CA) {
1975
1976
1977 fauxDoAppendCycle (OPERAND_READ);
1978 cpu.TPR.TRR = cpu.PPR.PRR;
1979 cpu.TPR.TSR = cpu.PPR.PSR;
1980 cpu.TPR.TBR = 0;
1981 }
1982
1983
1984
1985
1986
1987
1988
1989
1990 bool icOdd = !! (cpu.PPR.IC & 1);
1991 bool icEven = ! icOdd;
1992
1993
1994
1995
1996
1997
1998
1999 bool rf = cpu.cu.repeat_first;
2000 if (rf && cpu.cu.rd && icEven)
2001 rf = false;
2002
2003 if (unlikely ((! rf) && (cpu.cu.rpt || cpu.cu.rd || cpu.cu.rl))) {
2004 CPT (cpt2L, 7);
2005
2006
2007
2008
2009 if (cpu.cu.rpt || cpu.cu.rd) {
2010
2011
2012 bool rptA = !! (cpu.rX[0] & 01000);
2013 bool rptB = !! (cpu.rX[0] & 00400);
2014
2015 sim_debug (DBG_TRACEEXT, & cpu_dev, "RPT/RPD delta first %d rf %d rpt %d rd %d " "e/o %d X0 %06o a %d b %d\n", cpu.cu.repeat_first, rf, cpu.cu.rpt, cpu.cu.rd, icOdd, cpu.rX[0], rptA, rptB);
2016
2017 if (cpu.cu.rpt) {
2018 CPT (cpt2L, 8);
2019 uint Xn = (uint) getbits36_3 (cpu.cu.IWB, 36 - 3);
2020 cpu.TPR.CA = (cpu.rX[Xn] + cpu.cu.delta) & AMASK;
2021 cpu.rX[Xn] = cpu.TPR.CA;
2022 #ifdef TESTING
2023 HDBGRegXW (Xn, "rpt delta");
2024 #endif
2025 sim_debug (DBG_TRACEEXT, & cpu_dev, "RPT/RPD delta; X%d now %06o\n", Xn, cpu.rX[Xn]);
2026 }
2027
2028
2029
2030
2031
2032 if (cpu.cu.rd && icOdd && rptA) {
2033 CPT (cpt2L, 9);
2034
2035 uint Xn = (uint) getbits36_3 (cpu.cu.IWB, 36 - 3);
2036 cpu.TPR.CA = (cpu.rX[Xn] + cpu.cu.delta) & AMASK;
2037 cpu.rX[Xn] = cpu.TPR.CA;
2038 #ifdef TESTING
2039 HDBGRegXW (Xn, "rpd delta even");
2040 #endif
2041 sim_debug (DBG_TRACEEXT, & cpu_dev, "RPT/RPD delta; X%d now %06o\n", Xn, cpu.rX[Xn]);
2042 }
2043
2044 if (cpu.cu.rd && icOdd && rptB) {
2045 CPT (cpt2L, 10);
2046
2047 uint Xn = (uint) getbits36_3 (cpu.cu.IRODD, 36 - 3);
2048 cpu.TPR.CA = (cpu.rX[Xn] + cpu.cu.delta) & AMASK;
2049 cpu.rX[Xn] = cpu.TPR.CA;
2050 #ifdef TESTING
2051 HDBGRegXW (Xn, "rpd delta odd");
2052 #endif
2053 sim_debug (DBG_TRACEEXT, & cpu_dev, "RPT/RPD delta; X%d now %06o\n", Xn, cpu.rX[Xn]);
2054 }
2055 }
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070 bool flt;
2071 if (cpu.tweaks.l68_mode)
2072 flt = (cpu.cu.rl || cpu.cu.rpt || cpu.cu.rd) && cpu.dlyFlt;
2073 else
2074 flt = cpu.cu.rl && cpu.dlyFlt;
2075 if (flt) {
2076 CPT (cpt2L, 14);
2077 doFault (cpu.dlyFltNum, cpu.dlySubFltNum, cpu.dlyCtx);
2078 }
2079
2080
2081
2082
2083
2084 if (cpu.cu.rpt || (cpu.cu.rd && icOdd) || cpu.cu.rl) {
2085 CPT (cpt2L, 12);
2086 bool exit = false;
2087
2088
2089
2090
2091 uint x = (uint) getbits18 (cpu.rX[0], 0, 8);
2092
2093
2094 x = (uint) (((int) x) - 1);
2095 x &= MASK8;
2096 putbits18 (& cpu.rX[0], 0, 8, x);
2097 #ifdef TESTING
2098 HDBGRegXW (0, "rpt term");
2099 #endif
2100
2101
2102
2103
2104
2105 sim_debug (DBG_TRACEEXT, & cpu_dev, "tally %d\n", x);
2106 if (x == 0) {
2107 sim_debug (DBG_TRACEEXT, & cpu_dev, "tally runout\n");
2108 SET_I_TALLY;
2109 exit = true;
2110 } else {
2111 sim_debug (DBG_TRACEEXT, & cpu_dev, "not tally runout\n");
2112 CLR_I_TALLY;
2113 }
2114
2115
2116
2117
2118 if (TST_I_ZERO && (cpu.rX[0] & 0100)) {
2119 sim_debug (DBG_TRACEEXT, & cpu_dev, "is zero terminate\n");
2120 CLR_I_TALLY;
2121 exit = true;
2122 }
2123 if (!TST_I_ZERO && (cpu.rX[0] & 040)) {
2124 sim_debug (DBG_TRACEEXT, & cpu_dev, "is not zero terminate\n");
2125 CLR_I_TALLY;
2126 exit = true;
2127 }
2128 if (TST_I_NEG && (cpu.rX[0] & 020)) {
2129 sim_debug (DBG_TRACEEXT, & cpu_dev, "is neg terminate\n");
2130 CLR_I_TALLY;
2131 exit = true;
2132 }
2133 if (!TST_I_NEG && (cpu.rX[0] & 010)) {
2134 sim_debug (DBG_TRACEEXT, & cpu_dev, "is not neg terminate\n");
2135 CLR_I_TALLY;
2136 exit = true;
2137 }
2138 if (TST_I_CARRY && (cpu.rX[0] & 04)) {
2139 sim_debug (DBG_TRACEEXT, & cpu_dev, "is carry terminate\n");
2140 CLR_I_TALLY;
2141 exit = true;
2142 }
2143 if (!TST_I_CARRY && (cpu.rX[0] & 02)) {
2144 sim_debug (DBG_TRACEEXT, & cpu_dev, "is not carry terminate\n");
2145 CLR_I_TALLY;
2146 exit = true;
2147 }
2148 if (TST_I_OFLOW && (cpu.rX[0] & 01)) {
2149 sim_debug (DBG_TRACEEXT, & cpu_dev, "is overflow terminate\n");
2150
2151
2152 SET_I_TALLY;
2153 exit = true;
2154 }
2155
2156 if (exit) {
2157 CPT (cpt2L, 13);
2158 cpu.cu.rpt = false;
2159 cpu.cu.rd = false;
2160 cpu.cu.rl = false;
2161 } else {
2162 sim_debug (DBG_TRACEEXT, & cpu_dev, "not terminate\n");
2163 }
2164 }
2165
2166 if (cpu.cu.rl) {
2167 CPT (cpt2L, 11);
2168 if (cpu.lnk == 0) {
2169 CPT (cpt2L, 13);
2170 cpu.cu.rpt = false;
2171 cpu.cu.rd = false;
2172 cpu.cu.rl = false;
2173 SET_I_TALLY;
2174 } else {
2175
2176 uint Xn = (uint) getbits36_3 (cpu.cu.IWB, 36 - 3);
2177
2178
2179 cpu.rX[Xn] = cpu.lnk;
2180 #ifdef TESTING
2181 HDBGRegXW (Xn, "rl");
2182 #endif
2183 }
2184 }
2185 }
2186
2187 if (unlikely (cpu.dlyFlt)) {
2188 CPT (cpt2L, 14);
2189 doFault (cpu.dlyFltNum, cpu.dlySubFltNum, cpu.dlyCtx);
2190 }
2191
2192
2193
2194
2195
2196 cpu.instrCnt ++;
2197
2198 if_sim_debug (DBG_REGDUMP, & cpu_dev) {
2199 char buf [256];
2200 sim_debug (DBG_REGDUMPAQI, &cpu_dev, "A=%012"PRIo64" Q=%012"PRIo64" IR:%s\n", cpu.rA, cpu.rQ, dump_flags (buf, cpu.cu.IR));
2201 #if !defined(__MINGW64__) || !defined(__MINGW32__)
2202 sim_debug (DBG_REGDUMPFLT, &cpu_dev, "E=%03o A=%012"PRIo64" Q=%012"PRIo64" %.10Lg\n", cpu.rE, cpu.rA, cpu.rQ, EAQToIEEElongdouble ());
2203 #else
2204 sim_debug (DBG_REGDUMPFLT, &cpu_dev, "E=%03o A=%012"PRIo64" Q=%012"PRIo64" %.10g\n", cpu.rE, cpu.rA, cpu.rQ, EAQToIEEEdouble ());
2205 #endif
2206 sim_debug (DBG_REGDUMPIDX, &cpu_dev, "X[0]=%06o X[1]=%06o X[2]=%06o X[3]=%06o\n", cpu.rX[0], cpu.rX[1], cpu.rX[2], cpu.rX[3]);
2207 sim_debug (DBG_REGDUMPIDX, &cpu_dev, "X[4]=%06o X[5]=%06o X[6]=%06o X[7]=%06o\n", cpu.rX[4], cpu.rX[5], cpu.rX[6], cpu.rX[7]);
2208 for (int n = 0 ; n < 8 ; n++) {
2209 sim_debug (DBG_REGDUMPPR, &cpu_dev, "PR%d/%s: SNR=%05o RNR=%o WORDNO=%06o BITNO:%02o ARCHAR:%o ARBITNO:%02o\n", n, PRalias[n], cpu.PR[n].SNR, cpu.PR[n].RNR, cpu.PR[n].WORDNO, GET_PR_BITNO (n), GET_AR_CHAR (n), GET_AR_BITNO (n));
2210 }
2211 sim_debug (DBG_REGDUMPPPR, &cpu_dev, "PRR:%o PSR:%05o P:%o IC:%06o\n", cpu.PPR.PRR, cpu.PPR.PSR, cpu.PPR.P, cpu.PPR.IC);
2212 sim_debug (DBG_REGDUMPDSBR, &cpu_dev, "ADDR:%08o BND:%05o U:%o STACK:%04o\n", cpu.DSBR.ADDR, cpu.DSBR.BND, cpu.DSBR.U, cpu.DSBR.STACK);
2213 }
2214
2215
2216
2217
2218
2219 return ret;
2220 }
2221
2222
2223
2224
2225 static inline void overflow (bool ovf, bool dly, const char * msg)
2226 {
2227 CPT (cpt2L, 15);
2228
2229
2230 if (ovf && chkOVF ())
2231 {
2232 SET_I_OFLOW;
2233
2234 if (tstOVFfault ())
2235 {
2236 CPT (cpt2L, 16);
2237
2238 if (cpu.cu.rpt || cpu.cu.rd || cpu.cu.rl)
2239 {
2240 SET_I_TALLY;
2241 }
2242 if (dly)
2243 dlyDoFault (FAULT_OFL, fst_zero, msg);
2244 else
2245 doFault (FAULT_OFL, fst_zero, msg);
2246 }
2247 }
2248 }
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269 static t_stat doInstruction (void)
2270 {
2271 DCDstruct * i = & cpu.currentInstruction;
2272
2273
2274
2275
2276 if (i->info->ndes > 0)
2277 CLR_I_MIF;
2278
2279 L68_ (
2280 cpu.ou.eac = 0;
2281 cpu.ou.RB1_FULL = 0;
2282 cpu.ou.RP_FULL = 0;
2283 cpu.ou.RS_FULL = 0;
2284 cpu.ou.STR_OP = 0;
2285 cpu.ou.cycle = 0;
2286 )
2287 PNL (cpu.ou.RS = (word9) i->opcode);
2288 PNL (L68_ (DU_CYCLE_FDUD;))
2289 cpu.skip_cu_hist = false;
2290 memcpy (& cpu.MR_cache, & cpu.MR, sizeof (cpu.MR_cache));
2291
2292
2293 #define x0(n) (n)
2294 #define x1(n) (n|01000)
2295
2296
2297 uint32 opcode10 = i->opcode10;
2298
2299 #ifdef PANEL68
2300 if (insGrp [opcode10])
2301 {
2302 word8 grp = insGrp [opcode10] - 1;
2303 uint row = grp / 36;
2304 uint col = grp % 36;
2305 CPT (cpt3U + row, col);
2306 }
2307 #endif
2308 bool is_ou = false;
2309 bool is_du = false;
2310 if (cpu.tweaks.l68_mode) {
2311 if (opcodes10[opcode10].reg_use & is_OU) {
2312 is_ou = true;
2313 #ifdef PANEL68
2314
2315 cpu.ou.RB1_FULL = cpu.ou.RP_FULL = cpu.ou.RS_FULL = 1;
2316 cpu.ou.cycle |= ou_GIN;
2317 cpu.ou.opsz = (opcodes10[i->opcode10].reg_use >> 12) & 037;
2318 word10 reguse = (opcodes10[i->opcode10].reg_use) & MASK10;
2319 cpu.ou.reguse = reguse;
2320 if (reguse & ru_A) CPT (cpt5U, 4);
2321 if (reguse & ru_Q) CPT (cpt5U, 5);
2322 if (reguse & ru_X0) CPT (cpt5U, 6);
2323 if (reguse & ru_X1) CPT (cpt5U, 7);
2324 if (reguse & ru_X2) CPT (cpt5U, 8);
2325 if (reguse & ru_X3) CPT (cpt5U, 9);
2326 if (reguse & ru_X4) CPT (cpt5U, 10);
2327 if (reguse & ru_X5) CPT (cpt5U, 11);
2328 if (reguse & ru_X6) CPT (cpt5U, 12);
2329 if (reguse & ru_X7) CPT (cpt5U, 13);
2330 #endif
2331 }
2332 if (opcodes10[opcode10].reg_use & is_DU) {
2333 is_du = true;
2334 PNL (DU_CYCLE_nDUD;)
2335 }
2336 }
2337
2338 switch (opcode10)
2339 {
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585 case x0 (0350):
2586 case x1 (0351):
2587 case x0 (0352):
2588 case x1 (0353):
2589 case x0 (0370):
2590 case x1 (0371):
2591 case x0 (0372):
2592 case x1 (0373):
2593
2594
2595
2596
2597
2598 {
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608 uint n = ((opcode10 & 020) >> 2) | (opcode10 & 03);
2609 CPTUR (cptUsePRn + n);
2610 cpu.PR[n].RNR = cpu.TPR.TRR;
2611 cpu.PR[n].SNR = cpu.TPR.TSR;
2612 cpu.PR[n].WORDNO = cpu.TPR.CA;
2613 SET_PR_BITNO (n, cpu.TPR.TBR);
2614 #ifdef TESTING
2615 HDBGRegPRW (n, "epp");
2616 #endif
2617 }
2618 break;
2619
2620 case x0 (0250):
2621 case x1 (0251):
2622 case x0 (0252):
2623 case x1 (0253):
2624 case x0 (0650):
2625 case x1 (0651):
2626 case x0 (0652):
2627 case x1 (0653):
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639 {
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649 uint n = ((opcode10 & 0400) >> 6) | (opcode10 & 03);
2650 CPTUR (cptUsePRn + n);
2651 #ifdef TESTING
2652 HDBGRegPRR (n, "spri");
2653 #endif
2654 cpu.Ypair[0] = 043;
2655 cpu.Ypair[0] |= ((word36) cpu.PR[n].SNR) << 18;
2656 cpu.Ypair[0] |= ((word36) cpu.PR[n].RNR) << 15;
2657
2658 cpu.Ypair[1] = (word36) cpu.PR[n].WORDNO << 18;
2659 cpu.Ypair[1] |= (word36) GET_PR_BITNO (n) << 9;
2660 }
2661 break;
2662
2663 case x0 (0235):
2664 cpu.rA = cpu.CY;
2665 #ifdef TESTING
2666 HDBGRegAW ("lda");
2667 #endif
2668 SC_I_ZERO (cpu.rA == 0);
2669 SC_I_NEG (cpu.rA & SIGN36);
2670 break;
2671
2672 case x0 (0710):
2673
2674
2675 do_caf ();
2676 read_tra_op ();
2677 return CONT_TRA;
2678
2679 case x0 (0236):
2680 cpu.rQ = cpu.CY;
2681 #ifdef TESTING
2682 HDBGRegQW ("ldq");
2683 #endif
2684 SC_I_ZERO (cpu.rQ == 0);
2685 SC_I_NEG (cpu.rQ & SIGN36);
2686 break;
2687
2688 case x0 (0600):
2689
2690
2691
2692
2693 if (TST_I_ZERO)
2694 {
2695 do_caf ();
2696 read_tra_op ();
2697 return CONT_TRA;
2698 }
2699 break;
2700
2701 case x0 (0601):
2702
2703
2704
2705 if (!TST_I_ZERO)
2706 {
2707 do_caf ();
2708 read_tra_op ();
2709 return CONT_TRA;
2710 }
2711 break;
2712
2713 case x0 (0756):
2714 cpu.CY = cpu.rQ;
2715 #ifdef TESTING
2716 HDBGRegQR ("stq");
2717 #endif
2718 break;
2719
2720 case x0 (0116):
2721
2722 cmp36 (cpu.rQ, cpu.CY, &cpu.cu.IR);
2723 #ifdef TESTING
2724 HDBGRegQR ("cmpq");
2725 #endif
2726 break;
2727
2728 case x0 (0377):
2729
2730 {
2731 word72 tmp72 = YPAIRTO72 (cpu.Ypair);
2732 word72 trAQ = convert_to_word72 (cpu.rA, cpu.rQ);
2733 #ifdef TESTING
2734 HDBGRegAR ("anaq");
2735 HDBGRegQR ("anaq");
2736 #endif
2737 #ifdef NEED_128
2738 trAQ = and_128 (trAQ, tmp72);
2739 trAQ = and_128 (trAQ, MASK72);
2740
2741 SC_I_ZERO (iszero_128 (trAQ));
2742 SC_I_NEG (isnonzero_128 (and_128 (trAQ, SIGN72)));
2743 #else
2744 trAQ = trAQ & tmp72;
2745 trAQ &= MASK72;
2746
2747 SC_I_ZERO (trAQ == 0);
2748 SC_I_NEG (trAQ & SIGN72);
2749 #endif
2750 convert_to_word36 (trAQ, &cpu.rA, &cpu.rQ);
2751 #ifdef TESTING
2752 HDBGRegAW ("anaq");
2753 HDBGRegQW ("anaq");
2754 #endif
2755 }
2756 break;
2757
2758 case x0 (0755):
2759 cpu.CY = cpu.rA;
2760 #ifdef TESTING
2761 HDBGRegAR ("sta");
2762 #endif
2763 break;
2764
2765
2766 case x0 (0760):
2767 case x0 (0761):
2768 case x0 (0762):
2769 case x0 (0763):
2770 case x0 (0764):
2771 case x0 (0765):
2772 case x0 (0766):
2773 case x0 (0767):
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785 {
2786 uint32 n = opcode10 & 07;
2787 CPTUR (cptUsePRn + n);
2788 cpu.PR[n].RNR = cpu.TPR.TRR;
2789
2790
2791
2792
2793
2794 if (((cpu.CY >> 34) & 3) != 3)
2795 {
2796 word6 bitno = (cpu.CY >> 30) & 077;
2797 SET_PR_BITNO (n, bitno);
2798 }
2799 else
2800 {
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817 doFault (FAULT_CMD, fst_cmd_lprpn, "lprpn");
2818 }
2819
2820
2821
2822
2823
2824
2825 word12 oSNR = getbits36_12 (cpu.CY, 6);
2826
2827 if (oSNR == 07777)
2828 cpu.PR[n].SNR = 077777;
2829 else
2830 cpu.PR[n].SNR = oSNR;
2831
2832 cpu.PR[n].WORDNO = GETLO (cpu.CY);
2833
2834 sim_debug (DBG_APPENDING, & cpu_dev,
2835 "lprp%d CY 0%012"PRIo64", PR[n].RNR 0%o, "
2836 "PR[n].BITNO 0%o, PR[n].SNR 0%o, PR[n].WORDNO %o\n",
2837 n, cpu.CY, cpu.PR[n].RNR, GET_PR_BITNO (n),
2838 cpu.PR[n].SNR, cpu.PR[n].WORDNO);
2839 #ifdef TESTING
2840 HDBGRegPRW (n, "lprp");
2841 #endif
2842 }
2843 break;
2844
2845
2846 case x0 (0620):
2847 case x0 (0621):
2848 case x0 (0622):
2849 case x0 (0623):
2850 case x0 (0624):
2851 case x0 (0625):
2852 case x0 (0626):
2853 case x0 (0627):
2854 {
2855 uint32 n = opcode10 & 07;
2856 cpu.rX[n] = cpu.TPR.CA;
2857 #ifdef TESTING
2858 HDBGRegXW (n, "eaxn");
2859 #endif
2860
2861 SC_I_ZERO (cpu.TPR.CA == 0);
2862 SC_I_NEG (cpu.TPR.CA & SIGN18);
2863
2864 }
2865 break;
2866
2867
2868 case x0 (0700):
2869 case x0 (0701):
2870 case x0 (0702):
2871 case x0 (0703):
2872 case x0 (0704):
2873 case x0 (0705):
2874 case x0 (0706):
2875 case x0 (0707):
2876
2877
2878
2879
2880 {
2881
2882 word18 ret = (cpu.PPR.IC + 1) & MASK18;
2883 do_caf ();
2884 read_tra_op ();
2885 cpu.rX[opcode10 & 07] = ret;
2886 #ifdef TESTING
2887 HDBGRegXW (opcode10 & 07, "tsxn");
2888 #endif
2889 }
2890 return CONT_TRA;
2891
2892 case x0 (0450):
2893 cpu.CY = 0;
2894 break;
2895
2896
2897 case x1 (0350):
2898 case x0 (0351):
2899 case x1 (0352):
2900 case x0 (0353):
2901 case x1 (0370):
2902 case x0 (0371):
2903 case x1 (0372):
2904 case x0 (0373):
2905
2906
2907
2908
2909
2910 {
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920 uint n = ((opcode10 & 020) >> 2) | (opcode10 & 03);
2921 CPTUR (cptUsePRn + n);
2922 cpu.PR[n].RNR = cpu.TPR.TRR;
2923 cpu.PR[n].SNR = cpu.TPR.TSR;
2924 cpu.PR[n].WORDNO = 0;
2925 SET_PR_BITNO (n, 0);
2926 #ifdef TESTING
2927 HDBGRegPRW (n, "epbp");
2928 #endif
2929 }
2930 break;
2931
2932 case x0 (0115):
2933
2934 cmp36 (cpu.rA, cpu.CY, &cpu.cu.IR);
2935 #ifdef TESTING
2936 HDBGRegAR ("cmpa");
2937 #endif
2938 break;
2939
2940 case x0 (0054):
2941 {
2942
2943
2944 L68_ (cpu.ou.cycle |= ou_GOS;)
2945 bool ovf;
2946 cpu.CY = Add36b (cpu.CY, 1, 0, I_ZNOC,
2947 & cpu.cu.IR, & ovf);
2948 overflow (ovf, true, "aos overflow fault");
2949 }
2950 break;
2951
2952 case x0 (0315):
2953
2954 {
2955 #ifdef TESTING
2956 HDBGRegAR ("cana");
2957 #endif
2958 word36 trZ = cpu.rA & cpu.CY;
2959 trZ &= MASK36;
2960
2961 SC_I_ZERO (trZ == 0);
2962 SC_I_NEG (trZ & SIGN36);
2963 }
2964 break;
2965
2966 case x0 (0237):
2967 cpu.rA = cpu.Ypair[0];
2968 #ifdef TESTING
2969 HDBGRegAW ("ldaq");
2970 #endif
2971 cpu.rQ = cpu.Ypair[1];
2972 #ifdef TESTING
2973 HDBGRegQW ("ldaq");
2974 #endif
2975 SC_I_ZERO (cpu.rA == 0 && cpu.rQ == 0)
2976 SC_I_NEG (cpu.rA & SIGN36);
2977 break;
2978
2979 case x1 (0605):
2980
2981
2982
2983 if (! (cpu.cu.IR & I_NEG) && ! (cpu.cu.IR & I_ZERO))
2984 {
2985 do_caf ();
2986 read_tra_op ();
2987 return CONT_TRA;
2988 }
2989 break;
2990
2991
2992 case x0 (0720):
2993 case x0 (0721):
2994 case x0 (0722):
2995 case x0 (0723):
2996 case x0 (0724):
2997 case x0 (0725):
2998 case x0 (0726):
2999 case x0 (0727):
3000 {
3001 uint32 n = opcode10 & 07;
3002 cpu.rX[n] = GETLO (cpu.CY);
3003 #ifdef TESTING
3004 HDBGRegXW (n, "lxln");
3005 #endif
3006 SC_I_ZERO (cpu.rX[n] == 0);
3007 SC_I_NEG (cpu.rX[n] & SIGN18);
3008 }
3009 break;
3010
3011 case x0 (0757):
3012 cpu.Ypair[0] = cpu.rA;
3013 cpu.Ypair[1] = cpu.rQ;
3014 break;
3015
3016
3017 case x0 (0270):
3018 case x0 (0271):
3019 case x0 (0272):
3020 case x0 (0273):
3021 case x0 (0670):
3022 case x0 (0671):
3023 case x0 (0672):
3024 case x0 (0673):
3025
3026
3027
3028
3029
3030
3031
3032 {
3033 #ifdef PANEL68
3034 uint32 n;
3035 if (opcode10 <= 0273)
3036 n = (opcode10 & 3);
3037 else
3038 n = (opcode10 & 3) + 4;
3039 CPTUR (cptUsePRn + n);
3040 #endif
3041
3042 do_caf ();
3043
3044 read_tra_op ();
3045 }
3046 return CONT_TRA;
3047
3048 case x0 (0735):
3049 {
3050 #ifdef TESTING
3051 HDBGRegAR ("als");
3052 #endif
3053 word36 tmp36 = cpu.TPR.CA & 0177;
3054
3055 word36 tmpSign = cpu.rA & SIGN36;
3056 CLR_I_CARRY;
3057
3058 for (uint j = 0; j < tmp36; j ++)
3059 {
3060 cpu.rA <<= 1;
3061 if (tmpSign != (cpu.rA & SIGN36))
3062 SET_I_CARRY;
3063 }
3064 cpu.rA &= DMASK;
3065 #ifdef TESTING
3066 HDBGRegAW ("als");
3067 #endif
3068
3069 SC_I_ZERO (cpu.rA == 0);
3070 SC_I_NEG (cpu.rA & SIGN36);
3071 }
3072 break;
3073
3074 case x0 (0610):
3075
3076
3077
3078 do_caf ();
3079 Read2 (cpu.TPR.CA, cpu.Ypair, RTCD_OPERAND_FETCH);
3080
3081 set_addr_mode (APPEND_mode);
3082
3083 return CONT_RET;
3084
3085 case x0 (0604):
3086
3087
3088
3089 if (TST_I_NEG)
3090 {
3091 do_caf ();
3092 read_tra_op ();
3093 return CONT_TRA;
3094 }
3095 break;
3096
3097
3098 case x0 (0740):
3099 case x0 (0741):
3100 case x0 (0742):
3101 case x0 (0743):
3102 case x0 (0744):
3103 case x0 (0745):
3104 case x0 (0746):
3105 case x0 (0747):
3106 {
3107 uint32 n = opcode10 & 07;
3108
3109 cpu.CY = ((word36) cpu.rX[n]) << 18;
3110 cpu.zone = 0777777000000;
3111 cpu.useZone = true;
3112 }
3113 break;
3114
3115 case x0 (0634):
3116 {
3117 CPTUR (cptUseIR);
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140 word18 tmp18;
3141 if (cpu.tweaks.l68_mode)
3142 tmp18 = GETLO (cpu.CY) & 0777760;
3143 else
3144 tmp18 = GETLO (cpu.CY) & 0777770;
3145
3146 bool bAbsPriv = is_priv_mode ();
3147
3148 SC_I_ZERO (tmp18 & I_ZERO);
3149 SC_I_NEG (tmp18 & I_NEG);
3150 SC_I_CARRY (tmp18 & I_CARRY);
3151 SC_I_OFLOW (tmp18 & I_OFLOW);
3152 SC_I_EOFL (tmp18 & I_EOFL);
3153 SC_I_EUFL (tmp18 & I_EUFL);
3154 SC_I_OMASK (tmp18 & I_OMASK);
3155 SC_I_TALLY (tmp18 & I_TALLY);
3156 SC_I_PERR (tmp18 & I_PERR);
3157
3158
3159 SC_I_TRUNC (tmp18 & I_TRUNC);
3160
3161
3162 DPS8M_ (SC_I_HEX (tmp18 & I_HEX);)
3163
3164 if (bAbsPriv)
3165 {
3166 SC_I_PMASK (tmp18 & I_PMASK);
3167 SC_I_MIF (tmp18 & I_MIF);
3168 }
3169 else
3170 {
3171 CLR_I_PMASK;
3172 CLR_I_MIF;
3173 }
3174 }
3175 break;
3176
3177 case x0 (0677):
3178
3179 {
3180 #ifdef TESTING
3181 HDBGRegAR ("eraq");
3182 HDBGRegQR ("eraq");
3183 #endif
3184 word72 tmp72 = YPAIRTO72 (cpu.Ypair);
3185 word72 trAQ = convert_to_word72 (cpu.rA, cpu.rQ);
3186 #ifdef NEED_128
3187 trAQ = xor_128 (trAQ, tmp72);
3188 trAQ = and_128 (trAQ, MASK72);
3189
3190 SC_I_ZERO (iszero_128 (trAQ));
3191 SC_I_NEG (isnonzero_128 (and_128 (trAQ, SIGN72)));
3192 #else
3193 trAQ = trAQ ^ tmp72;
3194 trAQ &= MASK72;
3195
3196 SC_I_ZERO (trAQ == 0);
3197 SC_I_NEG (trAQ & SIGN72);
3198 #endif
3199
3200 convert_to_word36 (trAQ, &cpu.rA, &cpu.rQ);
3201 #ifdef TESTING
3202 HDBGRegAW ("eraq");
3203 HDBGRegQW ("eraq");
3204 #endif
3205 }
3206 break;
3207
3208 case x0 (0275):
3209
3210 #ifdef TESTING
3211 HDBGRegAR ("ora");
3212 #endif
3213 cpu.rA = cpu.rA | cpu.CY;
3214 cpu.rA &= DMASK;
3215 #ifdef TESTING
3216 HDBGRegAW ("ora");
3217 #endif
3218
3219 SC_I_ZERO (cpu.rA == 0);
3220 SC_I_NEG (cpu.rA & SIGN36);
3221 break;
3222
3223 case x0 (0076):
3224 {
3225 L68_ (cpu.ou.cycle |= ou_GOS;)
3226 bool ovf;
3227 #ifdef TESTING
3228 HDBGRegQR ("adq");
3229 #endif
3230 cpu.rQ = Add36b (cpu.rQ, cpu.CY, 0, I_ZNOC,
3231 & cpu.cu.IR, & ovf);
3232 #ifdef TESTING
3233 HDBGRegQW ("adq");
3234 #endif
3235 overflow (ovf, false, "adq overflow fault");
3236 }
3237 break;
3238
3239 case x1 (0604):
3240
3241
3242
3243 if (cpu.cu.IR & (I_NEG | I_ZERO))
3244 {
3245 do_caf ();
3246 read_tra_op ();
3247 return CONT_TRA;
3248 }
3249 break;
3250
3251 case x1 (0250):
3252 case x0 (0251):
3253 case x1 (0252):
3254 case x0 (0253):
3255 case x1 (0650):
3256 case x0 (0651):
3257 case x1 (0652):
3258 case x0 (0653):
3259
3260
3261
3262
3263
3264
3265
3266 {
3267
3268
3269
3270
3271
3272
3273
3274
3275 uint n = ((opcode10 & 0400) >> 6) | (opcode10 & 03);
3276 CPTUR (cptUsePRn + n);
3277 cpu.Ypair[0] = 043;
3278 cpu.Ypair[0] |= ((word36) cpu.PR[n].SNR) << 18;
3279 cpu.Ypair[0] |= ((word36) cpu.PR[n].RNR) << 15;
3280 cpu.Ypair[1] = 0;
3281 }
3282 break;
3283
3284 case x0 (0375):
3285
3286 #ifdef TESTING
3287 HDBGRegAR ("ana");
3288 #endif
3289 cpu.rA = cpu.rA & cpu.CY;
3290 cpu.rA &= DMASK;
3291 #ifdef TESTING
3292 HDBGRegAW ("ana");
3293 #endif
3294 SC_I_ZERO (cpu.rA == 0);
3295 SC_I_NEG (cpu.rA & SIGN36);
3296 break;
3297
3298 case x0 (0431):
3299
3300
3301
3302
3303
3304
3305 CPTUR (cptUseE);
3306 cpu.CY &= DMASK;
3307 cpu.rE = (cpu.CY >> 28) & 0377;
3308 cpu.rA = (cpu.CY & FLOAT36MASK) << 8;
3309 #ifdef TESTING
3310 HDBGRegAW ("fld");
3311 #endif
3312 cpu.rQ = 0;
3313 #ifdef TESTING
3314 HDBGRegQW ("fld");
3315 #endif
3316
3317 SC_I_ZERO (cpu.rA == 0 && cpu.rQ == 0);
3318 SC_I_NEG (cpu.rA & SIGN36);
3319 break;
3320
3321 case x0 (0213):
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331 cpu.rA = cpu.TPR.TRR & MASK3;
3332 cpu.rA |= (word36) (cpu.TPR.TSR & MASK15) << 18;
3333 #ifdef TESTING
3334 HDBGRegAW ("epaq");
3335 #endif
3336
3337 cpu.rQ = cpu.TPR.TBR & MASK6;
3338 cpu.rQ |= (word36) (cpu.TPR.CA & MASK18) << 18;
3339 #ifdef TESTING
3340 HDBGRegQW ("epaq");
3341 #endif
3342
3343 SC_I_ZERO (cpu.rA == 0 && cpu.rQ == 0);
3344
3345 break;
3346
3347 case x0 (0736):
3348
3349
3350 {
3351 #ifdef TESTING
3352 HDBGRegQR ("qls");
3353 #endif
3354 word36 tmp36 = cpu.TPR.CA & 0177;
3355 word36 tmpSign = cpu.rQ & SIGN36;
3356 CLR_I_CARRY;
3357
3358 for (uint j = 0; j < tmp36; j ++)
3359 {
3360 cpu.rQ <<= 1;
3361 if (tmpSign != (cpu.rQ & SIGN36))
3362 SET_I_CARRY;
3363 }
3364 cpu.rQ &= DMASK;
3365 #ifdef TESTING
3366 HDBGRegQW ("qls");
3367 #endif
3368
3369 SC_I_ZERO (cpu.rQ == 0);
3370 SC_I_NEG (cpu.rQ & SIGN36);
3371 }
3372 break;
3373
3374 case x0 (0754):
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385 CPTUR (cptUseIR);
3386
3387
3388
3389
3390 DPS8M_ (cpu.CY = cpu.cu.IR & 0000000777770LL; )
3391
3392 L68_ (cpu.CY = cpu.cu.IR & 0000000777760LL;)
3393
3394 if (cpu.switches.procMode == procModeGCOS)
3395 cpu.CY = cpu.cu.IR & 0000000777600LL;
3396 cpu.zone = 0000000777777;
3397 cpu.useZone = true;
3398 SCF (i->stiTally, cpu.CY, I_TALLY);
3399 break;
3400
3401
3402
3403
3404
3405 case x0 (0635):
3406 cpu.rA = 0;
3407 SETHI (cpu.rA, cpu.TPR.CA);
3408 #ifdef TESTING
3409 HDBGRegAW ("eea");
3410 #endif
3411 SC_I_ZERO (cpu.TPR.CA == 0);
3412 SC_I_NEG (cpu.TPR.CA & SIGN18);
3413
3414 break;
3415
3416 case x0 (0636):
3417 cpu.rQ = 0;
3418 SETHI (cpu.rQ, cpu.TPR.CA);
3419 #ifdef TESTING
3420 HDBGRegQW ("eaq");
3421 #endif
3422
3423 SC_I_ZERO (cpu.TPR.CA == 0);
3424 SC_I_NEG (cpu.TPR.CA & SIGN18);
3425
3426 break;
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438 case x0 (0335):
3439 {
3440 bool ovf;
3441 cpu.rA = compl36 (cpu.CY, & cpu.cu.IR, & ovf);
3442 #ifdef TESTING
3443 HDBGRegAW ("lca");
3444 #endif
3445 overflow (ovf, false, "lca overflow fault");
3446 }
3447 break;
3448
3449 case x0 (0336):
3450 {
3451 bool ovf;
3452 cpu.rQ = compl36 (cpu.CY, & cpu.cu.IR, & ovf);
3453 #ifdef TESTING
3454 HDBGRegQW ("lcq");
3455 #endif
3456 overflow (ovf, false, "lcq overflow fault");
3457 }
3458 break;
3459
3460
3461 case x0 (0320):
3462 case x0 (0321):
3463 case x0 (0322):
3464 case x0 (0323):
3465 case x0 (0324):
3466 case x0 (0325):
3467 case x0 (0326):
3468 case x0 (0327):
3469 {
3470 bool ovf;
3471 uint32 n = opcode10 & 07;
3472 cpu.rX[n] = compl18 (GETHI (cpu.CY), & cpu.cu.IR, & ovf);
3473 #ifdef TESTING
3474 HDBGRegXW (n, "lcxn");
3475 #endif
3476 overflow (ovf, false, "lcxn overflow fault");
3477 }
3478 break;
3479
3480 case x0 (0337):
3481 {
3482
3483
3484
3485
3486
3487
3488 if (cpu.Ypair[0] == 0400000000000LL && cpu.Ypair[1] == 0)
3489 {
3490 cpu.rA = cpu.Ypair[0];
3491 #ifdef TESTING
3492 HDBGRegAW ("lcaq");
3493 #endif
3494 cpu.rQ = cpu.Ypair[1];
3495 #ifdef TESTING
3496 HDBGRegQW ("lcaq");
3497 #endif
3498 SET_I_NEG;
3499 CLR_I_ZERO;
3500 overflow (true, false, "lcaq overflow fault");
3501 }
3502 else if (cpu.Ypair[0] == 0 && cpu.Ypair[1] == 0)
3503 {
3504 cpu.rA = 0;
3505 #ifdef TESTING
3506 HDBGRegAW ("lcaq");
3507 #endif
3508 cpu.rQ = 0;
3509 #ifdef TESTING
3510 HDBGRegQW ("lcaq");
3511 #endif
3512
3513 SET_I_ZERO;
3514 CLR_I_NEG;
3515 }
3516 else
3517 {
3518 word72 tmp72 = convert_to_word72 (cpu.Ypair[0], cpu.Ypair[1]);
3519 #ifdef NEED_128
3520 tmp72 = negate_128 (tmp72);
3521 #else
3522 tmp72 = ~tmp72 + 1;
3523 #endif
3524 convert_to_word36 (tmp72, & cpu.rA, & cpu.rQ);
3525 #ifdef TESTING
3526 HDBGRegAW ("lcaq");
3527 HDBGRegQW ("lcaq");
3528 #endif
3529
3530 SC_I_ZERO (cpu.rA == 0 && cpu.rQ == 0);
3531 SC_I_NEG (cpu.rA & SIGN36);
3532 }
3533 }
3534 break;
3535
3536
3537
3538
3539 case x0 (0034):
3540 cpu.rA = cpu.CY;
3541 #ifdef TESTING
3542 HDBGRegAW ("ldac");
3543 #endif
3544 SC_I_ZERO (cpu.rA == 0);
3545 SC_I_NEG (cpu.rA & SIGN36);
3546 cpu.CY = 0;
3547 break;
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558 case x0 (0032):
3559 cpu.rQ = cpu.CY;
3560 #ifdef TESTING
3561 HDBGRegQW ("ldqc");
3562 #endif
3563 SC_I_ZERO (cpu.rQ == 0);
3564 SC_I_NEG (cpu.rQ & SIGN36);
3565 cpu.CY = 0;
3566 break;
3567
3568
3569 case x0 (0220):
3570 case x0 (0221):
3571 case x0 (0222):
3572 case x0 (0223):
3573 case x0 (0224):
3574 case x0 (0225):
3575 case x0 (0226):
3576 case x0 (0227):
3577 {
3578 uint32 n = opcode10 & 07;
3579 cpu.rX[n] = GETHI (cpu.CY);
3580 #ifdef TESTING
3581 HDBGRegXW (n, "ldxn");
3582 #endif
3583 SC_I_ZERO (cpu.rX[n] == 0);
3584 SC_I_NEG (cpu.rX[n] & SIGN18);
3585 }
3586 break;
3587
3588 case x0 (0073):
3589 CPTUR (cptUseE);
3590 L68_ (cpu.ou.cycle |= ou_GOS;)
3591 L68_ (cpu.ou.eac = 0;)
3592 cpu.rX[0] = GETHI (cpu.Yblock8[0]);
3593 #ifdef TESTING
3594 HDBGRegXW (0, "lreg");
3595 #endif
3596 cpu.rX[1] = GETLO (cpu.Yblock8[0]);
3597 #ifdef TESTING
3598 HDBGRegXW (1, "lreg");
3599 #endif
3600 L68_ (cpu.ou.eac ++;)
3601 cpu.rX[2] = GETHI (cpu.Yblock8[1]);
3602 #ifdef TESTING
3603 HDBGRegXW (2, "lreg");
3604 #endif
3605 cpu.rX[3] = GETLO (cpu.Yblock8[1]);
3606 #ifdef TESTING
3607 HDBGRegXW (3, "lreg");
3608 #endif
3609 L68_ (cpu.ou.eac ++;)
3610 cpu.rX[4] = GETHI (cpu.Yblock8[2]);
3611 #ifdef TESTING
3612 HDBGRegXW (4, "lreg");
3613 #endif
3614 cpu.rX[5] = GETLO (cpu.Yblock8[2]);
3615 #ifdef TESTING
3616 HDBGRegXW (5, "lreg");
3617 #endif
3618 L68_ (cpu.ou.eac ++;)
3619 cpu.rX[6] = GETHI (cpu.Yblock8[3]);
3620 #ifdef TESTING
3621 HDBGRegXW (6, "lreg");
3622 #endif
3623 cpu.rX[7] = GETLO (cpu.Yblock8[3]);
3624 #ifdef TESTING
3625 HDBGRegXW (7, "lreg");
3626 #endif
3627 L68_ (cpu.ou.eac ++;)
3628 cpu.rA = cpu.Yblock8[4];
3629 #ifdef TESTING
3630 HDBGRegAW ("lreg");
3631 #endif
3632 cpu.rQ = cpu.Yblock8[5];
3633 #ifdef TESTING
3634 HDBGRegQW ("lreg");
3635 #endif
3636 cpu.rE = (GETHI (cpu.Yblock8[6]) >> 10) & 0377;
3637 break;
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652 case x0 (0753):
3653 CPTUR (cptUseE);
3654 CPTUR (cptUseRALR);
3655
3656
3657 L68_ (cpu.ou.cycle |= ou_GOS;)
3658 L68_ (cpu.ou.eac = 0;)
3659 SETHI (cpu.Yblock8[0], cpu.rX[0]);
3660 SETLO (cpu.Yblock8[0], cpu.rX[1]);
3661 L68_ (cpu.ou.eac ++;)
3662 SETHI (cpu.Yblock8[1], cpu.rX[2]);
3663 SETLO (cpu.Yblock8[1], cpu.rX[3]);
3664 L68_ (cpu.ou.eac ++;)
3665 SETHI (cpu.Yblock8[2], cpu.rX[4]);
3666 SETLO (cpu.Yblock8[2], cpu.rX[5]);
3667 L68_ (cpu.ou.eac ++;)
3668 SETHI (cpu.Yblock8[3], cpu.rX[6]);
3669 SETLO (cpu.Yblock8[3], cpu.rX[7]);
3670 L68_ (cpu.ou.eac ++;)
3671 cpu.Yblock8[4] = cpu.rA;
3672 cpu.Yblock8[5] = cpu.rQ;
3673 cpu.Yblock8[6] = ((word36)(cpu.rE & MASK8)) << 28;
3674 if (cpu.tweaks.isolts_mode)
3675 cpu.Yblock8[7] = (((-- cpu.shadowTR) & MASK27) << 9) | (cpu.rRALR & 07);
3676 else
3677 cpu.Yblock8[7] = ((cpu.rTR & MASK27) << 9) | (cpu.rRALR & 07);
3678 #ifdef TESTING
3679 HDBGRegXR (0, "sreg");
3680 HDBGRegXR (1, "sreg");
3681 HDBGRegXR (2, "sreg");
3682 HDBGRegXR (3, "sreg");
3683 HDBGRegXR (4, "sreg");
3684 HDBGRegXR (5, "sreg");
3685 HDBGRegXR (6, "sreg");
3686 HDBGRegXR (7, "sreg");
3687 HDBGRegAR ("sreg");
3688 HDBGRegQR ("sreg");
3689 #endif
3690 break;
3691
3692
3693
3694
3695 case x0 (0354):
3696 if (cpu.CY == 0)
3697 {
3698 #ifdef TESTING
3699 HDBGRegAR ("stac");
3700 #endif
3701 SET_I_ZERO;
3702 cpu.CY = cpu.rA;
3703 }
3704 else
3705 CLR_I_ZERO;
3706 break;
3707
3708 case x0 (0654):
3709 #ifdef TESTING
3710 HDBGRegQR ("stacq");
3711 #endif
3712 if (cpu.CY == cpu.rQ)
3713 {
3714 #ifdef TESTING
3715 HDBGRegAR ("stacq");
3716 #endif
3717 cpu.CY = cpu.rA;
3718 SET_I_ZERO;
3719 }
3720 else
3721 CLR_I_ZERO;
3722 break;
3723
3724
3725
3726
3727 case x0 (0551):
3728
3729
3730
3731 #ifdef TESTING
3732 HDBGRegAR ("stba");
3733 #endif
3734 cpu.CY = cpu.rA;
3735 cpu.zone =
3736
3737 ((i->tag & 040) ? 0777000000000u : 0) |
3738 ((i->tag & 020) ? 0000777000000u : 0) |
3739 ((i->tag & 010) ? 0000000777000u : 0) |
3740 ((i->tag & 004) ? 0000000000777u : 0);
3741 cpu.useZone = true;
3742 cpu.ou.crflag = true;
3743 break;
3744
3745 case x0 (0552):
3746
3747
3748
3749 #ifdef TESTING
3750 HDBGRegQR ("stbq");
3751 #endif
3752 cpu.CY = cpu.rQ;
3753 cpu.zone =
3754
3755 ((i->tag & 040) ? 0777000000000u : 0) |
3756 ((i->tag & 020) ? 0000777000000u : 0) |
3757 ((i->tag & 010) ? 0000000777000u : 0) |
3758 ((i->tag & 004) ? 0000000000777u : 0);
3759 cpu.useZone = true;
3760 cpu.ou.crflag = true;
3761 break;
3762
3763 case x0 (0554):
3764
3765
3766 SETHI (cpu.CY, (cpu.PPR.IC + 1) & MASK18);
3767
3768
3769 DPS8M_ (SETLO (cpu.CY, cpu.cu.IR & 0777770);)
3770 L68_ (SETLO (cpu.CY, cpu.cu.IR & 0777760);)
3771 SCF (i->stiTally, cpu.CY, I_TALLY);
3772 break;
3773
3774 case x0 (0750):
3775
3776
3777
3778
3779 cpu.CY = ((word36) ((cpu.PPR.IC + 2) & MASK18)) << 18;
3780 cpu.zone = 0777777000000;
3781 cpu.useZone = true;
3782 break;
3783
3784 case x0 (0751):
3785
3786
3787
3788
3789 #ifdef TESTING
3790 HDBGRegAR ("stca");
3791 #endif
3792 cpu.CY = cpu.rA;
3793 cpu.zone =
3794
3795 ((i->tag & 040) ? 0770000000000u : 0) |
3796 ((i->tag & 020) ? 0007700000000u : 0) |
3797 ((i->tag & 010) ? 0000077000000u : 0) |
3798 ((i->tag & 004) ? 0000000770000u : 0) |
3799 ((i->tag & 002) ? 0000000007700u : 0) |
3800 ((i->tag & 001) ? 0000000000077u : 0);
3801 cpu.useZone = true;
3802 cpu.ou.crflag = true;
3803 break;
3804
3805 case x0 (0752):
3806
3807
3808
3809 #ifdef TESTING
3810 HDBGRegQR ("stcq");
3811 #endif
3812 cpu.CY = cpu.rQ;
3813 cpu.zone =
3814
3815 ((i->tag & 040) ? 0770000000000u : 0) |
3816 ((i->tag & 020) ? 0007700000000u : 0) |
3817 ((i->tag & 010) ? 0000077000000u : 0) |
3818 ((i->tag & 004) ? 0000000770000u : 0) |
3819 ((i->tag & 002) ? 0000000007700u : 0) |
3820 ((i->tag & 001) ? 0000000000077u : 0);
3821 cpu.useZone = true;
3822 cpu.ou.crflag = true;
3823 break;
3824
3825 case x0 (0357):
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842 if (cpu.cycle == EXEC_cycle)
3843 {
3844 cpu.Ypair[0] = 0;
3845 putbits36_15 (& cpu.Ypair[0], 3, cpu.PPR.PSR);
3846 putbits36_3 (& cpu.Ypair[0], 18, cpu.PPR.PRR);
3847 putbits36_6 (& cpu.Ypair[0], 30, 043);
3848
3849 cpu.Ypair[1] = 0;
3850 putbits36_18 (& cpu.Ypair[1], 0, cpu.PPR.IC + 2);
3851 }
3852 else
3853 {
3854 cpu.Ypair[0] = 0;
3855 putbits36_15 (& cpu.Ypair[0], 3, cpu.cu_data.PSR);
3856 putbits36_3 (& cpu.Ypair[0], 18, cpu.cu_data.PRR);
3857
3858
3859 cpu.Ypair[1] = 0;
3860 putbits36_18 (& cpu.Ypair[1], 0, cpu.cu_data.IC + 2);
3861 }
3862 break;
3863
3864
3865
3866
3867
3868
3869
3870 case x0 (0454):
3871 CPTUR (cptUseTR);
3872 if (cpu.tweaks.isolts_mode)
3873
3874
3875 cpu.CY = (((uint) (((int) cpu.shadowTR) - 1)) & MASK27) << 9;
3876 else
3877 cpu.CY = (cpu.rTR & MASK27) << 9;
3878 break;
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895 case x0 (0440):
3896 case x0 (0441):
3897 case x0 (0442):
3898 case x0 (0443):
3899 case x0 (0444):
3900 case x0 (0445):
3901 case x0 (0446):
3902 case x0 (0447):
3903
3904 cpu.CY = cpu.rX[opcode10 & 07];
3905 cpu.zone = 0000000777777;
3906 cpu.useZone = true;
3907 break;
3908
3909
3910
3911 case x0 (0775):
3912 {
3913 #ifdef TESTING
3914 HDBGRegAR ("alr");
3915 #endif
3916 word36 tmp36 = cpu.TPR.CA & 0177;
3917 for (uint j = 0 ; j < tmp36 ; j++)
3918 {
3919 bool a0 = cpu.rA & SIGN36;
3920 cpu.rA <<= 1;
3921 if (a0)
3922 cpu.rA |= 1;
3923 }
3924 cpu.rA &= DMASK;
3925 #ifdef TESTING
3926 HDBGRegAW ("alr");
3927 #endif
3928
3929 SC_I_ZERO (cpu.rA == 0);
3930 SC_I_NEG (cpu.rA & SIGN36);
3931 }
3932 break;
3933
3934
3935
3936
3937 case x0 (0771):
3938
3939
3940 {
3941 #ifdef TESTING
3942 HDBGRegAR ("arl");
3943 #endif
3944 cpu.rA &= DMASK;
3945 word36 tmp36 = cpu.TPR.CA & 0177;
3946
3947 cpu.rA >>= tmp36;
3948 cpu.rA &= DMASK;
3949 #ifdef TESTING
3950 HDBGRegAW ("arl");
3951 #endif
3952
3953 SC_I_ZERO (cpu.rA == 0);
3954 SC_I_NEG (cpu.rA & SIGN36);
3955 }
3956 break;
3957
3958 case x0 (0731):
3959 {
3960
3961
3962
3963 #ifdef TESTING
3964 HDBGRegAR ("ars");
3965 #endif
3966 cpu.rA &= DMASK;
3967 word18 tmp18 = cpu.TPR.CA & 0177;
3968
3969 bool a0 = cpu.rA & SIGN36;
3970 for (uint j = 0 ; j < tmp18 ; j ++)
3971 {
3972 cpu.rA >>= 1;
3973 if (a0)
3974 cpu.rA |= SIGN36;
3975 }
3976 cpu.rA &= DMASK;
3977 #ifdef TESTING
3978 HDBGRegAW ("ars");
3979 #endif
3980
3981 SC_I_ZERO (cpu.rA == 0);
3982 SC_I_NEG (cpu.rA & SIGN36);
3983 }
3984 break;
3985
3986 case x0 (0777):
3987
3988
3989
3990 {
3991 #ifdef TESTING
3992 HDBGRegAR ("llr");
3993 HDBGRegQR ("llr");
3994 #endif
3995 word36 tmp36 = cpu.TPR.CA & 0177;
3996 for (uint j = 0 ; j < tmp36 ; j++)
3997 {
3998 bool a0 = cpu.rA & SIGN36;
3999
4000 cpu.rA <<= 1;
4001
4002 bool b0 = cpu.rQ & SIGN36;
4003 if (b0)
4004 cpu.rA |= 1;
4005
4006 cpu.rQ <<= 1;
4007
4008 if (a0)
4009 cpu.rQ |= 1;
4010 }
4011
4012 cpu.rA &= DMASK;
4013 cpu.rQ &= DMASK;
4014 #ifdef TESTING
4015 HDBGRegAW ("llr");
4016 HDBGRegQW ("llr");
4017 #endif
4018
4019 SC_I_ZERO (cpu.rA == 0 && cpu.rQ == 0);
4020 SC_I_NEG (cpu.rA & SIGN36);
4021 }
4022 break;
4023
4024 case x0 (0737):
4025 {
4026
4027
4028
4029 CLR_I_CARRY;
4030
4031 #ifdef TESTING
4032 HDBGRegAR ("lls");
4033 HDBGRegQR ("lls");
4034 #endif
4035 word36 tmp36 = cpu.TPR.CA & 0177;
4036 word36 tmpSign = cpu.rA & SIGN36;
4037 for (uint j = 0 ; j < tmp36 ; j ++)
4038 {
4039 cpu.rA <<= 1;
4040
4041 if (tmpSign != (cpu.rA & SIGN36))
4042 SET_I_CARRY;
4043
4044 bool b0 = cpu.rQ & SIGN36;
4045 if (b0)
4046 cpu.rA |= 1;
4047
4048 cpu.rQ <<= 1;
4049 }
4050
4051 cpu.rA &= DMASK;
4052 cpu.rQ &= DMASK;
4053 #ifdef TESTING
4054 HDBGRegAW ("lls");
4055 HDBGRegQW ("lls");
4056 #endif
4057
4058 SC_I_ZERO (cpu.rA == 0 && cpu.rQ == 0);
4059 SC_I_NEG (cpu.rA & SIGN36);
4060 }
4061 break;
4062
4063 case x0 (0773):
4064
4065
4066 {
4067 #ifdef TESTING
4068 HDBGRegAR ("lrl");
4069 HDBGRegQR ("lrl");
4070 #endif
4071 cpu.rA &= DMASK;
4072 cpu.rQ &= DMASK;
4073 word36 tmp36 = cpu.TPR.CA & 0177;
4074 for (uint j = 0 ; j < tmp36 ; j++)
4075 {
4076 bool a35 = cpu.rA & 1;
4077 cpu.rA >>= 1;
4078
4079 cpu.rQ >>= 1;
4080
4081 if (a35)
4082 cpu.rQ |= SIGN36;
4083 }
4084 cpu.rA &= DMASK;
4085 cpu.rQ &= DMASK;
4086 #ifdef TESTING
4087 HDBGRegAW ("lrl");
4088 HDBGRegQW ("lrl");
4089 #endif
4090
4091 SC_I_ZERO (cpu.rA == 0 && cpu.rQ == 0);
4092 SC_I_NEG (cpu.rA & SIGN36);
4093 }
4094 break;
4095
4096 case x0 (0733):
4097 {
4098
4099
4100
4101 #ifdef TESTING
4102 HDBGRegAR ("lrs");
4103 HDBGRegQR ("lrs");
4104 #endif
4105 word36 tmp36 = cpu.TPR.CA & 0177;
4106 cpu.rA &= DMASK;
4107 cpu.rQ &= DMASK;
4108 bool a0 = cpu.rA & SIGN36;
4109
4110 for (uint j = 0 ; j < tmp36 ; j ++)
4111 {
4112 bool a35 = cpu.rA & 1;
4113
4114 cpu.rA >>= 1;
4115 if (a0)
4116 cpu.rA |= SIGN36;
4117
4118 cpu.rQ >>= 1;
4119 if (a35)
4120 cpu.rQ |= SIGN36;
4121 }
4122 cpu.rA &= DMASK;
4123 cpu.rQ &= DMASK;
4124 #ifdef TESTING
4125 HDBGRegAW ("lrs");
4126 HDBGRegQW ("lrs");
4127 #endif
4128
4129 SC_I_ZERO (cpu.rA == 0 && cpu.rQ == 0);
4130 SC_I_NEG (cpu.rA & SIGN36);
4131 }
4132 break;
4133
4134 case x0 (0776):
4135
4136
4137 {
4138 #ifdef TESTING
4139 HDBGRegQR ("qlr");
4140 #endif
4141 word36 tmp36 = cpu.TPR.CA & 0177;
4142 for (uint j = 0 ; j < tmp36 ; j++)
4143 {
4144 bool q0 = cpu.rQ & SIGN36;
4145 cpu.rQ <<= 1;
4146 if (q0)
4147 cpu.rQ |= 1;
4148 }
4149 cpu.rQ &= DMASK;
4150 #ifdef TESTING
4151 HDBGRegQW ("qlr");
4152 #endif
4153
4154 SC_I_ZERO (cpu.rQ == 0);
4155 SC_I_NEG (cpu.rQ & SIGN36);
4156 }
4157 break;
4158
4159
4160
4161
4162 case x0 (0772):
4163
4164
4165 {
4166 #ifdef TESTING
4167 HDBGRegQR ("qrl");
4168 #endif
4169 word36 tmp36 = cpu.TPR.CA & 0177;
4170
4171 cpu.rQ &= DMASK;
4172 cpu.rQ >>= tmp36;
4173 cpu.rQ &= DMASK;
4174 #ifdef TESTING
4175 HDBGRegQW ("qrl");
4176 #endif
4177
4178 SC_I_ZERO (cpu.rQ == 0);
4179 SC_I_NEG (cpu.rQ & SIGN36);
4180
4181 }
4182 break;
4183
4184 case x0 (0732):
4185 {
4186
4187
4188
4189 #ifdef TESTING
4190 HDBGRegQR ("qrs");
4191 #endif
4192 cpu.rQ &= DMASK;
4193 word36 tmp36 = cpu.TPR.CA & 0177;
4194 bool q0 = cpu.rQ & SIGN36;
4195 for (uint j = 0 ; j < tmp36 ; j++)
4196 {
4197 cpu.rQ >>= 1;
4198 if (q0)
4199 cpu.rQ |= SIGN36;
4200 }
4201 cpu.rQ &= DMASK;
4202 #ifdef TESTING
4203 HDBGRegQW ("qrs");
4204 #endif
4205
4206 SC_I_ZERO (cpu.rQ == 0);
4207 SC_I_NEG (cpu.rQ & SIGN36);
4208 }
4209 break;
4210
4211
4212
4213 case x0 (0075):
4214 {
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224 L68_ (cpu.ou.cycle |= ou_GOS;)
4225 #ifdef TESTING
4226 HDBGRegAR ("ada");
4227 #endif
4228 bool ovf;
4229 cpu.rA = Add36b (cpu.rA, cpu.CY, 0, I_ZNOC, & cpu.cu.IR, & ovf);
4230 #ifdef TESTING
4231 HDBGRegAW ("ada");
4232 #endif
4233 overflow (ovf, false, "ada overflow fault");
4234 }
4235 break;
4236
4237 case x0 (0077):
4238 {
4239
4240 L68_ (cpu.ou.cycle |= ou_GOS;)
4241 #ifdef TESTING
4242 HDBGRegAR ("adaq");
4243 HDBGRegQR ("adaq");
4244 #endif
4245 bool ovf;
4246 word72 tmp72 = YPAIRTO72 (cpu.Ypair);
4247 tmp72 = Add72b (convert_to_word72 (cpu.rA, cpu.rQ),
4248 tmp72, 0, I_ZNOC, & cpu.cu.IR, & ovf);
4249 convert_to_word36 (tmp72, & cpu.rA, & cpu.rQ);
4250 #ifdef TESTING
4251 HDBGRegAW ("adaq");
4252 HDBGRegQW ("adaq");
4253 #endif
4254 overflow (ovf, false, "adaq overflow fault");
4255 }
4256 break;
4257
4258 case x0 (0033):
4259 {
4260
4261 L68_ (cpu.ou.cycle |= ou_GOS;)
4262 #ifdef TESTING
4263 HDBGRegAR ("adl");
4264 HDBGRegQR ("adl");
4265 #endif
4266 bool ovf;
4267 word72 tmp72 = SIGNEXT36_72 (cpu.CY);
4268 tmp72 = Add72b (convert_to_word72 (cpu.rA, cpu.rQ),
4269 tmp72, 0, I_ZNOC, & cpu.cu.IR, & ovf);
4270 convert_to_word36 (tmp72, & cpu.rA, & cpu.rQ);
4271 #ifdef TESTING
4272 HDBGRegAW ("adl");
4273 HDBGRegQW ("adl");
4274 #endif
4275 overflow (ovf, false, "adl overflow fault");
4276 }
4277 break;
4278
4279 case x0 (0037):
4280 {
4281
4282
4283
4284
4285 L68_ (cpu.ou.cycle |= ou_GOS;)
4286 #ifdef TESTING
4287 HDBGRegAR ("adlaq");
4288 HDBGRegQR ("adlaq");
4289 #endif
4290 bool ovf;
4291 word72 tmp72 = YPAIRTO72 (cpu.Ypair);
4292
4293 tmp72 = Add72b (convert_to_word72 (cpu.rA, cpu.rQ),
4294 tmp72, 0, I_ZNC, & cpu.cu.IR, & ovf);
4295 convert_to_word36 (tmp72, & cpu.rA, & cpu.rQ);
4296 #ifdef TESTING
4297 HDBGRegAW ("adlaq");
4298 HDBGRegQW ("adlaq");
4299 #endif
4300 }
4301 break;
4302
4303 case x0 (0035):
4304 {
4305 L68_ (cpu.ou.cycle |= ou_GOS;)
4306
4307
4308
4309
4310
4311 #ifdef TESTING
4312 HDBGRegAR ("adla");
4313 #endif
4314 bool ovf;
4315 cpu.rA = Add36b (cpu.rA, cpu.CY, 0, I_ZNC, & cpu.cu.IR, & ovf);
4316 #ifdef TESTING
4317 HDBGRegAW ("adla");
4318 #endif
4319 }
4320 break;
4321
4322 case x0 (0036):
4323 {
4324
4325
4326
4327
4328
4329 L68_ (cpu.ou.cycle |= ou_GOS;)
4330 #ifdef TESTING
4331 HDBGRegQR ("adlq");
4332 #endif
4333 bool ovf;
4334 cpu.rQ = Add36b (cpu.rQ, cpu.CY, 0, I_ZNC, & cpu.cu.IR, & ovf);
4335 #ifdef TESTING
4336 HDBGRegQW ("adlq");
4337 #endif
4338 }
4339 break;
4340
4341
4342 case x0 (0020):
4343 case x0 (0021):
4344 case x0 (0022):
4345 case x0 (0023):
4346 case x0 (0024):
4347 case x0 (0025):
4348 case x0 (0026):
4349 case x0 (0027):
4350 {
4351 L68_ (cpu.ou.cycle |= ou_GOS;)
4352 uint32 n = opcode10 & 07;
4353 #ifdef TESTING
4354 HDBGRegXR (n, "adlxn");
4355 #endif
4356 bool ovf;
4357 cpu.rX[n] = Add18b (cpu.rX[n], GETHI (cpu.CY), 0, I_ZNC,
4358 & cpu.cu.IR, & ovf);
4359 #ifdef TESTING
4360 HDBGRegXW (n, "adlxn");
4361 #endif
4362 }
4363 break;
4364
4365
4366
4367
4368
4369 case x0 (0060):
4370 case x0 (0061):
4371 case x0 (0062):
4372 case x0 (0063):
4373 case x0 (0064):
4374 case x0 (0065):
4375 case x0 (0066):
4376 case x0 (0067):
4377 {
4378 L68_ (cpu.ou.cycle |= ou_GOS;)
4379 uint32 n = opcode10 & 07;
4380 #ifdef TESTING
4381 HDBGRegXR (n, "adxn");
4382 #endif
4383 bool ovf;
4384 cpu.rX[n] = Add18b (cpu.rX[n], GETHI (cpu.CY), 0,
4385 I_ZNOC,
4386 & cpu.cu.IR, & ovf);
4387 #ifdef TESTING
4388 HDBGRegXW (n, "adxn");
4389 #endif
4390 overflow (ovf, false, "adxn overflow fault");
4391 }
4392 break;
4393
4394
4395
4396
4397 case x0 (0055):
4398 {
4399
4400
4401 L68_ (cpu.ou.cycle |= ou_GOS;)
4402 #ifdef TESTING
4403 HDBGRegAR ("asa");
4404 #endif
4405 bool ovf;
4406 cpu.CY = Add36b (cpu.rA, cpu.CY, 0, I_ZNOC,
4407 & cpu.cu.IR, & ovf);
4408 overflow (ovf, true, "asa overflow fault");
4409 }
4410 break;
4411
4412 case x0 (0056):
4413 {
4414
4415 L68_ (cpu.ou.cycle |= ou_GOS;)
4416 #ifdef TESTING
4417 HDBGRegQR ("asa");
4418 #endif
4419 bool ovf;
4420 cpu.CY = Add36b (cpu.rQ, cpu.CY, 0, I_ZNOC, & cpu.cu.IR, & ovf);
4421 overflow (ovf, true, "asq overflow fault");
4422 }
4423 break;
4424
4425
4426 case x0 (0040):
4427 case x0 (0041):
4428 case x0 (0042):
4429 case x0 (0043):
4430 case x0 (0044):
4431 case x0 (0045):
4432 case x0 (0046):
4433 case x0 (0047):
4434 {
4435
4436
4437 L68_ (cpu.ou.cycle |= ou_GOS;)
4438 uint32 n = opcode10 & 07;
4439 #ifdef TESTING
4440 HDBGRegXR (n, "asxn");
4441 #endif
4442 bool ovf;
4443 word18 tmp18 = Add18b (cpu.rX[n], GETHI (cpu.CY), 0,
4444 I_ZNOC, & cpu.cu.IR, & ovf);
4445 SETHI (cpu.CY, tmp18);
4446 overflow (ovf, true, "asxn overflow fault");
4447 }
4448 break;
4449
4450 case x0 (0071):
4451 {
4452
4453
4454
4455 L68_ (cpu.ou.cycle |= ou_GOS;)
4456 #ifdef TESTING
4457 HDBGRegAR ("awca");
4458 #endif
4459 bool ovf;
4460 cpu.rA = Add36b (cpu.rA, cpu.CY, TST_I_CARRY ? 1 : 0,
4461 I_ZNOC, & cpu.cu.IR, & ovf);
4462 #ifdef TESTING
4463 HDBGRegAW ("awca");
4464 #endif
4465 overflow (ovf, false, "awca overflow fault");
4466 }
4467 break;
4468
4469 case x0 (0072):
4470 {
4471
4472
4473
4474 L68_ (cpu.ou.cycle |= ou_GOS;)
4475 #ifdef TESTING
4476 HDBGRegQR ("awcq");
4477 #endif
4478 bool ovf;
4479 cpu.rQ = Add36b (cpu.rQ, cpu.CY, TST_I_CARRY ? 1 : 0,
4480 I_ZNOC, & cpu.cu.IR, & ovf);
4481 #ifdef TESTING
4482 HDBGRegQW ("awcq");
4483 #endif
4484 overflow (ovf, false, "awcq overflow fault");
4485 }
4486 break;
4487
4488
4489
4490 case x0 (0175):
4491 {
4492
4493
4494 L68_ (cpu.ou.cycle |= ou_GOS;)
4495 #ifdef TESTING
4496 HDBGRegAR ("sba");
4497 #endif
4498 bool ovf;
4499 cpu.rA = Sub36b (cpu.rA, cpu.CY, 1, I_ZNOC, & cpu.cu.IR, & ovf);
4500 #ifdef TESTING
4501 HDBGRegAW ("sba");
4502 #endif
4503 overflow (ovf, false, "sba overflow fault");
4504 }
4505 break;
4506
4507 case x0 (0177):
4508 {
4509
4510 L68_ (cpu.ou.cycle |= ou_GOS;)
4511 #ifdef TESTING
4512 HDBGRegAR ("sbaq");
4513 HDBGRegQR ("sbaq");
4514 #endif
4515 bool ovf;
4516 word72 tmp72 = YPAIRTO72 (cpu.Ypair);
4517 tmp72 = Sub72b (convert_to_word72 (cpu.rA, cpu.rQ), tmp72, 1,
4518 I_ZNOC, & cpu.cu.IR,
4519 & ovf);
4520 convert_to_word36 (tmp72, & cpu.rA, & cpu.rQ);
4521 #ifdef TESTING
4522 HDBGRegAW ("sbaq");
4523 HDBGRegQW ("sbaq");
4524 #endif
4525 overflow (ovf, false, "sbaq overflow fault");
4526 }
4527 break;
4528
4529 case x0 (0135):
4530 {
4531
4532
4533 L68_ (cpu.ou.cycle |= ou_GOS;)
4534 #ifdef TESTING
4535 HDBGRegAR ("sbla");
4536 #endif
4537 bool ovf;
4538 cpu.rA = Sub36b (cpu.rA, cpu.CY, 1, I_ZNC, & cpu.cu.IR, & ovf);
4539 #ifdef TESTING
4540 HDBGRegAW ("sbla");
4541 #endif
4542 }
4543 break;
4544
4545 case x0 (0137):
4546 {
4547
4548
4549
4550
4551
4552
4553 L68_ (cpu.ou.cycle |= ou_GOS;)
4554 #ifdef TESTING
4555 HDBGRegAR ("sblaq");
4556 HDBGRegQR ("sblaq");
4557 #endif
4558 bool ovf;
4559 word72 tmp72 = YPAIRTO72 (cpu.Ypair);
4560
4561 tmp72 = Sub72b (convert_to_word72 (cpu.rA, cpu.rQ), tmp72, 1,
4562 I_ZNC, & cpu.cu.IR, & ovf);
4563 convert_to_word36 (tmp72, & cpu.rA, & cpu.rQ);
4564 #ifdef TESTING
4565 HDBGRegAW ("sblaq");
4566 HDBGRegQW ("sblaq");
4567 #endif
4568 }
4569 break;
4570
4571 case x0 (0136):
4572 {
4573
4574 L68_ (cpu.ou.cycle |= ou_GOS;)
4575 #ifdef TESTING
4576 HDBGRegQR ("sblq");
4577 #endif
4578 bool ovf;
4579 cpu.rQ = Sub36b (cpu.rQ, cpu.CY, 1, I_ZNC, & cpu.cu.IR, & ovf);
4580 #ifdef TESTING
4581 HDBGRegQW ("sblq");
4582 #endif
4583 }
4584 break;
4585
4586
4587 case x0 (0120):
4588 case x0 (0121):
4589 case x0 (0122):
4590 case x0 (0123):
4591 case x0 (0124):
4592 case x0 (0125):
4593 case x0 (0126):
4594 case x0 (0127):
4595 {
4596
4597
4598
4599 L68_ (cpu.ou.cycle |= ou_GOS;)
4600 uint32 n = opcode10 & 07;
4601 #ifdef TESTING
4602 HDBGRegXR (n, "sblxn");
4603 #endif
4604 bool ovf;
4605 cpu.rX[n] = Sub18b (cpu.rX[n], GETHI (cpu.CY), 1,
4606 I_ZNC, & cpu.cu.IR, & ovf);
4607 #ifdef TESTING
4608 HDBGRegXW (n, "sblxn");
4609 #endif
4610 }
4611 break;
4612
4613 case x0 (0176):
4614 {
4615
4616 L68_ (cpu.ou.cycle |= ou_GOS;)
4617 #ifdef TESTING
4618 HDBGRegQR ("sbq");
4619 #endif
4620 bool ovf;
4621 cpu.rQ = Sub36b (cpu.rQ, cpu.CY, 1, I_ZNOC, & cpu.cu.IR, & ovf);
4622 #ifdef TESTING
4623 HDBGRegQW ("sbq");
4624 #endif
4625 overflow (ovf, false, "sbq overflow fault");
4626 }
4627 break;
4628
4629
4630 case x0 (0160):
4631 case x0 (0161):
4632 case x0 (0162):
4633 case x0 (0163):
4634 case x0 (0164):
4635 case x0 (0165):
4636 case x0 (0166):
4637 case x0 (0167):
4638 {
4639
4640
4641
4642 L68_ (cpu.ou.cycle |= ou_GOS;)
4643 uint32 n = opcode10 & 07;
4644 #ifdef TESTING
4645 HDBGRegXR (n, "sbxn");
4646 #endif
4647 bool ovf;
4648 cpu.rX[n] = Sub18b (cpu.rX[n], GETHI (cpu.CY), 1,
4649 I_ZNOC, & cpu.cu.IR, & ovf);
4650 #ifdef TESTING
4651 HDBGRegXW (n, "sbxn");
4652 #endif
4653 overflow (ovf, false, "sbxn overflow fault");
4654 }
4655 break;
4656
4657 case x0 (0155):
4658 {
4659
4660
4661 L68_ (cpu.ou.cycle |= ou_GOS;)
4662 #ifdef TESTING
4663 HDBGRegAR ("ssa");
4664 #endif
4665 bool ovf;
4666 cpu.CY = Sub36b (cpu.rA, cpu.CY, 1, I_ZNOC, & cpu.cu.IR, & ovf);
4667 overflow (ovf, true, "ssa overflow fault");
4668 }
4669 break;
4670
4671 case x0 (0156):
4672 {
4673
4674
4675 L68_ (cpu.ou.cycle |= ou_GOS;)
4676 #ifdef TESTING
4677 HDBGRegQR ("ssq");
4678 #endif
4679 bool ovf;
4680 cpu.CY = Sub36b (cpu.rQ, cpu.CY, 1, I_ZNOC, & cpu.cu.IR, & ovf);
4681 overflow (ovf, true, "ssq overflow fault");
4682 }
4683 break;
4684
4685
4686 case x0 (0140):
4687 case x0 (0141):
4688 case x0 (0142):
4689 case x0 (0143):
4690 case x0 (0144):
4691 case x0 (0145):
4692 case x0 (0146):
4693 case x0 (0147):
4694 {
4695
4696
4697
4698 L68_ (cpu.ou.cycle |= ou_GOS;)
4699 uint32 n = opcode10 & 07;
4700 #ifdef TESTING
4701 HDBGRegXR (n, "ssxn");
4702 #endif
4703 bool ovf;
4704 word18 tmp18 = Sub18b (cpu.rX[n], GETHI (cpu.CY), 1,
4705 I_ZNOC, & cpu.cu.IR, & ovf);
4706 SETHI (cpu.CY, tmp18);
4707 overflow (ovf, true, "ssxn overflow fault");
4708 }
4709 break;
4710
4711 case x0 (0171):
4712 {
4713
4714
4715
4716 L68_ (cpu.ou.cycle |= ou_GOS;)
4717 #ifdef TESTING
4718 HDBGRegAR ("swca");
4719 #endif
4720 bool ovf;
4721 cpu.rA = Sub36b (cpu.rA, cpu.CY, TST_I_CARRY ? 1 : 0,
4722 I_ZNOC, & cpu.cu.IR, & ovf);
4723 #ifdef TESTING
4724 HDBGRegAW ("swca");
4725 #endif
4726 overflow (ovf, false, "swca overflow fault");
4727 }
4728 break;
4729
4730 case x0 (0172):
4731 {
4732
4733
4734
4735 L68_ (cpu.ou.cycle |= ou_GOS;)
4736 #ifdef TESTING
4737 HDBGRegQR ("swcq");
4738 #endif
4739 bool ovf;
4740 cpu.rQ = Sub36b (cpu.rQ, cpu.CY, TST_I_CARRY ? 1 : 0,
4741 I_ZNOC, & cpu.cu.IR, & ovf);
4742 #ifdef TESTING
4743 HDBGRegQW ("swcq");
4744 #endif
4745 overflow (ovf, false, "swcq overflow fault");
4746 }
4747 break;
4748
4749
4750
4751 case x0 (0401):
4752 {
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762 L68_ (cpu.ou.cycle |= ou_GD1;)
4763 #ifdef NEED_128
4764 # ifdef TESTING
4765 HDBGRegAR ("mpf");
4766 HDBGRegQR ("mpf");
4767 # endif
4768 word72 tmp72 = multiply_128 (SIGNEXT36_72 (cpu.rA), SIGNEXT36_72 (cpu.CY));
4769 tmp72 = and_128 (tmp72, MASK72);
4770 tmp72 = lshift_128 (tmp72, 1);
4771 #else
4772
4773
4774 word72 tmp72 = (word72) (((word72s) SIGNEXT36_72 (cpu.rA)) * ((word72s) SIGNEXT36_72 (cpu.CY)));
4775 tmp72 &= MASK72;
4776 tmp72 <<= 1;
4777 #endif
4778 L68_ (cpu.ou.cycle |= ou_GD2;)
4779
4780
4781 if (cpu.rA == MAXNEG && cpu.CY == MAXNEG)
4782 {
4783 SET_I_NEG;
4784 CLR_I_ZERO;
4785 overflow (true, false, "mpf overflow fault");
4786 }
4787
4788 convert_to_word36 (tmp72, &cpu.rA, &cpu.rQ);
4789 #ifdef TESTING
4790 HDBGRegAW ("mpf");
4791 HDBGRegQW ("mpf");
4792 #endif
4793 SC_I_ZERO (cpu.rA == 0 && cpu.rQ == 0);
4794 SC_I_NEG (cpu.rA & SIGN36);
4795 }
4796 break;
4797
4798 case x0 (0402):
4799
4800
4801 {
4802 L68_ (cpu.ou.cycle |= ou_GOS;)
4803 #ifdef NEED_128
4804 # ifdef TESTING
4805 HDBGRegQR ("mpy");
4806 # endif
4807 int128 prod = multiply_s128 (
4808 SIGNEXT36_128 (cpu.rQ & DMASK),
4809 SIGNEXT36_128 (cpu.CY & DMASK));
4810 convert_to_word36 (cast_128 (prod), &cpu.rA, &cpu.rQ);
4811 #else
4812 int64_t t0 = SIGNEXT36_64 (cpu.rQ & DMASK);
4813 int64_t t1 = SIGNEXT36_64 (cpu.CY & DMASK);
4814
4815 __int128_t prod = (__int128_t) t0 * (__int128_t) t1;
4816
4817 convert_to_word36 ((word72)prod, &cpu.rA, &cpu.rQ);
4818 #endif
4819 #ifdef TESTING
4820 HDBGRegAW ("mpy");
4821 HDBGRegQW ("mpy");
4822 #endif
4823
4824 SC_I_ZERO (cpu.rA == 0 && cpu.rQ == 0);
4825 SC_I_NEG (cpu.rA & SIGN36);
4826 }
4827 break;
4828
4829
4830
4831
4832
4833 case x0 (0506):
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847 L68_ (cpu.ou.cycle |= ou_GD1;)
4848
4849
4850
4851 #ifdef TESTING
4852 HDBGRegQR ("div");
4853 #endif
4854 if ((cpu.rQ == MAXNEG && (cpu.CY == 1 || cpu.CY == NEG136)) ||
4855 (cpu.CY == 0))
4856 {
4857
4858
4859
4860
4861 cpu.rA = (cpu.rQ & SIGN36) ? 0 : SIGN36;
4862 #ifdef TESTING
4863 HDBGRegAW ("div");
4864 #endif
4865
4866
4867 SC_I_ZERO (cpu.CY == 0);
4868 SC_I_NEG (cpu.rQ & SIGN36);
4869
4870 if (cpu.rQ & SIGN36)
4871 {
4872
4873
4874 cpu.rQ = ((word36) (- (word36s) cpu.rQ)) & MASK36;
4875 #ifdef TESTING
4876 HDBGRegQW ("div");
4877 #endif
4878 }
4879
4880 dlyDoFault (FAULT_DIV,
4881 fst_ill_op,
4882 "div divide check");
4883 }
4884 else
4885 {
4886 t_int64 dividend = (t_int64) (SIGNEXT36_64 (cpu.rQ));
4887 t_int64 divisor = (t_int64) (SIGNEXT36_64 (cpu.CY));
4888 #ifdef TESTING
4889 # ifdef DIV_TRACE
4890 sim_debug (DBG_CAC, & cpu_dev, "\n");
4891 sim_debug (DBG_CAC, & cpu_dev,
4892 ">>> dividend cpu.rQ %"PRId64" (%012"PRIo64")\n",
4893 dividend, cpu.rQ);
4894 sim_debug (DBG_CAC, & cpu_dev,
4895 ">>> divisor CY %"PRId64" (%012"PRIo64")\n",
4896 divisor, cpu.CY);
4897 # endif
4898 #endif
4899
4900 t_int64 quotient = dividend / divisor;
4901 L68_ (cpu.ou.cycle |= ou_GD2;)
4902 t_int64 remainder = dividend % divisor;
4903 #ifdef TESTING
4904 # ifdef DIV_TRACE
4905 sim_debug (DBG_CAC, & cpu_dev, ">>> quot 1 %"PRId64"\n", quotient);
4906 sim_debug (DBG_CAC, & cpu_dev, ">>> rem 1 %"PRId64"\n", remainder);
4907 # endif
4908 #endif
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929 #ifdef TESTING
4930 # ifdef DIV_TRACE
4931
4932 sim_debug (DBG_CAC, & cpu_dev,
4933 "dividend was = %"PRId64"\n", dividend);
4934 sim_debug (DBG_CAC, & cpu_dev,
4935 "quotient * divisor + remainder = %"PRId64"\n",
4936 quotient * divisor + remainder);
4937 if (dividend != quotient * divisor + remainder)
4938 {
4939 sim_debug (DBG_CAC, & cpu_dev,
4940 "---------------------------------^^^^^^^^^^^^^^^\n");
4941 }
4942 # endif
4943 #endif
4944
4945 if (dividend != quotient * divisor + remainder)
4946 {
4947 sim_debug (DBG_ERR, & cpu_dev,
4948 "Internal division error;"
4949 " rQ %012"PRIo64" CY %012"PRIo64"\n", cpu.rQ, cpu.CY);
4950 }
4951
4952 cpu.rA = (word36) remainder & DMASK;
4953 cpu.rQ = (word36) quotient & DMASK;
4954 #ifdef TESTING
4955 HDBGRegAW ("div");
4956 HDBGRegQW ("div");
4957
4958 # ifdef DIV_TRACE
4959 sim_debug (DBG_CAC, & cpu_dev, "rA (rem) %012"PRIo64"\n", cpu.rA);
4960 sim_debug (DBG_CAC, & cpu_dev, "rQ (quot) %012"PRIo64"\n", cpu.rQ);
4961 # endif
4962 #endif
4963
4964 SC_I_ZERO (cpu.rQ == 0);
4965 SC_I_NEG (cpu.rQ & SIGN36);
4966 }
4967
4968 break;
4969
4970 case x0 (0507):
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987 dvf ();
4988
4989 break;
4990
4991
4992
4993 case x0 (0531):
4994
4995
4996 #ifdef TESTING
4997 HDBGRegAR ("neg");
4998 #endif
4999 cpu.rA &= DMASK;
5000 if (cpu.rA == 0400000000000ULL)
5001 {
5002 CLR_I_ZERO;
5003 SET_I_NEG;
5004 overflow (true, false, "neg overflow fault");
5005 }
5006
5007
5008
5009 cpu.rA = (word36) (- (word36s) cpu.rA);
5010
5011 cpu.rA &= DMASK;
5012 #ifdef TESTING
5013 HDBGRegAW ("neg");
5014 #endif
5015
5016 SC_I_ZERO (cpu.rA == 0);
5017 SC_I_NEG (cpu.rA & SIGN36);
5018
5019 break;
5020
5021 case x0 (0533):
5022
5023 {
5024 #ifdef TESTING
5025 HDBGRegAR ("negl");
5026 HDBGRegQR ("negl");
5027 #endif
5028 cpu.rA &= DMASK;
5029 cpu.rQ &= DMASK;
5030
5031 if (cpu.rA == 0400000000000ULL && cpu.rQ == 0)
5032 {
5033 CLR_I_ZERO;
5034 SET_I_NEG;
5035 overflow (true, false, "negl overflow fault");
5036 }
5037
5038 word72 tmp72 = convert_to_word72 (cpu.rA, cpu.rQ);
5039 #ifdef NEED_128
5040 tmp72 = negate_128 (tmp72);
5041
5042 SC_I_ZERO (iszero_128 (tmp72));
5043 SC_I_NEG (isnonzero_128 (and_128 (tmp72, SIGN72)));
5044 #else
5045
5046
5047 tmp72 = (word72) (-(word72s) tmp72);
5048
5049 SC_I_ZERO (tmp72 == 0);
5050 SC_I_NEG (tmp72 & SIGN72);
5051 #endif
5052
5053 convert_to_word36 (tmp72, &cpu.rA, &cpu.rQ);
5054 #ifdef TESTING
5055 HDBGRegAW ("negl");
5056 HDBGRegQW ("negl");
5057 #endif
5058 }
5059 break;
5060
5061
5062
5063 case x0 (0405):
5064
5065
5066
5067 {
5068
5069
5070
5071
5072
5073 #ifdef TESTING
5074 HDBGRegAR ("cmg");
5075 #endif
5076 t_int64 a = SIGNEXT36_64 (cpu.rA);
5077 if (a < 0)
5078 a = -a;
5079 t_int64 y = SIGNEXT36_64 (cpu.CY);
5080 if (y < 0)
5081 y = -y;
5082
5083 SC_I_ZERO (a == y);
5084 SC_I_NEG (a < y);
5085 }
5086 break;
5087
5088 case x0 (0211):
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107 {
5108 #ifdef TESTING
5109 HDBGRegAR ("cmk");
5110 HDBGRegQR ("cmk");
5111 HDBGRegYR ("cmk");
5112 #endif
5113 word36 Z = ~cpu.rQ & (cpu.rA ^ cpu.CY);
5114 Z &= DMASK;
5115 #ifdef TESTING
5116 HDBGRegZW (Z, "cmk");
5117 HDBGRegIR ("cmk");
5118 #endif
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130 SC_I_ZERO (Z == 0);
5131 SC_I_NEG (Z & SIGN36);
5132 }
5133 break;
5134
5135
5136
5137
5138 case x0 (0117):
5139
5140 {
5141 #ifdef TESTING
5142 HDBGRegAR ("cmpaq");
5143 HDBGRegQR ("cmpaq");
5144 #endif
5145 word72 tmp72 = YPAIRTO72 (cpu.Ypair);
5146 word72 trAQ = convert_to_word72 (cpu.rA, cpu.rQ);
5147 #ifdef NEED_128
5148 trAQ = and_128 (trAQ, MASK72);
5149 #else
5150 trAQ &= MASK72;
5151 #endif
5152 cmp72 (trAQ, tmp72, &cpu.cu.IR);
5153 }
5154 break;
5155
5156
5157
5158
5159
5160 case x0 (0100):
5161 case x0 (0101):
5162 case x0 (0102):
5163 case x0 (0103):
5164 case x0 (0104):
5165 case x0 (0105):
5166 case x0 (0106):
5167 case x0 (0107):
5168
5169
5170 {
5171 uint32 n = opcode10 & 07;
5172 #ifdef TESTING
5173 HDBGRegXR (n, "cmpxn");
5174 #endif
5175 cmp18 (cpu.rX[n], GETHI (cpu.CY), &cpu.cu.IR);
5176 }
5177 break;
5178
5179 case x0 (0111):
5180
5181
5182
5183
5184
5185
5186
5187 #ifdef TESTING
5188 HDBGRegAR ("cwl");
5189 HDBGRegQR ("cwl");
5190 #endif
5191 cmp36wl (cpu.rA, cpu.CY, cpu.rQ, &cpu.cu.IR);
5192 break;
5193
5194
5195
5196 case x0 (0234):
5197
5198 cpu.CY &= DMASK;
5199 SC_I_ZERO (cpu.CY == 0);
5200 SC_I_NEG (cpu.CY & SIGN36);
5201 break;
5202
5203 case x0 (0214):
5204
5205 cpu.CY &= DMASK;
5206 SC_I_ZERO (cpu.CY == 0);
5207 SC_I_NEG (cpu.CY & SIGN36);
5208
5209 cpu.CY = 0;
5210 break;
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222 case x0 (0376):
5223
5224 #ifdef TESTING
5225 HDBGRegQR ("anq");
5226 #endif
5227 cpu.rQ = cpu.rQ & cpu.CY;
5228 cpu.rQ &= DMASK;
5229 #ifdef TESTING
5230 HDBGRegQW ("anq");
5231 #endif
5232
5233 SC_I_ZERO (cpu.rQ == 0);
5234 SC_I_NEG (cpu.rQ & SIGN36);
5235 break;
5236
5237 case x0 (0355):
5238
5239 {
5240 #ifdef TESTING
5241 HDBGRegAR ("ansa");
5242 #endif
5243 cpu.CY = cpu.rA & cpu.CY;
5244 cpu.CY &= DMASK;
5245
5246 SC_I_ZERO (cpu.CY == 0);
5247 SC_I_NEG (cpu.CY & SIGN36);
5248 }
5249 break;
5250
5251 case x0 (0356):
5252
5253 {
5254 #ifdef TESTING
5255 HDBGRegQR ("ansq");
5256 #endif
5257 cpu.CY = cpu.rQ & cpu.CY;
5258 cpu.CY &= DMASK;
5259
5260 SC_I_ZERO (cpu.CY == 0);
5261 SC_I_NEG (cpu.CY & SIGN36);
5262 }
5263 break;
5264
5265
5266 case x0 (0340):
5267 case x0 (0341):
5268 case x0 (0342):
5269 case x0 (0343):
5270 case x0 (0344):
5271 case x0 (0345):
5272 case x0 (0346):
5273 case x0 (0347):
5274
5275
5276 {
5277 uint32 n = opcode10 & 07;
5278 #ifdef TESTING
5279 HDBGRegXR (n, "ansxn");
5280 #endif
5281 word18 tmp18 = cpu.rX[n] & GETHI (cpu.CY);
5282 tmp18 &= MASK18;
5283
5284 SC_I_ZERO (tmp18 == 0);
5285 SC_I_NEG (tmp18 & SIGN18);
5286
5287 SETHI (cpu.CY, tmp18);
5288 }
5289
5290 break;
5291
5292
5293 case x0 (0360):
5294 case x0 (0361):
5295 case x0 (0362):
5296 case x0 (0363):
5297 case x0 (0364):
5298 case x0 (0365):
5299 case x0 (0366):
5300 case x0 (0367):
5301
5302
5303 {
5304 uint32 n = opcode10 & 07;
5305 #ifdef TESTING
5306 HDBGRegXR (n, "anxn");
5307 #endif
5308 cpu.rX[n] &= GETHI (cpu.CY);
5309 cpu.rX[n] &= MASK18;
5310 #ifdef TESTING
5311 HDBGRegXW (n, "anxn");
5312 #endif
5313
5314 SC_I_ZERO (cpu.rX[n] == 0);
5315 SC_I_NEG (cpu.rX[n] & SIGN18);
5316 }
5317 break;
5318
5319
5320
5321
5322
5323
5324 case x0 (0277):
5325
5326 {
5327 #ifdef TESTING
5328 HDBGRegAR ("oraq");
5329 HDBGRegQR ("oraq");
5330 #endif
5331 word72 tmp72 = YPAIRTO72 (cpu.Ypair);
5332 word72 trAQ = convert_to_word72 (cpu.rA, cpu.rQ);
5333 #ifdef NEED_128
5334 trAQ = or_128 (trAQ, tmp72);
5335 trAQ = and_128 (trAQ, MASK72);
5336
5337 SC_I_ZERO (iszero_128 (trAQ));
5338 SC_I_NEG (isnonzero_128 (and_128 (trAQ, SIGN72)));
5339 #else
5340 trAQ = trAQ | tmp72;
5341 trAQ &= MASK72;
5342
5343 SC_I_ZERO (trAQ == 0);
5344 SC_I_NEG (trAQ & SIGN72);
5345 #endif
5346 convert_to_word36 (trAQ, &cpu.rA, &cpu.rQ);
5347 #ifdef TESTING
5348 HDBGRegAW ("oraq");
5349 HDBGRegQW ("oraq");
5350 #endif
5351 }
5352 break;
5353
5354 case x0 (0276):
5355
5356 #ifdef TESTING
5357 HDBGRegQR ("orq");
5358 #endif
5359 cpu.rQ = cpu.rQ | cpu.CY;
5360 cpu.rQ &= DMASK;
5361 #ifdef TESTING
5362 HDBGRegQW ("orq");
5363 #endif
5364
5365 SC_I_ZERO (cpu.rQ == 0);
5366 SC_I_NEG (cpu.rQ & SIGN36);
5367
5368 break;
5369
5370 case x0 (0255):
5371
5372 #ifdef TESTING
5373 HDBGRegAR ("orsa");
5374 #endif
5375 cpu.CY = cpu.rA | cpu.CY;
5376 cpu.CY &= DMASK;
5377
5378 SC_I_ZERO (cpu.CY == 0);
5379 SC_I_NEG (cpu.CY & SIGN36);
5380 break;
5381
5382 case x0 (0256):
5383
5384 #ifdef TESTING
5385 HDBGRegQR ("orsq");
5386 #endif
5387 cpu.CY = cpu.rQ | cpu.CY;
5388 cpu.CY &= DMASK;
5389
5390 SC_I_ZERO (cpu.CY == 0);
5391 SC_I_NEG (cpu.CY & SIGN36);
5392 break;
5393
5394
5395 case x0 (0240):
5396 case x0 (0241):
5397 case x0 (0242):
5398 case x0 (0243):
5399 case x0 (0244):
5400 case x0 (0245):
5401 case x0 (0246):
5402 case x0 (0247):
5403
5404
5405 {
5406 uint32 n = opcode10 & 07;
5407
5408 word18 tmp18 = cpu.rX[n] | GETHI (cpu.CY);
5409 tmp18 &= MASK18;
5410
5411 SC_I_ZERO (tmp18 == 0);
5412 SC_I_NEG (tmp18 & SIGN18);
5413
5414 SETHI (cpu.CY, tmp18);
5415 }
5416 break;
5417
5418
5419 case x0 (0260):
5420 case x0 (0261):
5421 case x0 (0262):
5422 case x0 (0263):
5423 case x0 (0264):
5424 case x0 (0265):
5425 case x0 (0266):
5426 case x0 (0267):
5427
5428
5429 {
5430 uint32 n = opcode10 & 07;
5431 #ifdef TESTING
5432 HDBGRegXR (n, "orxn");
5433 #endif
5434 cpu.rX[n] |= GETHI (cpu.CY);
5435 cpu.rX[n] &= MASK18;
5436 #ifdef TESTING
5437 HDBGRegXW (n, "orxn");
5438 #endif
5439
5440 SC_I_ZERO (cpu.rX[n] == 0);
5441 SC_I_NEG (cpu.rX[n] & SIGN18);
5442 }
5443 break;
5444
5445
5446
5447 case x0 (0675):
5448
5449 #ifdef TESTING
5450 HDBGRegAR ("era");
5451 #endif
5452 cpu.rA = cpu.rA ^ cpu.CY;
5453 cpu.rA &= DMASK;
5454 #ifdef TESTING
5455 HDBGRegAW ("era");
5456 #endif
5457
5458 SC_I_ZERO (cpu.rA == 0);
5459 SC_I_NEG (cpu.rA & SIGN36);
5460
5461 break;
5462
5463
5464
5465
5466 case x0 (0676):
5467
5468 #ifdef TESTING
5469 HDBGRegQR ("eraq");
5470 #endif
5471 cpu.rQ = cpu.rQ ^ cpu.CY;
5472 cpu.rQ &= DMASK;
5473 #ifdef TESTING
5474 HDBGRegQW ("eraq");
5475 #endif
5476 SC_I_ZERO (cpu.rQ == 0);
5477 SC_I_NEG (cpu.rQ & SIGN36);
5478 break;
5479
5480 case x0 (0655):
5481
5482 #ifdef TESTING
5483 HDBGRegAR ("ersa");
5484 #endif
5485 cpu.CY = cpu.rA ^ cpu.CY;
5486 cpu.CY &= DMASK;
5487
5488 SC_I_ZERO (cpu.CY == 0);
5489 SC_I_NEG (cpu.CY & SIGN36);
5490 break;
5491
5492 case x0 (0656):
5493
5494 #ifdef TESTING
5495 HDBGRegQR ("ersq");
5496 #endif
5497 cpu.CY = cpu.rQ ^ cpu.CY;
5498 cpu.CY &= DMASK;
5499
5500 SC_I_ZERO (cpu.CY == 0);
5501 SC_I_NEG (cpu.CY & SIGN36);
5502
5503 break;
5504
5505
5506 case x0 (0640):
5507 case x0 (0641):
5508 case x0 (0642):
5509 case x0 (0643):
5510 case x0 (0644):
5511 case x0 (0645):
5512 case x0 (0646):
5513 case x0 (0647):
5514
5515
5516 {
5517 uint32 n = opcode10 & 07;
5518 #ifdef TESTING
5519 HDBGRegXR (n, "ersxn");
5520 #endif
5521
5522 word18 tmp18 = cpu.rX[n] ^ GETHI (cpu.CY);
5523 tmp18 &= MASK18;
5524
5525 SC_I_ZERO (tmp18 == 0);
5526 SC_I_NEG (tmp18 & SIGN18);
5527
5528 SETHI (cpu.CY, tmp18);
5529 }
5530 break;
5531
5532
5533 case x0 (0660):
5534 case x0 (0661):
5535 case x0 (0662):
5536 case x0 (0663):
5537 case x0 (0664):
5538 case x0 (0665):
5539 case x0 (0666):
5540 case x0 (0667):
5541
5542
5543 {
5544 uint32 n = opcode10 & 07;
5545 #ifdef TESTING
5546 HDBGRegXR (n, "erxn");
5547 #endif
5548 cpu.rX[n] ^= GETHI (cpu.CY);
5549 cpu.rX[n] &= MASK18;
5550 #ifdef TESTING
5551 HDBGRegXW (n, "erxn");
5552 #endif
5553
5554 SC_I_ZERO (cpu.rX[n] == 0);
5555 SC_I_NEG (cpu.rX[n] & SIGN18);
5556 }
5557 break;
5558
5559
5560
5561
5562
5563
5564 case x0 (0317):
5565
5566 {
5567 #ifdef TESTING
5568 HDBGRegAR ("canaq");
5569 HDBGRegQR ("canaq");
5570 #endif
5571 word72 tmp72 = YPAIRTO72 (cpu.Ypair);
5572 word72 trAQ = convert_to_word72 (cpu.rA, cpu.rQ);
5573 #ifdef NEED_128
5574 trAQ = and_128 (trAQ, tmp72);
5575 trAQ = and_128 (trAQ, MASK72);
5576
5577 SC_I_ZERO (iszero_128 (trAQ));
5578 SC_I_NEG (isnonzero_128 (and_128 (trAQ, SIGN72)));
5579 #else
5580 trAQ = trAQ & tmp72;
5581 trAQ &= MASK72;
5582
5583 SC_I_ZERO (trAQ == 0);
5584 SC_I_NEG (trAQ & SIGN72);
5585 #endif
5586 }
5587 break;
5588
5589 case x0 (0316):
5590
5591 {
5592 #ifdef TESTING
5593 HDBGRegQR ("canq");
5594 #endif
5595 word36 trZ = cpu.rQ & cpu.CY;
5596 trZ &= DMASK;
5597
5598 SC_I_ZERO (trZ == 0);
5599 SC_I_NEG (trZ & SIGN36);
5600 }
5601 break;
5602
5603
5604 case x0 (0300):
5605 case x0 (0301):
5606 case x0 (0302):
5607 case x0 (0303):
5608 case x0 (0304):
5609 case x0 (0305):
5610 case x0 (0306):
5611 case x0 (0307):
5612
5613
5614 {
5615 uint32 n = opcode10 & 07;
5616 #ifdef TESTING
5617 HDBGRegXR (n, "canxn");
5618 #endif
5619 word18 tmp18 = cpu.rX[n] & GETHI (cpu.CY);
5620 tmp18 &= MASK18;
5621 sim_debug (DBG_TRACEEXT, & cpu_dev,
5622 "n %o rX %06o HI %06o tmp %06o\n",
5623 n, cpu.rX[n], (word18) (GETHI (cpu.CY) & MASK18),
5624 tmp18);
5625
5626 SC_I_ZERO (tmp18 == 0);
5627 SC_I_NEG (tmp18 & SIGN18);
5628 }
5629 break;
5630
5631
5632
5633 case x0 (0215):
5634
5635 {
5636 #ifdef TESTING
5637 HDBGRegAR ("cnaa");
5638 #endif
5639 word36 trZ = cpu.rA & ~cpu.CY;
5640 trZ &= DMASK;
5641
5642 SC_I_ZERO (trZ == 0);
5643 SC_I_NEG (trZ & SIGN36);
5644 }
5645 break;
5646
5647 case x0 (0217):
5648
5649 {
5650 #ifdef TESTING
5651 HDBGRegAR ("cnaaq");
5652 HDBGRegQR ("cnaaq");
5653 #endif
5654 word72 tmp72 = YPAIRTO72 (cpu.Ypair);
5655
5656 word72 trAQ = convert_to_word72 (cpu.rA, cpu.rQ);
5657 #ifdef NEED_128
5658 trAQ = and_128 (trAQ, complement_128 (tmp72));
5659 trAQ = and_128 (trAQ, MASK72);
5660
5661 SC_I_ZERO (iszero_128 (trAQ));
5662 SC_I_NEG (isnonzero_128 (and_128 (trAQ, SIGN72)));
5663 #else
5664 trAQ = trAQ & ~tmp72;
5665 trAQ &= MASK72;
5666
5667 SC_I_ZERO (trAQ == 0);
5668 SC_I_NEG (trAQ & SIGN72);
5669 #endif
5670 }
5671 break;
5672
5673 case x0 (0216):
5674
5675 {
5676 #ifdef TESTING
5677 HDBGRegQR ("cnaq");
5678 #endif
5679 word36 trZ = cpu.rQ & ~cpu.CY;
5680 trZ &= DMASK;
5681 SC_I_ZERO (trZ == 0);
5682 SC_I_NEG (trZ & SIGN36);
5683 }
5684 break;
5685
5686
5687 case x0 (0200):
5688 case x0 (0201):
5689 case x0 (0202):
5690 case x0 (0203):
5691 case x0 (0204):
5692 case x0 (0205):
5693 case x0 (0206):
5694 case x0 (0207):
5695
5696 {
5697 uint32 n = opcode10 & 07;
5698 #ifdef TESTING
5699 HDBGRegXR (n, "cnaxn");
5700 #endif
5701 word18 tmp18 = cpu.rX[n] & ~GETHI (cpu.CY);
5702 tmp18 &= MASK18;
5703
5704 SC_I_ZERO (tmp18 == 0);
5705 SC_I_NEG (tmp18 & SIGN18);
5706 }
5707 break;
5708
5709
5710
5711
5712
5713 case x0 (0433):
5714
5715
5716
5717
5718
5719
5720 CPTUR (cptUseE);
5721 cpu.rE = (cpu.Ypair[0] >> 28) & MASK8;
5722
5723 cpu.rA = (cpu.Ypair[0] & FLOAT36MASK) << 8;
5724 cpu.rA |= (cpu.Ypair[1] >> 28) & MASK8;
5725
5726 cpu.rQ = (cpu.Ypair[1] & FLOAT36MASK) << 8;
5727
5728 #ifdef TESTING
5729 HDBGRegAW ("dfld");
5730 HDBGRegQW ("dfld");
5731 #endif
5732
5733 SC_I_ZERO (cpu.rA == 0 && cpu.rQ == 0);
5734 SC_I_NEG (cpu.rA & SIGN36);
5735 break;
5736
5737
5738
5739
5740
5741
5742 case x0 (0457):
5743
5744
5745
5746 CPTUR (cptUseE);
5747 #ifdef TESTING
5748 HDBGRegAR ("dfst");
5749 HDBGRegQR ("dfst");
5750 #endif
5751 cpu.Ypair[0] = ((word36)cpu.rE << 28) |
5752 ((cpu.rA & 0777777777400LLU) >> 8);
5753 cpu.Ypair[1] = ((cpu.rA & 0377) << 28) |
5754 ((cpu.rQ & 0777777777400LLU) >> 8);
5755
5756 break;
5757
5758 case x0 (0472):
5759
5760 dfstr (cpu.Ypair);
5761 break;
5762
5763 case x0 (0455):
5764
5765
5766 CPTUR (cptUseE);
5767 #ifdef TESTING
5768 HDBGRegAR ("fst");
5769 #endif
5770 cpu.rE &= MASK8;
5771 cpu.rA &= DMASK;
5772 cpu.CY = ((word36)cpu.rE << 28) | (((cpu.rA >> 8) & 01777777777LL));
5773 break;
5774
5775 case x0 (0470):
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799 fstr (&cpu.CY);
5800
5801 break;
5802
5803
5804
5805 case x0 (0477):
5806
5807
5808
5809 CPTUR (cptUseE);
5810 #ifdef TESTING
5811 HDBGRegAR ("dfad");
5812 HDBGRegQR ("dfad");
5813 #endif
5814 dufa (false, true);
5815 #ifdef TESTING
5816 HDBGRegAW ("dfad");
5817 HDBGRegQW ("dfad");
5818 #endif
5819 break;
5820
5821 case x0 (0437):
5822 dufa (false, false);
5823 break;
5824
5825 case x0 (0475):
5826
5827
5828
5829
5830 CPTUR (cptUseE);
5831 #ifdef TESTING
5832 HDBGRegAR ("fad");
5833 HDBGRegQR ("fad");
5834 #endif
5835 ufa (false, true);
5836 #ifdef TESTING
5837 HDBGRegAW ("fad");
5838 HDBGRegQW ("fad");
5839 #endif
5840
5841 break;
5842
5843 case x0 (0435):
5844
5845
5846 ufa (false, false);
5847 break;
5848
5849
5850
5851 case x0 (0577):
5852
5853
5854
5855
5856 CPTUR (cptUseE);
5857 #ifdef TESTING
5858 HDBGRegAR ("dfsb");
5859 HDBGRegQR ("dfsb");
5860 #endif
5861 dufa (true, true);
5862 #ifdef TESTING
5863 HDBGRegAW ("dfsb");
5864 HDBGRegQW ("dfsb");
5865 #endif
5866 break;
5867
5868 case x0 (0537):
5869 dufa (true, false);
5870 break;
5871
5872 case x0 (0575):
5873
5874
5875 #ifdef TESTING
5876 HDBGRegAR ("fsb");
5877 HDBGRegQR ("fsb");
5878 #endif
5879 CPTUR (cptUseE);
5880 ufa (true, true);
5881 #ifdef TESTING
5882 HDBGRegAW ("fsb");
5883 HDBGRegQW ("fsb");
5884 #endif
5885 break;
5886
5887 case x0 (0535):
5888
5889 ufa (true, false);
5890 break;
5891
5892
5893
5894 case x0 (0463):
5895
5896
5897
5898 CPTUR (cptUseE);
5899 #ifdef TESTING
5900 HDBGRegAR ("dfmp");
5901 HDBGRegQR ("dfmp");
5902 #endif
5903 dufm (true);
5904 #ifdef TESTING
5905 HDBGRegAW ("dfmp");
5906 HDBGRegQW ("dfmp");
5907 #endif
5908 break;
5909
5910 case x0 (0423):
5911
5912 dufm (false);
5913 break;
5914
5915 case x0 (0461):
5916
5917
5918
5919 CPTUR (cptUseE);
5920 ufm (true);
5921 #ifdef TESTING
5922 HDBGRegAW ("fmp");
5923 HDBGRegQW ("fmp");
5924 #endif
5925 break;
5926
5927 case x0 (0421):
5928
5929 ufm (false);
5930 break;
5931
5932
5933
5934 case x0 (0527):
5935
5936 dfdi ();
5937 break;
5938
5939 case x0 (0567):
5940
5941 dfdv ();
5942 break;
5943
5944 case x0 (0525):
5945
5946
5947 fdi ();
5948 break;
5949
5950 case x0 (0565):
5951
5952
5953 fdv ();
5954 break;
5955
5956
5957
5958 case x0 (0513):
5959
5960 fneg ();
5961 break;
5962
5963
5964
5965 case x0 (0573):
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980 CPTUR (cptUseE);
5981 fno (& cpu.rE, & cpu.rA, & cpu.rQ);
5982 #ifdef TESTING
5983 HDBGRegAW ("fno");
5984 HDBGRegQW ("fno");
5985 #endif
5986 break;
5987
5988
5989
5990 case x0 (0473):
5991
5992
5993
5994 dfrd ();
5995 break;
5996
5997 case x0 (0471):
5998
5999
6000
6001 frd ();
6002 break;
6003
6004
6005
6006 case x0 (0427):
6007
6008
6009
6010 dfcmg ();
6011 break;
6012
6013 case x0 (0517):
6014
6015
6016
6017 dfcmp ();
6018 break;
6019
6020 case x0 (0425):
6021
6022
6023
6024 fcmg ();
6025 break;
6026
6027 case x0 (0515):
6028
6029
6030
6031 fcmp ();
6032 break;
6033
6034
6035
6036 case x0 (0415):
6037
6038 {
6039 CPTUR (cptUseE);
6040 int y = SIGNEXT8_int ((cpu.CY >> 28) & 0377);
6041 int e = SIGNEXT8_int (cpu.rE);
6042 e = e + y;
6043
6044 cpu.rE = e & 0377;
6045 CLR_I_ZERO;
6046 CLR_I_NEG;
6047
6048 if (e > 127)
6049 {
6050 SET_I_EOFL;
6051 if (tstOVFfault ())
6052 doFault (FAULT_OFL, fst_zero, "ade exp overflow fault");
6053 }
6054
6055 if (e < -128)
6056 {
6057 SET_I_EUFL;
6058 if (tstOVFfault ())
6059 doFault (FAULT_OFL, fst_zero, "ade exp underflow fault");
6060 }
6061 }
6062 break;
6063
6064 case x0 (0430):
6065
6066
6067
6068
6069 SC_I_ZERO ((cpu.CY & 001777777777LL) == 0);
6070 SC_I_NEG (cpu.CY & 001000000000LL);
6071
6072 break;
6073
6074 case x0 (0411):
6075
6076
6077 CPTUR (cptUseE);
6078 cpu.rE = (cpu.CY >> 28) & 0377;
6079 CLR_I_ZERO;
6080 CLR_I_NEG;
6081
6082 break;
6083
6084 case x0 (0456):
6085
6086
6087
6088 CPTUR (cptUseE);
6089
6090 cpu.CY = ((word36) (cpu.rE & 0377)) << 28;
6091 cpu.zone = 0777777000000;
6092 cpu.useZone = true;
6093 break;
6094
6095
6096
6097 case x0 (0713):
6098
6099 CPTUR (cptUsePRn + 7);
6100
6101 do_caf ();
6102 read_tra_op ();
6103 sim_debug (DBG_TRACEEXT, & cpu_dev,
6104 "call6 PRR %o PSR %o\n", cpu.PPR.PRR, cpu.PPR.PSR);
6105
6106 return CONT_TRA;
6107
6108 case x0 (0630):
6109 {
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120 do_caf ();
6121 Read (cpu.TPR.CA, &cpu.CY, OPERAND_READ);
6122
6123 cpu.PPR.IC = GETHI (cpu.CY);
6124 word18 tempIR = GETLO (cpu.CY) & 0777770;
6125
6126 if (is_priv_mode ())
6127 {
6128
6129
6130
6131
6132 SCF (TST_I_MIF, tempIR, I_MIF);
6133 }
6134 else
6135 {
6136 CLRF (tempIR, I_MIF);
6137 }
6138
6139
6140
6141
6142
6143
6144
6145
6146 if (! (TST_I_NBAR && TSTF (tempIR, I_NBAR)))
6147 {
6148 CLRF (tempIR, I_NBAR);
6149 }
6150 if (! (TST_I_ABS && TSTF (tempIR, I_ABS)))
6151 {
6152 CLRF (tempIR, I_ABS);
6153 }
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163 CPTUR (cptUseIR);
6164 cpu.cu.IR = tempIR;
6165 return CONT_RET;
6166 }
6167
6168
6169
6170
6171 case x0 (0614):
6172
6173
6174
6175
6176 if (TST_I_EOFL)
6177 {
6178 CLR_I_EOFL;
6179 do_caf ();
6180 read_tra_op ();
6181 return CONT_TRA;
6182 }
6183 break;
6184
6185 case x0 (0615):
6186
6187
6188
6189 if (TST_I_EUFL)
6190 {
6191 CLR_I_EUFL;
6192 do_caf ();
6193 read_tra_op ();
6194 return CONT_TRA;
6195 }
6196 break;
6197
6198
6199
6200
6201
6202
6203
6204 case x0 (0602):
6205
6206
6207
6208 if (!TST_I_CARRY)
6209 {
6210 do_caf ();
6211 read_tra_op ();
6212 return CONT_TRA;
6213 }
6214 break;
6215
6216
6217
6218
6219 case x0 (0617):
6220
6221
6222
6223 if (TST_I_OFLOW)
6224 {
6225 CLR_I_OFLOW;
6226 do_caf ();
6227 read_tra_op ();
6228 return CONT_TRA;
6229 }
6230 break;
6231
6232 case x0 (0605):
6233
6234
6235
6236 if (! (TST_I_NEG))
6237 {
6238 do_caf ();
6239 read_tra_op ();
6240 return CONT_TRA;
6241 }
6242 break;
6243
6244
6245
6246
6247
6248
6249
6250 case x0 (0603):
6251
6252
6253
6254 if (TST_I_CARRY)
6255 {
6256 do_caf ();
6257 read_tra_op ();
6258 return CONT_TRA;
6259 }
6260 break;
6261
6262 case x1 (0601):
6263
6264
6265
6266 if (!TST_I_TRUNC)
6267 {
6268 do_caf ();
6269 read_tra_op ();
6270 return CONT_TRA;
6271 }
6272 break;
6273
6274 case x1 (0600):
6275
6276
6277
6278 if (TST_I_TRUNC)
6279 {
6280 CLR_I_TRUNC;
6281 do_caf ();
6282 read_tra_op ();
6283 return CONT_TRA;
6284 }
6285 break;
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298 case x0 (0715):
6299 CPTUR (cptUseBAR);
6300 do_caf ();
6301 if (get_bar_mode ())
6302 read_tra_op ();
6303 else
6304 {
6305 cpu.TPR.CA = get_BAR_address (cpu.TPR.CA);
6306 read_tra_op ();
6307 CLR_I_NBAR;
6308 }
6309 return CONT_TRA;
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322 case x0 (0607):
6323
6324
6325
6326
6327 if (TST_I_TALLY == 0)
6328 {
6329 do_caf ();
6330 read_tra_op ();
6331 return CONT_TRA;
6332 }
6333 break;
6334
6335 case x1 (0606):
6336
6337
6338
6339
6340 if (TST_I_TALLY)
6341 {
6342 do_caf ();
6343 read_tra_op ();
6344 return CONT_TRA;
6345 }
6346 break;
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357 case x0 (0311):
6358
6359 CPTUR (cptUsePRn + 0);
6360 cpu.PR[0].SNR = cpu.TPR.CA & MASK15;
6361 #ifdef TESTING
6362 HDBGRegPRW (0, "easp0");
6363 #endif
6364 break;
6365
6366 case x1 (0310):
6367
6368 CPTUR (cptUsePRn + 1);
6369 cpu.PR[1].SNR = cpu.TPR.CA & MASK15;
6370 #ifdef TESTING
6371 HDBGRegPRW (1, "easp1");
6372 #endif
6373 break;
6374
6375 case x0 (0313):
6376
6377 CPTUR (cptUsePRn + 2);
6378 cpu.PR[2].SNR = cpu.TPR.CA & MASK15;
6379 #ifdef TESTING
6380 HDBGRegPRW (2, "easp2");
6381 #endif
6382 break;
6383
6384 case x1 (0312):
6385
6386 CPTUR (cptUsePRn + 3);
6387 cpu.PR[3].SNR = cpu.TPR.CA & MASK15;
6388 #ifdef TESTING
6389 HDBGRegPRW (3, "easp3");
6390 #endif
6391 break;
6392
6393 case x0 (0331):
6394
6395 CPTUR (cptUsePRn + 4);
6396 cpu.PR[4].SNR = cpu.TPR.CA & MASK15;
6397 #ifdef TESTING
6398 HDBGRegPRW (4, "easp4");
6399 #endif
6400 break;
6401
6402 case x1 (0330):
6403
6404 CPTUR (cptUsePRn + 5);
6405 cpu.PR[5].SNR = cpu.TPR.CA & MASK15;
6406 #ifdef TESTING
6407 HDBGRegPRW (5, "easp5");
6408 #endif
6409 break;
6410
6411 case x0 (0333):
6412
6413 CPTUR (cptUsePRn + 6);
6414 cpu.PR[6].SNR = cpu.TPR.CA & MASK15;
6415 #ifdef TESTING
6416 HDBGRegPRW (6, "easp6");
6417 #endif
6418 break;
6419
6420 case x1 (0332):
6421
6422 CPTUR (cptUsePRn + 7);
6423 cpu.PR[7].SNR = cpu.TPR.CA & MASK15;
6424 #ifdef TESTING
6425 HDBGRegPRW (7, "easp7");
6426 #endif
6427 break;
6428
6429
6430
6431 case x0 (0310):
6432
6433
6434
6435 CPTUR (cptUsePRn + 0);
6436 cpu.PR[0].WORDNO = cpu.TPR.CA;
6437 SET_PR_BITNO (0, cpu.TPR.TBR);
6438 #ifdef TESTING
6439 HDBGRegPRW (0, "eawp0");
6440 #endif
6441 break;
6442
6443 case x1 (0311):
6444
6445
6446
6447 CPTUR (cptUsePRn + 1);
6448 cpu.PR[1].WORDNO = cpu.TPR.CA;
6449 SET_PR_BITNO (1, cpu.TPR.TBR);
6450 #ifdef TESTING
6451 HDBGRegPRW (1, "eawp1");
6452 #endif
6453 break;
6454
6455 case x0 (0312):
6456
6457
6458
6459 CPTUR (cptUsePRn + 2);
6460 cpu.PR[2].WORDNO = cpu.TPR.CA;
6461 SET_PR_BITNO (2, cpu.TPR.TBR);
6462 #ifdef TESTING
6463 HDBGRegPRW (2, "eawp2");
6464 #endif
6465 break;
6466
6467 case x1 (0313):
6468
6469
6470
6471 CPTUR (cptUsePRn + 3);
6472 cpu.PR[3].WORDNO = cpu.TPR.CA;
6473 SET_PR_BITNO (3, cpu.TPR.TBR);
6474 #ifdef TESTING
6475 HDBGRegPRW (3, "eawp3");
6476 #endif
6477 break;
6478
6479 case x0 (0330):
6480
6481
6482
6483 CPTUR (cptUsePRn + 4);
6484 cpu.PR[4].WORDNO = cpu.TPR.CA;
6485 SET_PR_BITNO (4, cpu.TPR.TBR);
6486 #ifdef TESTING
6487 HDBGRegPRW (4, "eawp4");
6488 #endif
6489 break;
6490
6491 case x1 (0331):
6492
6493
6494
6495 CPTUR (cptUsePRn + 5);
6496 cpu.PR[5].WORDNO = cpu.TPR.CA;
6497 SET_PR_BITNO (5, cpu.TPR.TBR);
6498 #ifdef TESTING
6499 HDBGRegPRW (5, "eawp5");
6500 #endif
6501 break;
6502
6503 case x0 (0332):
6504
6505
6506
6507 CPTUR (cptUsePRn + 6);
6508 cpu.PR[6].WORDNO = cpu.TPR.CA;
6509 SET_PR_BITNO (6, cpu.TPR.TBR);
6510 #ifdef TESTING
6511 HDBGRegPRW (6, "eawp6");
6512 #endif
6513 break;
6514
6515 case x1 (0333):
6516
6517
6518
6519 CPTUR (cptUsePRn + 7);
6520 cpu.PR[7].WORDNO = cpu.TPR.CA;
6521 SET_PR_BITNO (7, cpu.TPR.TBR);
6522 #ifdef TESTING
6523 HDBGRegPRW (7, "eawp7");
6524 #endif
6525 break;
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547 case x0 (0173):
6548
6549
6550
6551
6552
6553
6554
6555 for (uint32 n = 0 ; n < 8 ; n ++)
6556 {
6557 CPTUR (cptUsePRn + n);
6558
6559 cpu.Ypair[0] = cpu.Yblock16[n * 2 + 0];
6560
6561 cpu.Ypair[1] = cpu.Yblock16[n * 2 + 1];
6562
6563
6564 word3 Crr = (GETLO (cpu.Ypair[0]) >> 15) & 07;
6565 if (get_addr_mode () == APPEND_mode)
6566 cpu.PR[n].RNR = max3 (Crr, cpu.SDW->R1, cpu.TPR.TRR);
6567 else
6568 cpu.PR[n].RNR = Crr;
6569 cpu.PR[n].SNR = (cpu.Ypair[0] >> 18) & MASK15;
6570 cpu.PR[n].WORDNO = GETHI (cpu.Ypair[1]);
6571 word6 bitno = (GETLO (cpu.Ypair[1]) >> 9) & 077;
6572
6573
6574
6575
6576
6577 if (bitno == 077)
6578 bitno = 037;
6579 SET_PR_BITNO (n, bitno);
6580 #ifdef TESTING
6581 HDBGRegPRW (n, "lpri");
6582 #endif
6583 }
6584
6585 break;
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610 case x0 (0254):
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625 for (uint32 n = 0 ; n < 8 ; n++)
6626 {
6627 CPTUR (cptUsePRn + n);
6628 cpu.Yblock16[2 * n] = 043;
6629 cpu.Yblock16[2 * n] |= ((word36) cpu.PR[n].SNR) << 18;
6630 cpu.Yblock16[2 * n] |= ((word36) cpu.PR[n].RNR) << 15;
6631
6632 cpu.Yblock16[2 * n + 1] = (word36) cpu.PR[n].WORDNO << 18;
6633 cpu.Yblock16[2 * n + 1] |= (word36) GET_PR_BITNO(n) << 9;
6634 }
6635
6636 break;
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649 case x0 (0540):
6650 case x0 (0541):
6651 case x0 (0542):
6652 case x0 (0543):
6653 case x0 (0544):
6654 case x0 (0545):
6655 case x0 (0546):
6656 case x0 (0547):
6657
6658
6659
6660
6661 {
6662 uint32 n = opcode10 & 07;
6663 CPTUR (cptUsePRn + n);
6664
6665
6666
6667
6668
6669 if ((cpu.PR[n].SNR & 070000) != 0 && cpu.PR[n].SNR != MASK15)
6670 doFault (FAULT_STR, fst_str_ptr, "sprpn");
6671
6672 cpu.CY = ((word36) (GET_PR_BITNO(n) & 077)) << 30;
6673
6674 cpu.CY |= ((word36) (cpu.PR[n].SNR & 07777)) << 18;
6675 cpu.CY |= cpu.PR[n].WORDNO & PAMASK;
6676 cpu.CY &= DMASK;
6677 }
6678 break;
6679
6680
6681
6682
6683 case x0 (0050):
6684 case x0 (0051):
6685 case x0 (0052):
6686 case x0 (0053):
6687
6688
6689
6690 {
6691 uint32 n = opcode10 & 03;
6692 CPTUR (cptUsePRn + n);
6693 cpu.PR[n].WORDNO += GETHI (cpu.CY);
6694 cpu.PR[n].WORDNO &= MASK18;
6695 SET_PR_BITNO (n, 0);
6696 #ifdef TESTING
6697 HDBGRegPRW (n, "adwpn");
6698 #endif
6699 }
6700 break;
6701
6702 case x0 (0150):
6703 case x0 (0151):
6704 case x0 (0152):
6705 case x0 (0153):
6706
6707
6708
6709 {
6710 uint32 n = (opcode10 & MASK3) + 4U;
6711 CPTUR (cptUsePRn + n);
6712 cpu.PR[n].WORDNO += GETHI (cpu.CY);
6713 cpu.PR[n].WORDNO &= MASK18;
6714 SET_PR_BITNO (n, 0);
6715 #ifdef TESTING
6716 HDBGRegPRW (n, "adwpn");
6717 #endif
6718 }
6719 break;
6720
6721
6722
6723
6724
6725
6726
6727
6728 case x0 (0633):
6729
6730
6731 {
6732
6733
6734
6735
6736
6737 uint cpu_port_num;
6738 if (cpu.tweaks.l68_mode)
6739 cpu_port_num = (cpu.TPR.CA >> 15) & 07;
6740 else
6741 cpu_port_num = (cpu.TPR.CA >> 15) & 03;
6742 if (! get_scu_in_use (current_running_cpu_idx, cpu_port_num))
6743 {
6744 sim_warn ("rccl on CPU %u port %d has no SCU; faulting\n",
6745 current_running_cpu_idx, cpu_port_num);
6746 doFault (FAULT_ONC, fst_onc_nem, "(rccl)");
6747 }
6748 uint scuUnitIdx = get_scu_idx (current_running_cpu_idx, cpu_port_num);
6749
6750 t_stat rc = scu_rscr ((uint) scuUnitIdx, current_running_cpu_idx,
6751 040, & cpu.rA, & cpu.rQ);
6752 #ifdef TESTING
6753 HDBGRegAW ("rccl");
6754 HDBGRegQW ("rccl");
6755 #endif
6756 if (rc > 0)
6757 return rc;
6758 #ifndef SPEED
6759 if_sim_debug (DBG_TRACEEXT, & cpu_dev)
6760 {
6761
6762
6763
6764 uint64 UnixSecs = 932686778;
6765 uint64 UnixuSecs = UnixSecs * 1000000LL;
6766
6767 uint64 MulticsuSecs = 2177452800000000LL + UnixuSecs;
6768
6769
6770 word72 big = convert_to_word72 (cpu.rA, cpu.rQ);
6771 # ifdef NEED_128
6772
6773 big = subtract_128 (big, construct_128 (0, MulticsuSecs));
6774 uint32_t remainder;
6775 uint128 bigsecs = divide_128_32 (big, 1000000u, & remainder);
6776 uint64_t uSecs = remainder;
6777 uint64_t secs = bigsecs.l;
6778 sim_debug (DBG_TRACEEXT, & cpu_dev,
6779 "Clock time since boot %4llu.%06llu seconds\n",
6780 secs, uSecs);
6781 # else
6782
6783 big -= MulticsuSecs;
6784 unsigned long uSecs = big % 1000000u;
6785 unsigned long secs = (unsigned long) (big / 1000000u);
6786 sim_debug (DBG_TRACEEXT, & cpu_dev,
6787 "Clock time since boot %4lu.%06lu seconds\n",
6788 secs, uSecs);
6789 # endif
6790 }
6791 #endif
6792 }
6793 break;
6794
6795 case x0 (0002):
6796
6797
6798
6799
6800
6801 if (cpu.tweaks.drl_fatal)
6802 {
6803 return STOP_STOP;
6804 }
6805 doFault (FAULT_DRL, fst_zero, "drl");
6806
6807
6808 case x0 (0716):
6809 cpu.cu.xde = 1;
6810 cpu.cu.xdo = 0;
6811
6812
6813
6814 cpu.cu.IWB = cpu.CY;
6815 return CONT_XEC;
6816
6817 case x0 (0717):
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853 cpu.cu.xde = 1;
6854 cpu.cu.xdo = 1;
6855
6856
6857
6858 cpu.cu.IWB = cpu.Ypair[0];
6859 cpu.cu.IRODD = cpu.Ypair[1];
6860 return CONT_XEC;
6861
6862 case x0 (0001):
6863 #ifdef TESTING
6864 if (sim_deb_mme_cntdwn > 0)
6865 sim_deb_mme_cntdwn --;
6866 #endif
6867
6868
6869
6870
6871 doFault (FAULT_MME, fst_zero, "Master Mode Entry (mme)");
6872
6873
6874 case x0 (0004):
6875
6876
6877
6878
6879 doFault (FAULT_MME2, fst_zero, "Master Mode Entry 2 (mme2)");
6880
6881
6882 case x0 (0005):
6883
6884
6885
6886
6887 doFault (FAULT_MME3, fst_zero, "Master Mode Entry 3 (mme3)");
6888
6889
6890 case x0 (0007):
6891
6892
6893
6894
6895 doFault (FAULT_MME4, fst_zero, "Master Mode Entry 4 (mme4)");
6896
6897
6898 case x0 (0011):
6899 break;
6900
6901 case x0 (0012):
6902 break;
6903
6904 case x0 (0013):
6905 break;
6906
6907
6908
6909 case x0 (0560):
6910 {
6911 if ((cpu.PPR.IC & 1) == 0)
6912 doFault (FAULT_IPR, fst_ill_proc, "rpd odd");
6913 cpu.cu.delta = i->tag;
6914
6915 word1 c = (i->address >> 7) & 1;
6916 if (c)
6917 {
6918 cpu.rX[0] = i->address;
6919 #ifdef TESTING
6920 HDBGRegXW (0, "rpd");
6921 #endif
6922 }
6923 cpu.cu.rd = 1;
6924 cpu.cu.repeat_first = 1;
6925 }
6926 break;
6927
6928 case x0 (0500):
6929 {
6930 uint c = (i->address >> 7) & 1;
6931 cpu.cu.delta = i->tag;
6932 if (c)
6933 {
6934 cpu.rX[0] = i->address;
6935 #ifdef TESTING
6936 HDBGRegXW (0, "rpl");
6937 #endif
6938 }
6939 cpu.cu.rl = 1;
6940 cpu.cu.repeat_first = 1;
6941 }
6942 break;
6943
6944 case x0 (0520):
6945 {
6946 uint c = (i->address >> 7) & 1;
6947 cpu.cu.delta = i->tag;
6948 if (c)
6949 {
6950 cpu.rX[0] = i->address;
6951 #ifdef TESTING
6952 HDBGRegXW (0, "rpt");
6953 #endif
6954 }
6955 cpu.cu.rpt = 1;
6956 cpu.cu.repeat_first = 1;
6957 }
6958 break;
6959
6960
6961
6962 case x1 (0754):
6963
6964
6965
6966 CPTUR (cptUseRALR);
6967 cpu.CY = (word36)cpu.rRALR;
6968
6969 break;
6970
6971
6972
6973 case x0 (0550):
6974
6975 CPTUR (cptUseBAR);
6976
6977 cpu.CY = ((((word36) cpu.BAR.BASE) << 9) | cpu.BAR.BOUND) << 18;
6978 cpu.zone = 0777777000000;
6979 cpu.useZone = true;
6980 break;
6981
6982
6983
6984 case x0 (0505):
6985
6986
6987
6988
6989
6990
6991
6992 {
6993 word36 tmp1 = cpu.rA & SIGN36;
6994 word36 tmp36 = (cpu.rA << 3) & DMASK;
6995 word36 tmp36q = tmp36 / cpu.CY;
6996 word36 tmp36r = 0;
6997 if (!tmp1) {
6998 tmp36r = tmp36 - tmp36q * cpu.CY;
6999 } else {
7000
7001
7002
7003
7004
7005
7006 tmp36q += 6;
7007 tmp36r = tmp36 + tmp36q * cpu.CY;
7008 }
7009
7010 cpu.rQ <<= 6;
7011 cpu.rQ &= DMASK;
7012
7013
7014 cpu.rQ |= (tmp36q & 017);
7015 #ifdef TESTING
7016 HDBGRegQW ("bcd");
7017 #endif
7018
7019 cpu.rA = tmp36r & DMASK;
7020 #ifdef TESTING
7021 HDBGRegAW ("bcd");
7022 #endif
7023
7024 SC_I_ZERO (cpu.rA == 0);
7025
7026 SC_I_NEG (tmp1);
7027
7028 }
7029 break;
7030
7031 case x0 (0774):
7032
7033
7034 {
7035 word36 tmp = cpu.rA & MASK36;
7036 word36 mask = SIGN36;
7037
7038 for (int n=1;n<=35;n++) {
7039 tmp ^= (tmp & mask) >> 1;
7040 mask >>= 1;
7041 }
7042
7043 cpu.rA = tmp;
7044 #ifdef TESTING
7045 HDBGRegAW ("gtb");
7046 #endif
7047
7048 SC_I_ZERO (cpu.rA == 0);
7049
7050 SC_I_NEG (cpu.rA & SIGN36);
7051
7052 }
7053 break;
7054
7055
7056
7057 case x0 (0230):
7058
7059 CPTUR (cptUseBAR);
7060
7061 cpu.BAR.BASE = (GETHI (cpu.CY) >> 9) & 0777;
7062
7063 cpu.BAR.BOUND = GETHI (cpu.CY) & 0777;
7064 break;
7065
7066
7067
7068
7069
7070 case x0 (0674):
7071
7072 switch (i->tag)
7073 {
7074
7075
7076
7077 case 02:
7078 {
7079
7080
7081
7082
7083
7084 CPTUR (cptUseCMR);
7085
7086
7087
7088 uint csh1_on = getbits36_1 (cpu.CY, 54 - 36);
7089 uint csh2_on = getbits36_1 (cpu.CY, 55 - 36);
7090
7091
7092 cpu.CMR.csh1_on = (word1) csh1_on;
7093 cpu.CMR.csh2_on = (word1) csh2_on;
7094
7095
7096
7097 L68_ (cpu.CMR.opnd_on = getbits36_1 (cpu.CY, 56 - 36);)
7098 cpu.CMR.inst_on = getbits36_1 (cpu.CY, 57 - 36);
7099 cpu.CMR.csh_reg = getbits36_1 (cpu.CY, 59 - 36);
7100 if (cpu.CMR.csh_reg)
7101 sim_warn ("LCPR set csh_reg\n");
7102
7103
7104
7105 DPS8M_ (cpu.CMR.bypass_cache = getbits36_1 (cpu.CY, 68 - 36);)
7106 cpu.CMR.luf = getbits36_2 (cpu.CY, 70 - 36);
7107 }
7108 break;
7109
7110 case 04:
7111 {
7112 CPTUR (cptUseMR);
7113 cpu.MR.r = cpu.CY;
7114
7115 putbits36_1 (& cpu.MR.r, 32, 0);
7116
7117 putbits36_2 (& cpu.MR.r, 33, 0);
7118 L68_ (
7119 cpu.MR.FFV = getbits36_15 (cpu.CY, 0);
7120 cpu.MR.OC_TRAP = getbits36_1 (cpu.CY, 16);
7121 cpu.MR.ADR_TRAP = getbits36_1 (cpu.CY, 17);
7122 cpu.MR.OPCODE = getbits36_9 (cpu.CY, 18);
7123 cpu.MR.OPCODEX = getbits36_1 (cpu.CY, 27);
7124 )
7125 cpu.MR.sdpap = getbits36_1 (cpu.CY, 20);
7126 cpu.MR.separ = getbits36_1 (cpu.CY, 21);
7127 cpu.MR.hrhlt = getbits36_1 (cpu.CY, 28);
7128 DPS8M_ (cpu.MR.hrxfr = getbits36_1 (cpu.CY, 29);)
7129 cpu.MR.ihr = getbits36_1 (cpu.CY, 30);
7130 cpu.MR.ihrrs = getbits36_1 (cpu.CY, 31);
7131 cpu.MR.emr = getbits36_1 (cpu.CY, 35);
7132 if (! cpu.tweaks.l68_mode)
7133 cpu.MR.hexfp = getbits36_1 (cpu.CY, 33);
7134 else
7135 cpu.MR.hexfp = 0;
7136
7137
7138
7139
7140
7141 if (cpu.MR.hrhlt)
7142 {
7143 for (uint hset = 0; hset < N_HIST_SETS; hset ++)
7144 cpu.history_cyclic[hset] = 0;
7145 }
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158 }
7159 break;
7160
7161 case 03:
7162 {
7163 for (uint i = 0; i < N_HIST_SETS; i ++)
7164 add_history_force (i, 0, 0);
7165
7166
7167
7168
7169
7170 cpu.skip_cu_hist = true;
7171
7172 }
7173 break;
7174
7175 case 07:
7176 {
7177 for (uint i = 0; i < N_HIST_SETS; i ++)
7178 add_history_force (i, MASK36, MASK36);
7179
7180
7181
7182
7183
7184 cpu.skip_cu_hist = true;
7185 }
7186 break;
7187
7188 default:
7189 doFault (FAULT_IPR,
7190 fst_ill_mod,
7191 "lcpr tag invalid");
7192
7193 }
7194 break;
7195
7196 case x0 (0232):
7197 do_ldbr (cpu.Ypair);
7198 break;
7199
7200 case x0 (0637):
7201 CPTUR (cptUseTR);
7202 cpu.rTR = (cpu.CY >> 9) & MASK27;
7203 cpu.rTRticks = 0;
7204 if (cpu.tweaks.isolts_mode)
7205 {
7206 cpu.shadowTR = cpu.TR0 = cpu.rTR;
7207 cpu.rTRlsb = 0;
7208 }
7209 sim_debug (DBG_TRACEEXT, & cpu_dev, "ldt TR %d (%o)\n",
7210 cpu.rTR, cpu.rTR);
7211 #ifdef LOOPTRC
7212 elapsedtime ();
7213 sim_printf (" ldt %d PSR:IC %05o:%06o\r\n", cpu.rTR, cpu.PPR.PSR, cpu.PPR.IC);
7214 #endif
7215
7216
7217
7218
7219 clearTROFault ();
7220 break;
7221
7222 case x1 (0257):
7223
7224 if (cpu.tweaks.l68_mode) {
7225
7226
7227
7228
7229
7230
7231 for (uint i = 0; i < 16; i ++)
7232 {
7233 word4 m = cpu.PTWAM[i].USE;
7234 cpu.PTWAM[m].POINTER = getbits36_15 (cpu.Yblock16[i], 0);
7235 cpu.PTWAM[m].PAGENO = getbits36_12 (cpu.Yblock16[i], 15);
7236 cpu.PTWAM[m].FE = getbits36_1 (cpu.Yblock16[i], 27);
7237 }
7238 }
7239 break;
7240
7241 case x1 (0173):
7242 if (cpu.tweaks.l68_mode) {
7243
7244
7245
7246
7247 for (uint i = 0; i < 16; i ++)
7248 {
7249 word4 m = cpu.PTWAM[i].USE;
7250 cpu.PTWAM[m].ADDR = getbits36_18 (cpu.Yblock16[i], 0);
7251 cpu.PTWAM[m].M = getbits36_1 (cpu.Yblock16[i], 29);
7252 }
7253 }
7254 break;
7255
7256 case x1 (0774):
7257 CPTUR (cptUseRALR);
7258 cpu.rRALR = cpu.CY & MASK3;
7259 sim_debug (DBG_TRACEEXT, & cpu_dev, "RALR set to %o\n", cpu.rRALR);
7260 #ifdef LOOPTRC
7261 {
7262 void elapsedtime (void);
7263 elapsedtime ();
7264 sim_printf (" RALR set to %o PSR:IC %05o:%06o\r\n", cpu.rRALR, cpu.PPR.PSR, cpu.PPR.IC);
7265 }
7266 #endif
7267 break;
7268
7269 case x0 (0257):
7270 if (cpu.tweaks.l68_mode) {
7271
7272
7273
7274
7275 for (uint i = 0; i < 16; i ++)
7276 {
7277 word4 m = cpu.SDWAM[i].USE;
7278 cpu.SDWAM[m].POINTER = getbits36_15 (cpu.Yblock16[i], 0);
7279 cpu.SDWAM[m].FE = getbits36_1 (cpu.Yblock16[i], 27);
7280 }
7281 }
7282 break;
7283
7284 case x1 (0232):
7285 if (cpu.tweaks.l68_mode) {
7286
7287
7288
7289
7290
7291
7292
7293 for (uint i = 0; i < 16; i ++)
7294 {
7295 word4 m = cpu.SDWAM[i].USE;
7296 uint j = (uint)m * 2;
7297 cpu.SDWAM[m].ADDR = getbits36_24 (cpu.Yblock32[j], 0);
7298 cpu.SDWAM[m].R1 = getbits36_3 (cpu.Yblock32[j], 24);
7299 cpu.SDWAM[m].R2 = getbits36_3 (cpu.Yblock32[j], 27);
7300 cpu.SDWAM[m].R3 = getbits36_3 (cpu.Yblock32[j], 30);
7301
7302 cpu.SDWAM[m].BOUND = getbits36_14 (cpu.Yblock32[j + 1], 37 - 36);
7303 cpu.SDWAM[m].R = getbits36_1 (cpu.Yblock32[j + 1], 51 - 36);
7304 cpu.SDWAM[m].E = getbits36_1 (cpu.Yblock32[j + 1], 52 - 36);
7305 cpu.SDWAM[m].W = getbits36_1 (cpu.Yblock32[j + 1], 53 - 36);
7306 cpu.SDWAM[m].P = getbits36_1 (cpu.Yblock32[j + 1], 54 - 36);
7307 cpu.SDWAM[m].U = getbits36_1 (cpu.Yblock32[j + 1], 55 - 36);
7308 cpu.SDWAM[m].G = getbits36_1 (cpu.Yblock32[j + 1], 56 - 36);
7309 cpu.SDWAM[m].C = getbits36_1 (cpu.Yblock32[j + 1], 57 - 36);
7310 cpu.SDWAM[m].EB = getbits36_14 (cpu.Yblock32[j + 1], 58 - 36);
7311 }
7312 }
7313 break;
7314
7315 case x0 (0613):
7316 doRCU ();
7317
7318
7319
7320
7321 case x0 (0452):
7322 {
7323 uint tag = (i->tag) & MASK6;
7324 switch (tag)
7325 {
7326 case 000:
7327 {
7328 uint reg = cpu.tweaks.l68_mode ? L68_APU_HIST_REG : DPS8M_APU_HIST_REG;
7329 cpu.Ypair[0] = cpu.history[reg] [cpu.history_cyclic[reg]][0];
7330 cpu.Ypair[1] = cpu.history[reg] [cpu.history_cyclic[reg]][1];
7331 cpu.history_cyclic[reg] = (cpu.history_cyclic[reg] + 1) % N_MODEL_HIST_SIZE;
7332 }
7333 break;
7334
7335 case 001:
7336
7337 {
7338 CPTUR (cptUseFR);
7339 cpu.Ypair[0] = cpu.faultRegister[0];
7340 cpu.Ypair[1] = cpu.faultRegister[1];
7341 cpu.faultRegister[0] = 0;
7342 cpu.faultRegister[1] = 0;
7343 }
7344 break;
7345
7346 case 006:
7347
7348 {
7349 CPTUR (cptUseMR);
7350 cpu.Ypair[0] = cpu.MR.r;
7351 putbits36_1 (& cpu.Ypair[0], 20, cpu.MR.sdpap);
7352 putbits36_1 (& cpu.Ypair[0], 21, cpu.MR.separ);
7353 putbits36_1 (& cpu.Ypair[0], 30, cpu.MR.ihr);
7354 DPS8M_ (putbits36_1 (& cpu.Ypair[0], 33, cpu.MR.hexfp);)
7355 CPTUR (cptUseCMR);
7356 cpu.Ypair[1] = 0;
7357 putbits36_15 (& cpu.Ypair[1], 36 - 36,
7358 cpu.CMR.cache_dir_address);
7359 putbits36_1 (& cpu.Ypair[1], 51 - 36, cpu.CMR.par_bit);
7360 putbits36_1 (& cpu.Ypair[1], 52 - 36, cpu.CMR.lev_ful);
7361 putbits36_1 (& cpu.Ypair[1], 54 - 36, cpu.CMR.csh1_on);
7362 putbits36_1 (& cpu.Ypair[1], 55 - 36, cpu.CMR.csh2_on);
7363 L68_ (putbits36_1 (& cpu.Ypair[1], 56 - 36, cpu.CMR.opnd_on);)
7364 putbits36_1 (& cpu.Ypair[1], 57 - 36, cpu.CMR.inst_on);
7365 putbits36_1 (& cpu.Ypair[1], 59 - 36, cpu.CMR.csh_reg);
7366 putbits36_1 (& cpu.Ypair[1], 60 - 36, cpu.CMR.str_asd);
7367 putbits36_1 (& cpu.Ypair[1], 61 - 36, cpu.CMR.col_ful);
7368 putbits36_2 (& cpu.Ypair[1], 62 - 36, cpu.CMR.rro_AB);
7369 DPS8M_ (putbits36_1 (& cpu.Ypair[1], 68 - 36, cpu.CMR.bypass_cache);)
7370 putbits36_2 (& cpu.Ypair[1], 70 - 36, cpu.CMR.luf);
7371 }
7372 break;
7373
7374 case 010:
7375 {
7376 uint reg = cpu.tweaks.l68_mode ? L68_DU_HIST_REG : DPS8M_EAPU_HIST_REG;
7377 cpu.Ypair[0] = cpu.history[reg] [cpu.history_cyclic[reg]][0];
7378 cpu.Ypair[1] = cpu.history[reg] [cpu.history_cyclic[reg]][1];
7379 cpu.history_cyclic[reg] = (cpu.history_cyclic[reg] + 1) % N_MODEL_HIST_SIZE;
7380 }
7381 break;
7382
7383 case 020:
7384 {
7385 cpu.Ypair[0] =
7386 cpu.history[CU_HIST_REG]
7387 [cpu.history_cyclic[CU_HIST_REG]][0];
7388 cpu.Ypair[1] =
7389 cpu.history[CU_HIST_REG]
7390 [cpu.history_cyclic[CU_HIST_REG]][1];
7391 cpu.history_cyclic[CU_HIST_REG] =
7392 (cpu.history_cyclic[CU_HIST_REG] + 1) % N_MODEL_HIST_SIZE;
7393 }
7394 break;
7395
7396 case 040:
7397 {
7398 uint reg = cpu.tweaks.l68_mode ? L68_OU_HIST_REG : DPS8M_DU_OU_HIST_REG;
7399 cpu.Ypair[0] = cpu.history[reg] [cpu.history_cyclic[reg]][0];
7400 cpu.Ypair[1] = cpu.history[reg] [cpu.history_cyclic[reg]][1];
7401 cpu.history_cyclic[reg] = (cpu.history_cyclic[reg] + 1) % N_MODEL_HIST_SIZE;
7402 }
7403 break;
7404
7405 default:
7406 {
7407 doFault (FAULT_IPR,
7408 fst_ill_mod,
7409 "SCPR Illegal register select value");
7410 }
7411 }
7412 }
7413 break;
7414
7415 case x0 (0657):
7416
7417
7418
7419
7420
7421 if (cpu.cycle == EXEC_cycle)
7422 {
7423
7424
7425
7426
7427
7428
7429 scu2words (cpu.Yblock8);
7430 }
7431 else
7432 {
7433
7434 for (int j = 0; j < 8; j ++)
7435 cpu.Yblock8[j] = cpu.scu_data[j];
7436 }
7437 break;
7438
7439 case x0 (0154):
7440 {
7441 CPTUR (cptUseDSBR);
7442
7443
7444 cpu.Ypair[0] = ((word36) (cpu.DSBR.ADDR & PAMASK)) << (35 - 23);
7445
7446
7447
7448
7449
7450
7451 cpu.Ypair[1] = ((word36) (cpu.DSBR.BND & 037777)) << (71 - 50) |
7452 ((word36) (cpu.DSBR.U & 1)) << (71 - 55) |
7453 ((word36) (cpu.DSBR.STACK & 07777)) << (71 - 71);
7454 }
7455 break;
7456
7457 case x1 (0557):
7458 {
7459
7460
7461
7462 uint level;
7463 L68_ (level = 0;)
7464 DPS8M_ (level = (cpu.TPR.CA >> 4) & 03;)
7465 uint toffset = level * 16;
7466 for (uint j = 0; j < 16; j ++)
7467 {
7468 cpu.Yblock16[j] = 0;
7469 putbits36_15 (& cpu.Yblock16[j], 0,
7470 cpu.PTWAM[toffset + j].POINTER);
7471 DPS8M_ (
7472 putbits36_12 (& cpu.Yblock16[j], 15, cpu.PTWAM[toffset + j].PAGENO & 07760);
7473
7474 uint parity = 0;
7475 if (cpu.PTWAM[toffset + j].FE) {
7476
7477
7478 parity = ((uint) cpu.PTWAM[toffset + j].POINTER << 4) | (cpu.PTWAM[toffset + j].PAGENO >> 8);
7479 parity = parity ^ (parity >>16);
7480 parity = parity ^ (parity >> 8);
7481 parity = parity ^ (parity >> 4);
7482 parity = ~ (0x6996u >> (parity & 0xf));
7483 }
7484 putbits36_1 (& cpu.Yblock16[j], 23, (word1) (parity & 1));
7485 )
7486 L68_ (putbits36_12 (& cpu.Yblock16[j], 15, cpu.PTWAM[toffset + j].PAGENO); )
7487 putbits36_1 (& cpu.Yblock16[j], 27,
7488 cpu.PTWAM[toffset + j].FE);
7489 DPS8M_ (putbits36_6 (& cpu.Yblock16[j], 30, cpu.PTWAM[toffset + j].USE);)
7490 L68_ (putbits36_4 (& cpu.Yblock16[j], 32, cpu.PTWAM[toffset + j].USE);)
7491 }
7492 }
7493 break;
7494
7495 case x1 (0154):
7496 {
7497
7498
7499
7500
7501 uint level;
7502 DPS8M_ (level = (cpu.TPR.CA >> 4) & 03;)
7503 L68_ (level = 0;)
7504 uint toffset = level * 16;
7505 for (uint j = 0; j < 16; j ++)
7506 {
7507 cpu.Yblock16[j] = 0;
7508 DPS8M_ (putbits36_18 (& cpu.Yblock16[j], 0, cpu.PTWAM[toffset + j].ADDR & 0777760);)
7509 L68_ (putbits36_18 (& cpu.Yblock16[j], 0, cpu.PTWAM[toffset + j].ADDR);)
7510 putbits36_1 (& cpu.Yblock16[j], 29,
7511 cpu.PTWAM[toffset + j].M);
7512 }
7513 }
7514 break;
7515
7516 case x0 (0557):
7517 {
7518
7519
7520
7521 uint level;
7522 DPS8M_ (level = (cpu.TPR.CA >> 4) & 03;)
7523 L68_ (level = 0;)
7524 uint toffset = level * 16;
7525 for (uint j = 0; j < 16; j ++)
7526 {
7527 cpu.Yblock16[j] = 0;
7528 putbits36_15 (& cpu.Yblock16[j], 0,
7529 cpu.SDWAM[toffset + j].POINTER);
7530 putbits36_1 (& cpu.Yblock16[j], 27,
7531 cpu.SDWAM[toffset + j].FE);
7532 DPS8M_ (
7533 uint parity = 0;
7534 if (cpu.SDWAM[toffset + j].FE) {
7535
7536
7537 parity = cpu.SDWAM[toffset + j].POINTER >> 4;
7538
7539 parity = parity ^ (parity >> 8);
7540 parity = parity ^ (parity >> 4);
7541 parity = ~ (0x6996u >> (parity & 0xf));
7542 }
7543 putbits36_1 (& cpu.Yblock16[j], 15, (word1) (parity & 1));
7544
7545 putbits36_6 (& cpu.Yblock16[j], 30, cpu.SDWAM[toffset + j].USE);
7546 )
7547 L68_ (putbits36_4 (& cpu.Yblock16[j], 32, cpu.SDWAM[toffset + j].USE);)
7548 }
7549 }
7550 break;
7551
7552 case x1 (0254):
7553 {
7554
7555
7556
7557
7558
7559 uint level = 0;
7560 DPS8M_ (level = (cpu.TPR.CA >> 5) & 03;)
7561 L68_ (level = 0;)
7562 uint toffset = level * 16;
7563 for (uint j = 0; j < 16; j ++)
7564 {
7565 cpu.Yblock32[j * 2] = 0;
7566 putbits36_24 (& cpu.Yblock32[j * 2], 0,
7567 cpu.SDWAM[toffset + j].ADDR);
7568 putbits36_3 (& cpu.Yblock32[j * 2], 24,
7569 cpu.SDWAM[toffset + j].R1);
7570 putbits36_3 (& cpu.Yblock32[j * 2], 27,
7571 cpu.SDWAM[toffset + j].R2);
7572 putbits36_3 (& cpu.Yblock32[j * 2], 30,
7573 cpu.SDWAM[toffset + j].R3);
7574 cpu.Yblock32[j * 2 + 1] = 0;
7575
7576 putbits36_14 (& cpu.Yblock32[j * 2 + 1], 37 - 36,
7577 cpu.SDWAM[toffset + j].BOUND);
7578 putbits36_1 (& cpu.Yblock32[j * 2 + 1], 51 - 36,
7579 cpu.SDWAM[toffset + j].R);
7580 putbits36_1 (& cpu.Yblock32[j * 2 + 1], 52 - 36,
7581 cpu.SDWAM[toffset + j].E);
7582 putbits36_1 (& cpu.Yblock32[j * 2 + 1], 53 - 36,
7583 cpu.SDWAM[toffset + j].W);
7584 putbits36_1 (& cpu.Yblock32[j * 2 + 1], 54 - 36,
7585 cpu.SDWAM[toffset + j].P);
7586 putbits36_1 (& cpu.Yblock32[j * 2 + 1], 55 - 36,
7587 cpu.SDWAM[toffset + j].U);
7588 putbits36_1 (& cpu.Yblock32[j * 2 + 1], 56 - 36,
7589 cpu.SDWAM[toffset + j].G);
7590 putbits36_1 (& cpu.Yblock32[j * 2 + 1], 57 - 36,
7591 cpu.SDWAM[toffset + j].C);
7592 putbits36_14 (& cpu.Yblock32[j * 2 + 1], 58 - 36,
7593 cpu.SDWAM[toffset + j].EB);
7594 }
7595 }
7596 break;
7597
7598
7599
7600 case x1 (0532):
7601 {
7602
7603
7604
7605
7606
7607 if (cpu.tweaks.enable_wam)
7608 {
7609 if (cpu.tweaks.l68_mode || cpu.cu.PT_ON)
7610 for (uint i = 0; i < N_MODEL_WAM_ENTRIES; i ++)
7611 {
7612 cpu.PTWAM[i].FE = 0;
7613 L68_ (cpu.PTWAM[i].USE = (word4) i;)
7614 DPS8M_ (cpu.PTWAM[i].USE = 0;)
7615 }
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628 DPS8M_ (if (cpu.TPR.CA != 0000002 && (cpu.TPR.CA & 3) != 0)
7629 sim_warn ("CAMP ignores enable/disable %06o\n", cpu.TPR.CA);)
7630 if ((cpu.TPR.CA & 3) == 02)
7631 cpu.cu.PT_ON = 1;
7632 else if ((cpu.TPR.CA & 3) == 01)
7633 cpu.cu.PT_ON = 0;
7634 }
7635 else
7636 {
7637 cpu.PTW0.FE = 0;
7638 cpu.PTW0.USE = 0;
7639 }
7640 }
7641 break;
7642
7643 case x0 (0532):
7644 {
7645
7646
7647
7648
7649
7650
7651
7652 if (cpu.tweaks.enable_wam)
7653 {
7654 if (cpu.tweaks.l68_mode || cpu.cu.SD_ON)
7655 for (uint i = 0; i < N_MODEL_WAM_ENTRIES; i ++)
7656 {
7657 cpu.SDWAM[i].FE = 0;
7658 L68_ (cpu.SDWAM[i].USE = (word4) i;)
7659 DPS8M_ (cpu.SDWAM[i].USE = 0;)
7660 }
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672 DPS8M_ (if (cpu.TPR.CA != 0000006 && (cpu.TPR.CA & 3) != 0)
7673 sim_warn ("CAMS ignores enable/disable %06o\n", cpu.TPR.CA);)
7674 if ((cpu.TPR.CA & 3) == 02)
7675 cpu.cu.SD_ON = 1;
7676 else if ((cpu.TPR.CA & 3) == 01)
7677 cpu.cu.SD_ON = 0;
7678 }
7679 else
7680 {
7681 cpu.SDW0.FE = 0;
7682 cpu.SDW0.USE = 0;
7683 }
7684 }
7685 break;
7686
7687
7688
7689 case x0 (0233):
7690 {
7691
7692
7693
7694 uint cpu_port_num;
7695 DPS8M_ (cpu_port_num = (cpu.TPR.CA >> 15) & 03;)
7696 L68_ (cpu_port_num = (cpu.TPR.CA >> 15) & 07;)
7697 if (! get_scu_in_use (current_running_cpu_idx, cpu_port_num))
7698 {
7699 sim_warn ("rmcm to non-existent controller on "
7700 "cpu %d port %d\n",
7701 current_running_cpu_idx, cpu_port_num);
7702 break;
7703 }
7704 uint scuUnitIdx = get_scu_idx (current_running_cpu_idx, cpu_port_num);
7705 t_stat rc = scu_rmcm ((uint) scuUnitIdx,
7706 current_running_cpu_idx,
7707 & cpu.rA, & cpu.rQ);
7708 #ifdef TESTING
7709 HDBGRegAW ("rmcm");
7710 HDBGRegQW ("rmcm");
7711 #endif
7712 if (rc)
7713 return rc;
7714 SC_I_ZERO (cpu.rA == 0);
7715 SC_I_NEG (cpu.rA & SIGN36);
7716 }
7717 break;
7718
7719 case x0 (0413):
7720 {
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753 uint cpu_port_num;
7754 DPS8M_ (cpu_port_num = (cpu.TPR.CA >> 10) & 03;)
7755 L68_ (cpu_port_num = (cpu.TPR.CA >> 10) & 07;)
7756
7757
7758
7759 if (! get_scu_in_use (current_running_cpu_idx, cpu_port_num))
7760 {
7761
7762
7763
7764 if (cpu_port_num == 0)
7765 putbits36 (& cpu.faultRegister[0], 16, 4, 010);
7766 else if (cpu_port_num == 1)
7767 putbits36 (& cpu.faultRegister[0], 20, 4, 010);
7768 else if (cpu_port_num == 2)
7769 putbits36 (& cpu.faultRegister[0], 24, 4, 010);
7770 else
7771 putbits36 (& cpu.faultRegister[0], 28, 4, 010);
7772
7773 doFault (FAULT_CMD, fst_cmd_ctl, "(rscr)");
7774 }
7775 uint scuUnitIdx = get_scu_idx (current_running_cpu_idx, cpu_port_num);
7776 #ifdef PANEL68
7777 {
7778 uint function = (cpu.iefpFinalAddress >> 3) & 07;
7779 CPT (cpt13L, function);
7780 }
7781 #endif
7782 t_stat rc = scu_rscr ((uint) scuUnitIdx, current_running_cpu_idx,
7783 cpu.iefpFinalAddress & MASK15,
7784 & cpu.rA, & cpu.rQ);
7785 #ifdef TESTING
7786 HDBGRegAW ("rscr");
7787 HDBGRegQW ("rscr");
7788 #endif
7789 if (rc)
7790 return rc;
7791 }
7792 break;
7793
7794 case x0 (0231):
7795 {
7796 if (! cpu.tweaks.l68_mode) {
7797 word6 rTAG = GET_TAG (IWB_IRODD);
7798 word6 Td = GET_TD (rTAG);
7799 word6 Tm = GET_TM (rTAG);
7800 if (Tm == TM_R && Td == TD_DL)
7801 {
7802 unsigned char PROM[1024];
7803 setupPROM (current_running_cpu_idx, PROM);
7804 cpu.rA = PROM[cpu.TPR.CA & 1023];
7805 break;
7806 }
7807 }
7808 uint select = cpu.TPR.CA & 0x7;
7809 switch (select)
7810 {
7811 case 0:
7812 cpu.rA = cpu.switches.data_switches;
7813 break;
7814
7815 case 1:
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842 cpu.rA = 0;
7843 cpu.rA |= (word36) (cpu.switches.assignment [0] & 07LL)
7844 << (35 - (2 + 0));
7845 cpu.rA |= (word36) (cpu.switches.enable [0] & 01LL)
7846 << (35 - (3 + 0));
7847 cpu.rA |= (word36) (cpu.switches.init_enable [0] & 01LL)
7848 << (35 - (4 + 0));
7849 cpu.rA |= (word36) (cpu.switches.interlace [0] ? 1LL:0LL)
7850 << (35 - (5 + 0));
7851 cpu.rA |= (word36) (cpu.switches.store_size [0] & 07LL)
7852 << (35 - (8 + 0));
7853
7854 cpu.rA |= (word36) (cpu.switches.assignment [1] & 07LL)
7855 << (35 - (2 + 9));
7856 cpu.rA |= (word36) (cpu.switches.enable [1] & 01LL)
7857 << (35 - (3 + 9));
7858 cpu.rA |= (word36) (cpu.switches.init_enable [1] & 01LL)
7859 << (35 - (4 + 9));
7860 cpu.rA |= (word36) (cpu.switches.interlace [1] ? 1LL:0LL)
7861 << (35 - (5 + 9));
7862 cpu.rA |= (word36) (cpu.switches.store_size [1] & 07LL)
7863 << (35 - (8 + 9));
7864
7865 cpu.rA |= (word36) (cpu.switches.assignment [2] & 07LL)
7866 << (35 - (2 + 18));
7867 cpu.rA |= (word36) (cpu.switches.enable [2] & 01LL)
7868 << (35 - (3 + 18));
7869 cpu.rA |= (word36) (cpu.switches.init_enable [2] & 01LL)
7870 << (35 - (4 + 18));
7871 cpu.rA |= (word36) (cpu.switches.interlace [2] ? 1LL:0LL)
7872 << (35 - (5 + 18));
7873 cpu.rA |= (word36) (cpu.switches.store_size [2] & 07LL)
7874 << (35 - (8 + 18));
7875
7876 cpu.rA |= (word36) (cpu.switches.assignment [3] & 07LL)
7877 << (35 - (2 + 27));
7878 cpu.rA |= (word36) (cpu.switches.enable [3] & 01LL)
7879 << (35 - (3 + 27));
7880 cpu.rA |= (word36) (cpu.switches.init_enable [3] & 01LL)
7881 << (35 - (4 + 27));
7882 cpu.rA |= (word36) (cpu.switches.interlace [3] ? 1LL:0LL)
7883 << (35 - (5 + 27));
7884 cpu.rA |= (word36) (cpu.switches.store_size [3] & 07LL)
7885 << (35 - (8 + 27));
7886 break;
7887
7888 case 2:
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955 cpu.rA = 0;
7956 DPS8M_ (
7957 cpu.rA |= (word36) ((cpu.switches.interlace[0] == 2 ?
7958 1LL : 0LL) << (35- 0));
7959 cpu.rA |= (word36) ((cpu.switches.interlace[1] == 2 ?
7960 1LL : 0LL) << (35- 1));
7961 cpu.rA |= (word36) ((cpu.switches.interlace[2] == 2 ?
7962 1LL : 0LL) << (35- 2));
7963 cpu.rA |= (word36) ((cpu.switches.interlace[3] == 2 ?
7964 1LL : 0LL) << (35- 3));
7965 )
7966
7967 if (cpu.tweaks.l68_mode)
7968
7969
7970
7971 ;
7972 else
7973 cpu.rA |= (word36) ((01L)
7974 << (35- 5));
7975 cpu.rA |= (word36) ((cpu.switches.FLT_BASE & 0177LL)
7976 << (35-12));
7977 DPS8M_ (cpu.rA |= (word36) ((01L)
7978 << (35-13));)
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988 if (cpu.tweaks.l68_mode)
7989
7990
7991
7992 ;
7993 else
7994 cpu.rA |= (word36) ((01L)
7995 << (35-19));
7996 DPS8M_ (
7997
7998
7999
8000 cpu.rA |= (word36) ((cpu.switches.enable_cache ? 1 : 0)
8001 << (35-20));
8002
8003
8004
8005 cpu.rA |= (word36) ((cpu.switches.procMode)
8006 << (35-23));
8007 cpu.rA |= (word36) ((cpu.switches.procMode & 1U)
8008 << (35-24));
8009
8010
8011
8012
8013
8014
8015 cpu.rA |= (word36) ((cpu.options.proc_speed & 017LL)
8016 << (35-32));
8017 )
8018
8019 L68_ (
8020
8021
8022
8023
8024
8025
8026 cpu.rA |= (word36) ((016L)
8027 << (35-32));
8028 )
8029 cpu.rA |= (word36) ((cpu.switches.cpu_num & 07LL)
8030 << (35-35));
8031 break;
8032
8033 case 3:
8034 if (!cpu.tweaks.l68_mode) {
8035 cpu.rA = 0;
8036 break;
8037 }
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065 cpu.rA = 0;
8066 cpu.rA |= (word36) (cpu.switches.assignment [4] & 07LL)
8067 << (35 - (2 + 0));
8068 cpu.rA |= (word36) (cpu.switches.enable [4] & 01LL)
8069 << (35 - (3 + 0));
8070 cpu.rA |= (word36) (cpu.switches.init_enable [4] & 01LL)
8071 << (35 - (4 + 0));
8072 cpu.rA |= (word36) (cpu.switches.interlace [4] ? 1LL:0LL)
8073 << (35 - (5 + 0));
8074 cpu.rA |= (word36) (cpu.switches.store_size [4] & 07LL)
8075 << (35 - (8 + 0));
8076
8077 cpu.rA |= (word36) (cpu.switches.assignment [5] & 07LL)
8078 << (35 - (2 + 9));
8079 cpu.rA |= (word36) (cpu.switches.enable [5] & 01LL)
8080 << (35 - (3 + 9));
8081 cpu.rA |= (word36) (cpu.switches.init_enable [5] & 01LL)
8082 << (35 - (4 + 9));
8083 cpu.rA |= (word36) (cpu.switches.interlace [5] ? 1LL:0LL)
8084 << (35 - (5 + 9));
8085 cpu.rA |= (word36) (cpu.switches.store_size [5] & 07LL)
8086 << (35 - (8 + 9));
8087
8088 cpu.rA |= (word36) (cpu.switches.assignment [6] & 07LL)
8089 << (35 - (2 + 18));
8090 cpu.rA |= (word36) (cpu.switches.enable [6] & 01LL)
8091 << (35 - (3 + 18));
8092 cpu.rA |= (word36) (cpu.switches.init_enable [6] & 01LL)
8093 << (35 - (4 + 18));
8094 cpu.rA |= (word36) (cpu.switches.interlace [6] ? 1LL:0LL)
8095 << (35 - (5 + 18));
8096 cpu.rA |= (word36) (cpu.switches.store_size [6] & 07LL)
8097 << (35 - (8 + 18));
8098
8099 cpu.rA |= (word36) (cpu.switches.assignment [7] & 07LL)
8100 << (35 - (2 + 27));
8101 cpu.rA |= (word36) (cpu.switches.enable [7] & 01LL)
8102 << (35 - (3 + 27));
8103 cpu.rA |= (word36) (cpu.switches.init_enable [7] & 01LL)
8104 << (35 - (4 + 27));
8105 cpu.rA |= (word36) (cpu.switches.interlace [7] ? 1LL:0LL)
8106 << (35 - (5 + 27));
8107 cpu.rA |= (word36) (cpu.switches.store_size [7] & 07LL)
8108 << (35 - (8 + 27));
8109 break;
8110
8111 case 4:
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127 cpu.rA = 0;
8128 cpu.rA |= (word36) (cpu.switches.interlace [0] == 2 ?
8129 1LL : 0LL) << (35-13);
8130 cpu.rA |= (word36) (cpu.switches.interlace [1] == 2 ?
8131 1LL : 0LL) << (35-15);
8132 cpu.rA |= (word36) (cpu.switches.interlace [2] == 2 ?
8133 1LL : 0LL) << (35-17);
8134 cpu.rA |= (word36) (cpu.switches.interlace [3] == 2 ?
8135 1LL : 0LL) << (35-19);
8136 L68_ (
8137 cpu.rA |= (word36) (cpu.switches.interlace [4] == 2 ?
8138 1LL : 0LL) << (35-21);
8139 cpu.rA |= (word36) (cpu.switches.interlace [5] == 2 ?
8140 1LL : 0LL) << (35-23);
8141 cpu.rA |= (word36) (cpu.switches.interlace [6] == 2 ?
8142 1LL : 0LL) << (35-25);
8143 cpu.rA |= (word36) (cpu.switches.interlace [7] == 2 ?
8144 1LL : 0LL) << (35-27);
8145 )
8146 break;
8147
8148 default:
8149
8150 doFault (FAULT_IPR,
8151 fst_ill_mod,
8152 "Illegal register select value");
8153 }
8154 #ifdef TESTING
8155 HDBGRegAW ("rsw");
8156 #endif
8157 SC_I_ZERO (cpu.rA == 0);
8158 SC_I_NEG (cpu.rA & SIGN36);
8159 }
8160 break;
8161
8162
8163
8164 case x0 (0015):
8165 {
8166
8167
8168
8169 int cpu_port_num = lookup_cpu_mem_map (cpu.iefpFinalAddress);
8170
8171 if (cpu_port_num < 0)
8172 {
8173 doFault (FAULT_ONC, fst_onc_nem, "(cioc)");
8174 }
8175 if (! get_scu_in_use (current_running_cpu_idx, cpu_port_num))
8176 {
8177 doFault (FAULT_ONC, fst_onc_nem, "(cioc)");
8178 }
8179 uint scuUnitIdx = get_scu_idx (current_running_cpu_idx, cpu_port_num);
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193 word8 sub_mask = getbits36_8 (cpu.CY, 0);
8194 word3 expander_command = getbits36_3 (cpu.CY, 21);
8195 uint scu_port_num = (uint) getbits36_3 (cpu.CY, 33);
8196 scu_cioc (current_running_cpu_idx, (uint) scuUnitIdx, scu_port_num,
8197 expander_command, sub_mask);
8198 }
8199 break;
8200
8201 case x0 (0553):
8202 {
8203
8204
8205
8206 uint cpu_port_num;
8207 DPS8M_ (cpu_port_num = (cpu.TPR.CA >> 15) & 03;)
8208 L68_ (cpu_port_num = (cpu.TPR.CA >> 15) & 07;)
8209 if (! get_scu_in_use (current_running_cpu_idx, cpu_port_num))
8210 {
8211 sim_warn ("smcm to non-existent controller on "
8212 "cpu %d port %d\n",
8213 current_running_cpu_idx, cpu_port_num);
8214 break;
8215 }
8216 uint scuUnitIdx = get_scu_idx (current_running_cpu_idx, cpu_port_num);
8217 t_stat rc = scu_smcm ((uint) scuUnitIdx,
8218 current_running_cpu_idx, cpu.rA, cpu.rQ);
8219 if (rc)
8220 return rc;
8221 }
8222 break;
8223
8224 case x0 (0451):
8225 {
8226
8227
8228
8229
8230
8231
8232
8233
8234 uint cpu_port_num;
8235 DPS8M_ (cpu_port_num = (cpu.TPR.CA >> 15) & 03;)
8236 L68_ (cpu_port_num = (cpu.TPR.CA >> 15) & 07;)
8237 if (! get_scu_in_use (current_running_cpu_idx, cpu_port_num))
8238 {
8239 DPS8M_ (return SCPE_OK;)
8240
8241
8242 if (cpu_port_num == 0)
8243 putbits36_4 (& cpu.faultRegister[0], 16, 010);
8244 else if (cpu_port_num == 1)
8245 putbits36_4 (& cpu.faultRegister[0], 20, 010);
8246 else if (cpu_port_num == 2)
8247 putbits36_4 (& cpu.faultRegister[0], 24, 010);
8248 else if (cpu_port_num == 3)
8249 putbits36 (& cpu.faultRegister[0], 28, 4, 010);
8250
8251 doFault (FAULT_CMD, fst_cmd_ctl, "(smic)");
8252 }
8253 uint scuUnitIdx = get_scu_idx (current_running_cpu_idx, cpu_port_num);
8254 t_stat rc = scu_smic ((uint) scuUnitIdx, current_running_cpu_idx,
8255 cpu_port_num, cpu.rA);
8256 if (rc)
8257 return rc;
8258 }
8259 break;
8260
8261 case x0 (0057):
8262 {
8263
8264
8265 uint cpu_port_num;
8266 DPS8M_ (cpu_port_num = (cpu.TPR.CA >> 10) & 03;)
8267 L68_ (cpu_port_num = (cpu.TPR.CA >> 10) & 07;)
8268 if (! get_scu_in_use (current_running_cpu_idx, cpu_port_num))
8269 {
8270
8271 if (cpu_port_num == 0)
8272 putbits36_4 (& cpu.faultRegister[0], 16, 010);
8273 else if (cpu_port_num == 1)
8274 putbits36_4 (& cpu.faultRegister[0], 20, 010);
8275 else if (cpu_port_num == 2)
8276 putbits36_4 (& cpu.faultRegister[0], 24, 010);
8277 else
8278 putbits36 (& cpu.faultRegister[0], 28, 4, 010);
8279 doFault (FAULT_CMD, fst_cmd_ctl, "(sscr)");
8280 }
8281 uint scuUnitIdx = get_scu_idx (current_running_cpu_idx, cpu_port_num);
8282 t_stat rc = scu_sscr ((uint) scuUnitIdx, current_running_cpu_idx,
8283 cpu_port_num, cpu.iefpFinalAddress & MASK15,
8284 cpu.rA, cpu.rQ);
8285
8286 if (rc)
8287 return rc;
8288 }
8289 break;
8290
8291
8292
8293 case x0 (0212):
8294 {
8295 word36 result;
8296 int rc = doABSA (& result);
8297 if (rc)
8298 return rc;
8299 cpu.rA = result;
8300 #ifdef TESTING
8301 HDBGRegAW ("absa");
8302 #endif
8303 SC_I_ZERO (cpu.rA == 0);
8304 SC_I_NEG (cpu.rA & SIGN36);
8305 }
8306 break;
8307
8308 case x0 (0616):
8309
8310 if (! cpu.tweaks.dis_enable)
8311 {
8312 return STOP_STOP;
8313 }
8314
8315
8316
8317
8318
8319
8320 advanceG7Faults ();
8321
8322 if ((! cpu.tweaks.tro_enable) &&
8323 (! sample_interrupts ()) &&
8324 (sim_qcount () == 0))
8325
8326 {
8327 sim_printf ("DIS@0%06o with no interrupts pending and"
8328 " no events in queue\n", cpu.PPR.IC);
8329 #ifdef WIN_STDIO
8330 sim_printf ("\nCycles = %llu\n",
8331 #else
8332 sim_printf ("\nCycles = %'llu\n",
8333 #endif
8334 (unsigned long long)cpu.cycleCnt);
8335 #ifdef WIN_STDIO
8336 sim_printf ("\nInstructions = %llu\n",
8337 #else
8338 sim_printf ("\nInstructions = %'llu\n",
8339 #endif
8340 (unsigned long long)cpu.cycleCnt);
8341 longjmp (cpu.jmpMain, JMP_STOP);
8342 }
8343
8344
8345 if (cpu.PPR.PSR == 0430 && cpu.PPR.IC == 012)
8346 {
8347 sim_printf ("BCE DIS causes CPU halt\n");
8348 sim_debug (DBG_MSG, & cpu_dev, "BCE DIS causes CPU halt\n");
8349 #ifdef LOCKLESS
8350 bce_dis_called = true;
8351 #endif
8352 longjmp (cpu.jmpMain, JMP_STOP);
8353 }
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374 #ifdef ROUND_ROBIN
8375 if (cpu.PPR.PSR == 034 && cpu.PPR.IC == 03535)
8376 {
8377 sim_printf ("[%lld] sys_trouble$die DIS causes CPU halt\n", cpu.cycleCnt);
8378 sim_debug (DBG_MSG, & cpu_dev, "sys_trouble$die DIS causes CPU halt\n");
8379
8380 cpu.isRunning = false;
8381 }
8382 #endif
8383 sim_debug (DBG_TRACEEXT, & cpu_dev, "entered DIS_cycle\n");
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408 if (sample_interrupts ())
8409 {
8410 sim_debug (DBG_TRACEEXT, & cpu_dev, "DIS sees an interrupt\n");
8411 cpu.interrupt_flag = true;
8412 break;
8413 }
8414
8415
8416
8417 if (GET_I (cpu.cu.IWB) ? bG7PendingNoTRO () : bG7Pending ())
8418
8419
8420
8421
8422
8423
8424
8425
8426 {
8427 sim_debug (DBG_TRACEEXT, & cpu_dev, "DIS sees a TRO\n");
8428 cpu.g7_flag = true;
8429 break;
8430 }
8431 else
8432 {
8433 sim_debug (DBG_TRACEEXT, & cpu_dev, "DIS refetches\n");
8434 #ifdef ROUND_ROBIN
8435 if (cpu.tweaks.isolts_mode)
8436 {
8437
8438 cpu.isRunning = false;
8439 }
8440 #endif
8441 return CONT_DIS;
8442 }
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455 case x1 (0560):
8456 case x1 (0561):
8457 case x1 (0562):
8458 case x1 (0563):
8459 case x1 (0564):
8460 case x1 (0565):
8461 case x1 (0566):
8462 case x1 (0567):
8463 {
8464
8465 PNL (L68_ (DU_CYCLE_DDU_LDEA;))
8466
8467 if (getbits36_1 (cpu.CY, 23) != 0)
8468 doFault (FAULT_IPR,
8469 fst_ill_proc,
8470 "aarn C(Y)23 != 0");
8471
8472 uint32 n = opcode10 & 07;
8473 CPTUR (cptUsePRn + n);
8474
8475
8476 cpu.AR[n].WORDNO = GETHI (cpu.CY);
8477
8478 uint TA = getbits36_2 (cpu.CY, 21);
8479 uint CN = getbits36_3 (cpu.CY, 18);
8480
8481 switch (TA)
8482 {
8483 case CTA4:
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510 SET_AR_CHAR_BITNO (n, (word2) (CN/2), (CN % 2) ? 5 : 0);
8511
8512 break;
8513
8514 case CTA6:
8515
8516
8517 if (CN > 5)
8518 {
8519 cpu.AR[n].WORDNO = 0;
8520 SET_AR_CHAR_BITNO (n, 0, 0);
8521 doFault (FAULT_IPR, fst_ill_proc, "aarn TN > 5");
8522 }
8523
8524
8525
8526
8527 SET_AR_CHAR_BITNO (n, (word2) ((6 * CN) / 9),
8528 (6 * CN) % 9);
8529 break;
8530
8531 case CTA9:
8532
8533
8534
8535
8536 SET_AR_CHAR_BITNO (n, (word2) (CN >> 1), 0);
8537 break;
8538
8539 case CTAILL:
8540
8541
8542 cpu.AR[n].WORDNO = 0;
8543 SET_AR_CHAR_BITNO (n, 0, 0);
8544 #ifdef TESTING
8545 HDBGRegARW (n, "aarn");
8546 #endif
8547 doFault (FAULT_IPR, fst_ill_proc, "aarn TA = 3");
8548 }
8549 #ifdef TESTING
8550 HDBGRegARW (n, "aarn");
8551 #endif
8552 }
8553 break;
8554
8555
8556
8557 case x1 (0760):
8558 case x1 (0761):
8559 case x1 (0762):
8560 case x1 (0763):
8561 case x1 (0764):
8562 case x1 (0765):
8563 case x1 (0766):
8564 case x1 (0767):
8565 {
8566
8567
8568 PNL (L68_ (DU_CYCLE_DDU_LDEA;))
8569
8570 uint32 n = opcode10 & 07;
8571 CPTUR (cptUsePRn + n);
8572 cpu.AR[n].WORDNO = GETHI (cpu.CY);
8573
8574 SET_AR_CHAR_BITNO (n, getbits36_2 (cpu.CY, 18),
8575 getbits36_4 (cpu.CY, 20));
8576 #ifdef TESTING
8577 HDBGRegARW (n, "larn");
8578 #endif
8579 }
8580 break;
8581
8582
8583
8584 case x1 (0463):
8585 PNL (L68_ (DU_CYCLE_DDU_LDEA;))
8586
8587 for (uint32 n = 0 ; n < 8 ; n += 1)
8588 {
8589 CPTUR (cptUsePRn + n);
8590 word36 tmp36 = cpu.Yblock8[n];
8591 cpu.AR[n].WORDNO = getbits36_18 (tmp36, 0);
8592 SET_AR_CHAR_BITNO (n, getbits36_2 (tmp36, 18),
8593 getbits36_4 (tmp36, 20));
8594 #ifdef TESTING
8595 HDBGRegARW (n, "lareg");
8596 #endif
8597 }
8598 break;
8599
8600
8601
8602 case x1 (0467):
8603 PNL (L68_ (DU_CYCLE_DDU_LDEA;))
8604 words2du (cpu.Yblock8);
8605 break;
8606
8607
8608
8609 case x1 (0660):
8610 case x1 (0661):
8611 case x1 (0662):
8612 case x1 (0663):
8613 case x1 (0664):
8614 case x1 (0665):
8615 case x1 (0666):
8616 case x1 (0667):
8617 {
8618
8619 PNL (L68_ (DU_CYCLE_DDU_LDEA;))
8620
8621 uint32 n = opcode10 & 07;
8622 CPTUR (cptUsePRn + n);
8623
8624
8625 cpu.AR[n].WORDNO = GETHI (cpu.CY);
8626
8627 uint TN = getbits36_1 (cpu.CY, 21);
8628 uint CN = getbits36_3 (cpu.CY, 18);
8629
8630 switch(TN)
8631 {
8632 case CTN4:
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659 SET_AR_CHAR_BITNO (n, (word2) (CN/2), (CN % 2) ? 5 : 0);
8660
8661 break;
8662
8663 case CTN9:
8664
8665
8666 if ((CN & 1) != 0)
8667 doFault (FAULT_IPR, fst_ill_proc, "narn N9 and CN odd");
8668
8669 CN >>= 1;
8670
8671
8672
8673 SET_AR_CHAR_BITNO (n, (word2) CN, 0);
8674 break;
8675 }
8676 #ifdef TESTING
8677 HDBGRegARW (n, "narn");
8678 #endif
8679 }
8680 break;
8681
8682
8683
8684
8685
8686
8687 case x1 (0540):
8688 case x1 (0541):
8689 case x1 (0542):
8690 case x1 (0543):
8691 case x1 (0544):
8692 case x1 (0545):
8693 case x1 (0546):
8694 case x1 (0547):
8695 {
8696
8697
8698 PNL (L68_ (DU_CYCLE_DDU_STEA;))
8699
8700 uint TA = getbits36_2 (cpu.CY, 21);
8701
8702
8703
8704 if (TA == 03) {
8705 dlyDoFault (FAULT_IPR, fst_ill_proc, "ARAn tag == 3");
8706 break;
8707 }
8708 if (getbits36_1 (cpu.CY, 23) != 0) {
8709 dlyDoFault (FAULT_IPR, fst_ill_proc, "ARAn b23 == 1");
8710 break;
8711 }
8712
8713 uint32 n = opcode10 & 07;
8714 CPTUR (cptUsePRn + n);
8715
8716
8717
8718 putbits36_18 (& cpu.CY, 0, cpu.AR[n].WORDNO & MASK18);
8719
8720
8721
8722
8723
8724 int CN = 0;
8725
8726 switch (TA)
8727 {
8728 case CTA4:
8729
8730
8731 CN = (9 * GET_AR_CHAR (n) + GET_AR_BITNO (n) - 1) / 4;
8732 putbits36_3 (& cpu.CY, 18, (word3) CN & MASK3);
8733 break;
8734
8735 case CTA6:
8736
8737
8738 CN = (9 * GET_AR_CHAR (n) + GET_AR_BITNO (n)) / 6;
8739 putbits36_3 (& cpu.CY, 18, (word3) CN & MASK3);
8740 break;
8741
8742 case CTA9:
8743
8744
8745
8746 putbits36_3 (& cpu.CY, 18,
8747 (word3) ((GET_AR_CHAR (n) & MASK2) << 1));
8748 break;
8749 }
8750 cpu.zone = 0777777700000;
8751 cpu.useZone = true;
8752 }
8753 break;
8754
8755
8756
8757
8758 case x1 (0640):
8759 case x1 (0641):
8760 case x1 (0642):
8761 case x1 (0643):
8762 case x1 (0644):
8763 case x1 (0645):
8764 case x1 (0646):
8765 case x1 (0647):
8766 {
8767 PNL (L68_ (DU_CYCLE_DDU_STEA;))
8768 uint32 n = opcode10 & 07;
8769 CPTUR (cptUsePRn + n);
8770
8771
8772
8773
8774 uint TN = getbits36_1 (cpu.CY, 21);
8775
8776
8777
8778 putbits36_18 (& cpu.CY, 0, cpu.AR[n].WORDNO & MASK18);
8779
8780 switch (TN)
8781 {
8782 case CTN4:
8783 {
8784
8785
8786
8787 word3 CN = (9 * GET_AR_CHAR (n) +
8788 GET_AR_BITNO (n) - 1) / 4;
8789 putbits36_3 (& cpu.CY, 18, CN & MASK3);
8790 break;
8791 }
8792 case CTN9:
8793
8794
8795
8796 putbits36_3 (& cpu.CY, 18,
8797 (word3) ((GET_AR_CHAR (n) & MASK2) << 1));
8798 break;
8799 }
8800 cpu.zone = 0777777700000;
8801 cpu.useZone = true;
8802 }
8803 break;
8804
8805
8806
8807
8808 case x1 (0740):
8809 case x1 (0741):
8810 case x1 (0742):
8811 case x1 (0743):
8812 case x1 (0744):
8813 case x1 (0745):
8814 case x1 (0746):
8815 case x1 (0747):
8816
8817
8818
8819 {
8820 PNL (L68_ (DU_CYCLE_DDU_STEA;))
8821 uint32 n = opcode10 & 07;
8822 CPTUR (cptUsePRn + n);
8823 putbits36 (& cpu.CY, 0, 18, cpu.PR[n].WORDNO);
8824
8825 putbits36 (& cpu.CY, 18, 2, GET_AR_CHAR (n));
8826 putbits36 (& cpu.CY, 20, 4, GET_AR_BITNO (n));
8827
8828 cpu.zone = 0777777770000;
8829 cpu.useZone = true;
8830 }
8831 break;
8832
8833
8834
8835 case x1 (0443):
8836
8837
8838 PNL (L68_ (DU_CYCLE_DDU_STEA;))
8839 memset (cpu.Yblock8, 0, sizeof (cpu.Yblock8));
8840 for (uint32 n = 0 ; n < 8 ; n += 1)
8841 {
8842 CPTUR (cptUsePRn + n);
8843 word36 arx = 0;
8844 putbits36 (& arx, 0, 18, cpu.PR[n].WORDNO);
8845 putbits36 (& arx, 18, 2, GET_AR_CHAR (n));
8846 putbits36 (& arx, 20, 4, GET_AR_BITNO (n));
8847 cpu.Yblock8[n] = arx;
8848 }
8849 break;
8850
8851
8852
8853 case x1 (0447):
8854 PNL (L68_ (DU_CYCLE_DDU_STEA;))
8855 du2words (cpu.Yblock8);
8856 break;
8857
8858
8859
8860
8861
8862 case x1 (0502):
8863 asxbd (4, false);
8864 break;
8865
8866
8867
8868 case x1 (0501):
8869 asxbd (6, false);
8870 break;
8871
8872
8873
8874 case x1 (0500):
8875 asxbd (9, false);
8876 break;
8877
8878
8879
8880 case x1 (0503):
8881 asxbd (1, false);
8882 break;
8883
8884
8885
8886 case x1 (0507):
8887 asxbd (36, false);
8888 break;
8889
8890
8891
8892 case x1 (0522):
8893 asxbd (4, true);
8894 break;
8895
8896
8897
8898 case x1 (0521):
8899 asxbd (6, true);
8900 break;
8901
8902
8903
8904 case x1 (0520):
8905 asxbd (9, true);
8906 break;
8907
8908
8909
8910 case x1 (0523):
8911 asxbd (1, true);
8912 break;
8913
8914
8915
8916 case x1 (0527):
8917 asxbd (36, true);
8918 break;
8919
8920
8921
8922 case x1 (0106):
8923 cmpc ();
8924 break;
8925
8926 case x1 (0120):
8927 scd ();
8928 break;
8929
8930 case x1 (0121):
8931 scdr ();
8932 break;
8933
8934 case x1 (0124):
8935 scm ();
8936 break;
8937
8938 case x1 (0125):
8939 scmr ();
8940 break;
8941
8942 case x1 (0164):
8943 tct ();
8944 break;
8945
8946 case x1 (0165):
8947 tctr ();
8948 break;
8949
8950
8951
8952 case x1 (0100):
8953 mlr ();
8954 break;
8955
8956 case x1 (0101):
8957 mrl ();
8958 break;
8959
8960 case x1 (0020):
8961 mve ();
8962 break;
8963
8964 case x1 (0160):
8965 mvt ();
8966 break;
8967
8968
8969
8970 case x1 (0303):
8971 cmpn ();
8972 break;
8973
8974
8975
8976 case x1 (0300):
8977 mvn ();
8978 break;
8979
8980 case x1 (0024):
8981 mvne ();
8982 break;
8983
8984
8985
8986 case x1 (0060):
8987 csl ();
8988 break;
8989
8990 case x1 (0061):
8991 csr ();
8992 break;
8993
8994
8995
8996 case x1 (0066):
8997 cmpb ();
8998 break;
8999
9000
9001
9002 case x1 (0064):
9003
9004
9005
9006 sztl ();
9007 break;
9008
9009 case x1 (0065):
9010
9011
9012
9013 sztr ();
9014 break;
9015
9016
9017
9018 case x1 (0301):
9019 btd ();
9020 break;
9021
9022 case x1 (0305):
9023 dtb ();
9024 break;
9025
9026
9027
9028 case x1 (0202):
9029 ad2d ();
9030 break;
9031
9032 case x1 (0222):
9033 ad3d ();
9034 break;
9035
9036
9037
9038 case x1 (0203):
9039 sb2d ();
9040 break;
9041
9042 case x1 (0223):
9043 sb3d ();
9044 break;
9045
9046
9047
9048 case x1 (0206):
9049 mp2d ();
9050 break;
9051
9052 case x1 (0226):
9053 mp3d ();
9054 break;
9055
9056
9057
9058 case x1 (0207):
9059 dv2d ();
9060 break;
9061
9062 case x1 (0227):
9063 dv3d ();
9064 break;
9065
9066 case x1 (0420):
9067 {
9068 if (cpu.tweaks.enable_emcall) {
9069 int ret = emCall ();
9070 if (ret)
9071 return ret;
9072 break;
9073 }
9074 goto unimp;
9075 }
9076
9077 default:
9078 unimp:
9079 if (cpu.tweaks.halt_on_unimp)
9080 return STOP_STOP;
9081 doFault (FAULT_IPR,
9082 fst_ill_op,
9083 "Illegal instruction");
9084 }
9085 L68_ (
9086 cpu.ou.STR_OP = (is_ou && (i->info->flags & (STORE_OPERAND | STORE_YPAIR))) ? 1 : 0;
9087 cpu.ou.cycle |= ou_GOF;
9088 if (cpu.MR_cache.emr && cpu.MR_cache.ihr && is_ou)
9089 add_l68_OU_history ();
9090 if (cpu.MR_cache.emr && cpu.MR_cache.ihr && is_du)
9091 add_l68_DU_history ();
9092 )
9093 return SCPE_OK;
9094 }
9095
9096 #include <ctype.h>
9097 #include <time.h>
9098
9099
9100
9101
9102
9103
9104
9105 static uv_rusage_t startTime;
9106 static unsigned long long startInstrCnt;
9107
9108 static int emCall (void)
9109 {
9110 DCDstruct * i = & cpu.currentInstruction;
9111
9112
9113
9114
9115
9116 word36 op = M[i->address];
9117 switch (op)
9118 {
9119
9120
9121 case 1:
9122 sim_printf ("%lld\n", (long long int) M[i->address+1]);
9123 break;
9124
9125
9126 case 2:
9127 #ifdef LOCKLESS
9128 bce_dis_called = true;
9129 #endif
9130 return STOP_STOP;
9131
9132
9133 case 3:
9134 startInstrCnt = cpu.instrCnt;
9135 uv_getrusage (& startTime);
9136 break;
9137
9138
9139 case 4:
9140 {
9141 #define ns_sec (1000000000)
9142 #define ns_msec (1000000000 / 1000)
9143 #define ns_usec (1000000000 / 1000 / 1000)
9144 uv_rusage_t now;
9145 uv_getrusage (& now);
9146 uint64_t start = (uint64_t)(startTime.ru_utime.tv_usec * 1000 +
9147 startTime.ru_utime.tv_sec * ns_sec);
9148 uint64_t stop = (uint64_t)(now.ru_utime.tv_usec * 1000 +
9149 now.ru_utime.tv_sec * ns_sec);
9150 uint64_t delta = stop - start;
9151 uint64_t seconds = delta / ns_sec;
9152 uint64_t milliseconds = (delta / ns_msec) % 1000;
9153 uint64_t microseconds = (delta / ns_usec) % 1000;
9154 uint64_t nanoseconds = delta % 1000;
9155 unsigned long long nInsts = cpu.instrCnt - startInstrCnt;
9156 double secs = (double)(((long double) delta) / ((long double) ns_sec));
9157 long double ips = (long double)(((long double) nInsts) / ((long double) secs));
9158 long double mips = ips / 1000000.0L;
9159
9160 #ifdef WIN_STDIO
9161 sim_printf ("CPU time %llu.%03llu,%03llu,%03llu\n",
9162 #else
9163 sim_printf ("CPU time %'llu.%03llu,%03llu,%03llu\n",
9164 #endif
9165 (unsigned long long) seconds,
9166 (unsigned long long) milliseconds,
9167 (unsigned long long) microseconds,
9168 (unsigned long long) nanoseconds);
9169 #ifdef WIN_STDIO
9170 sim_printf ("%llu instructions\n", (unsigned long long) nInsts);
9171 sim_printf ("%f MIPS\n", (double) mips);
9172 #else
9173 sim_printf ("%'llu instructions\n", (unsigned long long) nInsts);
9174 sim_printf ("%'f MIPS\n", (double) mips);
9175 #endif
9176 break;
9177 }
9178 default:
9179 sim_printf ("emcall unknown op %llo\n", (unsigned long long)op);
9180 }
9181 return 0;
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373 }
9374
9375
9376 static int doABSA (word36 * result)
9377 {
9378 word36 res;
9379 sim_debug (DBG_APPENDING, & cpu_dev, "absa CA:%08o\n", cpu.TPR.CA);
9380
9381
9382
9383 if (get_addr_mode () == ABSOLUTE_mode && ! (cpu.cu.XSF || cpu.currentInstruction.b29))
9384 {
9385 * result = ((word36) (cpu.TPR.CA & MASK18)) << 12;
9386 return SCPE_OK;
9387 }
9388
9389
9390
9391
9392
9393
9394
9395 res = (word36) do_append_cycle (ABSA_CYCLE, NULL, 0) << 12;
9396
9397 * result = res;
9398
9399 return SCPE_OK;
9400 }
9401
9402 void doRCU (void)
9403 {
9404 #ifdef LOOPTRC
9405 elapsedtime ();
9406 sim_printf (" rcu to %05o:%06o PSR:IC %05o:%06o\r\n", (cpu.Yblock8[0]>>18)&MASK15, (cpu.Yblock8[4]>>18)&MASK18, cpu.PPR.PSR, cpu.PPR.IC);
9407 #endif
9408
9409 if_sim_debug (DBG_FAULT, & cpu_dev)
9410 {
9411 dump_words(cpu.Yblock8);
9412
9413
9414
9415
9416
9417 }
9418
9419 words2scu (cpu.Yblock8);
9420 decode_instruction (IWB_IRODD, & cpu.currentInstruction);
9421
9422
9423
9424 word1 saveP = cpu.PPR.P;
9425 if (TST_I_ABS == 0)
9426 set_addr_mode (APPEND_mode);
9427 else
9428 set_addr_mode (ABSOLUTE_mode);
9429 cpu.PPR.P = saveP;
9430
9431 if (getbits36_1 (cpu.Yblock8[1], 35) == 0)
9432 {
9433 sim_debug (DBG_FAULT, & cpu_dev, "RCU interrupt return\n");
9434 longjmp (cpu.jmpMain, JMP_REFETCH);
9435 }
9436
9437
9438 fauxDoAppendCycle (INSTRUCTION_FETCH);
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500 #define rework
9501 #ifdef rework
9502 if (cpu.cu.FIF)
9503 {
9504
9505
9506
9507
9508
9509
9510 cpu.cu.rfi = 0;
9511 sim_debug (DBG_FAULT, & cpu_dev, "RCU FIF REFETCH return\n");
9512 longjmp (cpu.jmpMain, JMP_REFETCH);
9513 }
9514
9515
9516 if (cpu.cu.rfi)
9517 {
9518
9519 sim_debug (DBG_FAULT, & cpu_dev, "RCU rfi refetch return\n");
9520
9521
9522
9523 cpu.cu.rfi = 0;
9524 longjmp (cpu.jmpMain, JMP_REFETCH);
9525 }
9526
9527
9528
9529
9530 word5 fi_addr = getbits36_5 (cpu.Yblock8[1], 30);
9531 if (fi_addr == FAULT_MME ||
9532 fi_addr == FAULT_MME2 ||
9533 fi_addr == FAULT_MME3 ||
9534 fi_addr == FAULT_MME4 ||
9535 fi_addr == FAULT_DRL)
9536
9537 {
9538
9539 sim_debug (DBG_FAULT, & cpu_dev, "RCU MME2 restart return\n");
9540 cpu.cu.rfi = 0;
9541 longjmp (cpu.jmpMain, JMP_RESTART);
9542 }
9543 #else
9544 if (cpu.cu.rfi ||
9545 cpu.cu.FIF)
9546 {
9547
9548
9549
9550
9551
9552
9553
9554 cpu.cu.rfi = 0;
9555 sim_debug (DBG_FAULT, & cpu_dev, "RCU rfi/FIF REFETCH return\n");
9556 longjmp (cpu.jmpMain, JMP_REFETCH);
9557 }
9558
9559
9560
9561
9562
9563 if (fi_addr == FAULT_MME2)
9564 {
9565
9566 sim_debug (DBG_FAULT, & cpu_dev, "RCU MME2 restart return\n");
9567 cpu.cu.rfi = 1;
9568 longjmp (cpu.jmpMain, JMP_RESTART);
9569 }
9570 #endif
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592 #ifdef rework
9593 if (fi_addr == FAULT_DIV ||
9594 fi_addr == FAULT_OFL ||
9595 fi_addr == FAULT_IPR)
9596 {
9597 sim_debug (DBG_FAULT, & cpu_dev, "RCU sync fault return\n");
9598 cpu.cu.rfi = 0;
9599 longjmp (cpu.jmpMain, JMP_SYNC_FAULT_RETURN);
9600 }
9601 #else
9602 if (fi_addr == FAULT_MME ||
9603
9604 fi_addr == FAULT_MME3 ||
9605 fi_addr == FAULT_MME4 ||
9606 fi_addr == FAULT_DRL ||
9607 fi_addr == FAULT_DIV ||
9608 fi_addr == FAULT_OFL ||
9609 fi_addr == FAULT_IPR)
9610 {
9611 sim_debug (DBG_FAULT, & cpu_dev, "RCU MMEx sync fault return\n");
9612 cpu.cu.rfi = 0;
9613 longjmp (cpu.jmpMain, JMP_SYNC_FAULT_RETURN);
9614 }
9615 #endif
9616
9617
9618 if (fi_addr == FAULT_LUF)
9619 {
9620 cpu.cu.rfi = 1;
9621 sim_debug (DBG_FAULT, & cpu_dev, "RCU LUF RESTART return\n");
9622 longjmp (cpu.jmpMain, JMP_RESTART);
9623 }
9624
9625 if (fi_addr == FAULT_DF0 ||
9626 fi_addr == FAULT_DF1 ||
9627 fi_addr == FAULT_DF2 ||
9628 fi_addr == FAULT_DF3 ||
9629 fi_addr == FAULT_ACV ||
9630 fi_addr == FAULT_F1 ||
9631 fi_addr == FAULT_F2 ||
9632 fi_addr == FAULT_F3 ||
9633 fi_addr == FAULT_CMD ||
9634 fi_addr == FAULT_EXF)
9635 {
9636
9637 cpu.cu.rfi = 1;
9638 sim_debug (DBG_FAULT, & cpu_dev, "RCU ACV RESTART return\n");
9639 longjmp (cpu.jmpMain, JMP_RESTART);
9640 }
9641 sim_printf ("doRCU dies with unhandled fault number %d\n", fi_addr);
9642 doFault (FAULT_TRB,
9643 (_fault_subtype) {.bits=fi_addr},
9644 "doRCU dies with unhandled fault number");
9645 }