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