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 #if BARREL_SHIFTER
4239 uint cnt = (uint) cpu.TPR.CA & 0177;
4240
4241
4242 word36 captureA, captureQ;
4243
4244 if (cnt < 36) {
4245
4246 captureA = cpu.rA & barrelLeftMaskTable[cnt + 1];
4247 if (captureA == 0 || captureA == (MASK36 & barrelLeftMaskTable[cnt + 1]))
4248 CLR_I_CARRY;
4249 else
4250 SET_I_CARRY;
4251 } else {
4252
4253 uint cnt72 = cnt < 72 ? cnt : 71;
4254 captureA = cpu.rA;
4255 captureQ = cpu.rQ & barrelLeftMaskTable[cnt72 + 1 - 36];
4256 if (captureA == 0 && ((captureQ & barrelLeftMaskTable[cnt72 + 1 - 36]) == 0))
4257 CLR_I_CARRY;
4258 else if (captureA == MASK36 &&
4259 ((captureQ & barrelLeftMaskTable[cnt72 + 1 - 36]) == (MASK36 & barrelLeftMaskTable[cnt72 + 1 - 36])))
4260 CLR_I_CARRY;
4261 else
4262 SET_I_CARRY;
4263 }
4264 cnt = cnt % 72;
4265 if (cnt > 35) {
4266 cnt = cnt - 36;
4267 cpu.rA = cpu.rQ;
4268 cpu.rQ = 0;
4269 }
4270
4271 word36 lowA = cpu.rA & BS_COMPL(barrelLeftMaskTable[cnt]);
4272 word36 highQ = cpu.rQ & barrelLeftMaskTable[cnt];
4273 word36 lowQ = cpu.rQ & BS_COMPL(barrelLeftMaskTable[cnt]);
4274 cpu.rA = (lowA << cnt) | (highQ >> (36 - cnt));
4275 cpu.rQ = (lowQ << cnt) ;
4276 #else
4277
4278 CLR_I_CARRY;
4279
4280 # if defined(TESTING)
4281 HDBGRegAR ("lls");
4282 HDBGRegQR ("lls");
4283 # endif
4284 word36 tmp36 = cpu.TPR.CA & 0177;
4285 word36 tmpSign = cpu.rA & SIGN36;
4286 for (uint j = 0 ; j < tmp36 ; j ++)
4287 {
4288 cpu.rA <<= 1;
4289
4290 if (tmpSign != (cpu.rA & SIGN36))
4291 SET_I_CARRY;
4292
4293 bool b0 = cpu.rQ & SIGN36;
4294 if (b0)
4295 cpu.rA |= 1;
4296
4297 cpu.rQ <<= 1;
4298 }
4299
4300 cpu.rA &= DMASK;
4301 cpu.rQ &= DMASK;
4302 #endif
4303 #if defined(TESTING)
4304 HDBGRegAW ("lls");
4305 HDBGRegQW ("lls");
4306 #endif
4307
4308 SC_I_ZERO (cpu.rA == 0 && cpu.rQ == 0);
4309 SC_I_NEG (cpu.rA & SIGN36);
4310 }
4311 break;
4312
4313 case x0 (0773):
4314
4315
4316 {
4317 #if defined(TESTING)
4318 HDBGRegAR ("lrl");
4319 HDBGRegQR ("lrl");
4320 #endif
4321 #if BARREL_SHIFTER
4322 uint cnt = (uint) cpu.TPR.CA & 0177;
4323 if (cnt >= 72) {
4324 cpu.rA = 0;
4325 cpu.rQ = 0;
4326 } else if (cnt < 36) {
4327
4328 cpu.rQ >>= cnt;
4329
4330 cpu.rQ &= BS_COMPL (barrelLeftMaskTable[cnt]);
4331
4332 word36 lowA = cpu.rA & barrelRightMaskTable[cnt];
4333
4334 cpu.rA >>= cnt;
4335
4336 cpu.rA &= BS_COMPL (barrelLeftMaskTable[cnt]);
4337
4338 lowA <<= (36 - cnt);
4339
4340 cpu.rQ |= lowA;
4341 } else {
4342
4343 cpu.rQ = cpu.rA >> (cnt - 36);
4344
4345 cpu.rQ &= BS_COMPL (barrelLeftMaskTable[cnt - 36]);
4346 cpu.rA = 0;
4347 }
4348 cpu.rA &= DMASK;
4349 cpu.rQ &= DMASK;
4350 #else
4351 cpu.rA &= DMASK;
4352 cpu.rQ &= DMASK;
4353 word36 tmp36 = cpu.TPR.CA & 0177;
4354 for (uint j = 0 ; j < tmp36 ; j++)
4355 {
4356 bool a35 = cpu.rA & 1;
4357 cpu.rA >>= 1;
4358
4359 cpu.rQ >>= 1;
4360
4361 if (a35)
4362 cpu.rQ |= SIGN36;
4363 }
4364 cpu.rA &= DMASK;
4365 cpu.rQ &= DMASK;
4366 #endif
4367 #if defined(TESTING)
4368 HDBGRegAW ("lrl");
4369 HDBGRegQW ("lrl");
4370 #endif
4371
4372 SC_I_ZERO (cpu.rA == 0 && cpu.rQ == 0);
4373 SC_I_NEG (cpu.rA & SIGN36);
4374 }
4375 break;
4376
4377 case x0 (0733):
4378 {
4379
4380
4381
4382 #if defined(TESTING)
4383 HDBGRegAR ("lrs");
4384 HDBGRegQR ("lrs");
4385 #endif
4386 #if BARREL_SHIFTER
4387 uint cnt = (uint) cpu.TPR.CA & 0177;
4388 bool AQ0 = (cpu.rA & SIGN36) != 0;
4389 if (cnt >= 72) {
4390 cpu.rA = cpu.rQ = AQ0 ? MASK36 : 0;
4391 } else if (cnt < 36) {
4392
4393 cpu.rQ >>= cnt;
4394
4395 cpu.rQ &= BS_COMPL (barrelLeftMaskTable[cnt]);
4396
4397 word36 lowA = cpu.rA & barrelRightMaskTable[cnt];
4398
4399 cpu.rA >>= cnt;
4400
4401 if (AQ0)
4402 cpu.rA |= barrelLeftMaskTable[cnt];
4403 else
4404 cpu.rA &= BS_COMPL (barrelLeftMaskTable[cnt]);
4405
4406 lowA <<= (36 - cnt);
4407
4408 cpu.rQ |= lowA;
4409 } else {
4410
4411 cpu.rQ = cpu.rA >> (cnt - 36);
4412
4413 if (AQ0) {
4414 cpu.rQ |= barrelLeftMaskTable[cnt - 36];
4415 cpu.rA = MASK36;
4416 } else {
4417 cpu.rQ &= BS_COMPL (barrelLeftMaskTable[cnt - 36]);
4418 cpu.rA = 0;
4419 }
4420 }
4421 cpu.rA &= DMASK;
4422 cpu.rQ &= DMASK;
4423 #else
4424 word36 tmp36 = cpu.TPR.CA & 0177;
4425 cpu.rA &= DMASK;
4426 cpu.rQ &= DMASK;
4427 bool a0 = cpu.rA & SIGN36;
4428
4429 for (uint j = 0 ; j < tmp36 ; j ++)
4430 {
4431 bool a35 = cpu.rA & 1;
4432
4433 cpu.rA >>= 1;
4434 if (a0)
4435 cpu.rA |= SIGN36;
4436
4437 cpu.rQ >>= 1;
4438 if (a35)
4439 cpu.rQ |= SIGN36;
4440 }
4441 cpu.rA &= DMASK;
4442 cpu.rQ &= DMASK;
4443 #endif
4444 #if defined(TESTING)
4445 HDBGRegAW ("lrs");
4446 HDBGRegQW ("lrs");
4447 #endif
4448
4449 SC_I_ZERO (cpu.rA == 0 && cpu.rQ == 0);
4450 SC_I_NEG (cpu.rA & SIGN36);
4451 }
4452 break;
4453
4454 case x0 (0776):
4455
4456
4457 {
4458 #if defined(TESTING)
4459 HDBGRegQR ("qlr");
4460 #endif
4461 #if BARREL_SHIFTER
4462 uint cnt = (uint) cpu.TPR.CA & 0177;
4463 cnt %= 36;
4464
4465 word36 highQ = cpu.rQ & barrelLeftMaskTable[cnt];
4466 cpu.rQ <<= cnt;
4467 highQ >>= (36 - cnt);
4468 highQ &= barrelRightMaskTable[cnt];
4469 cpu.rQ |= highQ;
4470 cpu.rQ &= DMASK;
4471 #else
4472 word36 tmp36 = cpu.TPR.CA & 0177;
4473 for (uint j = 0 ; j < tmp36 ; j++)
4474 {
4475 bool q0 = cpu.rQ & SIGN36;
4476 cpu.rQ <<= 1;
4477 if (q0)
4478 cpu.rQ |= 1;
4479 }
4480 cpu.rQ &= DMASK;
4481 #endif
4482 #if defined(TESTING)
4483 HDBGRegQW ("qlr");
4484 #endif
4485
4486 SC_I_ZERO (cpu.rQ == 0);
4487 SC_I_NEG (cpu.rQ & SIGN36);
4488 }
4489 break;
4490
4491
4492
4493
4494 case x0 (0772):
4495
4496
4497 {
4498 #if defined(TESTING)
4499 HDBGRegQR ("qrl");
4500 #endif
4501 word36 tmp36 = cpu.TPR.CA & 0177;
4502
4503 cpu.rQ &= DMASK;
4504 cpu.rQ >>= tmp36;
4505 cpu.rQ &= DMASK;
4506 #if defined(TESTING)
4507 HDBGRegQW ("qrl");
4508 #endif
4509
4510 SC_I_ZERO (cpu.rQ == 0);
4511 SC_I_NEG (cpu.rQ & SIGN36);
4512
4513 }
4514 break;
4515
4516 case x0 (0732):
4517 {
4518
4519
4520
4521 #if defined(TESTING)
4522 HDBGRegQR ("qrs");
4523 #endif
4524 #if BARREL_SHIFTER
4525 uint cnt = (uint) cpu.TPR.CA & 0177;
4526 bool Q0 = (cpu.rQ & SIGN36) != 0;
4527
4528 if (cnt >= 36) {
4529 cpu.rQ = Q0 ? MASK36 : 0;
4530 } else {
4531
4532 cpu.rQ >>= cnt;
4533
4534 if (Q0) {
4535 cpu.rQ |= barrelLeftMaskTable[cnt];
4536 } else {
4537 cpu.rQ &= BS_COMPL (barrelLeftMaskTable[cnt]);
4538 }
4539 }
4540 cpu.rQ &= DMASK;
4541 #else
4542 cpu.rQ &= DMASK;
4543 word36 tmp36 = cpu.TPR.CA & 0177;
4544 bool q0 = cpu.rQ & SIGN36;
4545 for (uint j = 0 ; j < tmp36 ; j++)
4546 {
4547 cpu.rQ >>= 1;
4548 if (q0)
4549 cpu.rQ |= SIGN36;
4550 }
4551 cpu.rQ &= DMASK;
4552 #endif
4553 #if defined(TESTING)
4554 HDBGRegQW ("qrs");
4555 #endif
4556
4557 SC_I_ZERO (cpu.rQ == 0);
4558 SC_I_NEG (cpu.rQ & SIGN36);
4559 }
4560 break;
4561
4562
4563
4564 case x0 (0075):
4565 {
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575 L68_ (cpu.ou.cycle |= ou_GOS;)
4576 #if defined(TESTING)
4577 HDBGRegAR ("ada");
4578 #endif
4579 bool ovf;
4580 cpu.rA = Add36b (cpup, cpu.rA, cpu.CY, 0, I_ZNOC, & cpu.cu.IR, & ovf);
4581 #if defined(TESTING)
4582 HDBGRegAW ("ada");
4583 #endif
4584 overflow (cpup, ovf, false, "ada overflow fault");
4585 }
4586 break;
4587
4588 case x0 (0077):
4589 {
4590
4591 L68_ (cpu.ou.cycle |= ou_GOS;)
4592 #if defined(TESTING)
4593 HDBGRegAR ("adaq");
4594 HDBGRegQR ("adaq");
4595 #endif
4596 bool ovf;
4597 word72 tmp72 = YPAIRTO72 (cpu.Ypair);
4598 tmp72 = Add72b (cpup, convert_to_word72 (cpu.rA, cpu.rQ),
4599 tmp72, 0, I_ZNOC, & cpu.cu.IR, & ovf);
4600 convert_to_word36 (tmp72, & cpu.rA, & cpu.rQ);
4601 #if defined(TESTING)
4602 HDBGRegAW ("adaq");
4603 HDBGRegQW ("adaq");
4604 #endif
4605 overflow (cpup, ovf, false, "adaq overflow fault");
4606 }
4607 break;
4608
4609 case x0 (0033):
4610 {
4611
4612 L68_ (cpu.ou.cycle |= ou_GOS;)
4613 #if defined(TESTING)
4614 HDBGRegAR ("adl");
4615 HDBGRegQR ("adl");
4616 #endif
4617 bool ovf;
4618 word72 tmp72 = SIGNEXT36_72 (cpu.CY);
4619 tmp72 = Add72b (cpup, convert_to_word72 (cpu.rA, cpu.rQ),
4620 tmp72, 0, I_ZNOC, & cpu.cu.IR, & ovf);
4621 convert_to_word36 (tmp72, & cpu.rA, & cpu.rQ);
4622 #if defined(TESTING)
4623 HDBGRegAW ("adl");
4624 HDBGRegQW ("adl");
4625 #endif
4626 overflow (cpup, ovf, false, "adl overflow fault");
4627 }
4628 break;
4629
4630 case x0 (0037):
4631 {
4632
4633
4634
4635
4636 L68_ (cpu.ou.cycle |= ou_GOS;)
4637 #if defined(TESTING)
4638 HDBGRegAR ("adlaq");
4639 HDBGRegQR ("adlaq");
4640 #endif
4641 bool ovf;
4642 word72 tmp72 = YPAIRTO72 (cpu.Ypair);
4643
4644 tmp72 = Add72b (cpup, convert_to_word72 (cpu.rA, cpu.rQ),
4645 tmp72, 0, I_ZNC, & cpu.cu.IR, & ovf);
4646 convert_to_word36 (tmp72, & cpu.rA, & cpu.rQ);
4647 #if defined(TESTING)
4648 HDBGRegAW ("adlaq");
4649 HDBGRegQW ("adlaq");
4650 #endif
4651 }
4652 break;
4653
4654 case x0 (0035):
4655 {
4656 L68_ (cpu.ou.cycle |= ou_GOS;)
4657
4658
4659
4660
4661
4662 #if defined(TESTING)
4663 HDBGRegAR ("adla");
4664 #endif
4665 bool ovf;
4666 cpu.rA = Add36b (cpup, cpu.rA, cpu.CY, 0, I_ZNC, & cpu.cu.IR, & ovf);
4667 #if defined(TESTING)
4668 HDBGRegAW ("adla");
4669 #endif
4670 }
4671 break;
4672
4673 case x0 (0036):
4674 {
4675
4676
4677
4678
4679
4680 L68_ (cpu.ou.cycle |= ou_GOS;)
4681 #if defined(TESTING)
4682 HDBGRegQR ("adlq");
4683 #endif
4684 bool ovf;
4685 cpu.rQ = Add36b (cpup, cpu.rQ, cpu.CY, 0, I_ZNC, & cpu.cu.IR, & ovf);
4686 #if defined(TESTING)
4687 HDBGRegQW ("adlq");
4688 #endif
4689 }
4690 break;
4691
4692
4693 case x0 (0020):
4694 case x0 (0021):
4695 case x0 (0022):
4696 case x0 (0023):
4697 case x0 (0024):
4698 case x0 (0025):
4699 case x0 (0026):
4700 case x0 (0027):
4701 {
4702 L68_ (cpu.ou.cycle |= ou_GOS;)
4703 uint32 n = opcode10 & 07;
4704 #if defined(TESTING)
4705 HDBGRegXR (n, "adlxn");
4706 #endif
4707 bool ovf;
4708 cpu.rX[n] = Add18b (cpup, cpu.rX[n], GETHI (cpu.CY), 0, I_ZNC,
4709 & cpu.cu.IR, & ovf);
4710 #if defined(TESTING)
4711 HDBGRegXW (n, "adlxn");
4712 #endif
4713 }
4714 break;
4715
4716
4717
4718
4719
4720 case x0 (0060):
4721 case x0 (0061):
4722 case x0 (0062):
4723 case x0 (0063):
4724 case x0 (0064):
4725 case x0 (0065):
4726 case x0 (0066):
4727 case x0 (0067):
4728 {
4729 L68_ (cpu.ou.cycle |= ou_GOS;)
4730 uint32 n = opcode10 & 07;
4731 #if defined(TESTING)
4732 HDBGRegXR (n, "adxn");
4733 #endif
4734 bool ovf;
4735 cpu.rX[n] = Add18b (cpup, cpu.rX[n], GETHI (cpu.CY), 0,
4736 I_ZNOC,
4737 & cpu.cu.IR, & ovf);
4738 #if defined(TESTING)
4739 HDBGRegXW (n, "adxn");
4740 #endif
4741 overflow (cpup, ovf, false, "adxn overflow fault");
4742 }
4743 break;
4744
4745
4746
4747
4748 case x0 (0055):
4749 {
4750
4751
4752 L68_ (cpu.ou.cycle |= ou_GOS;)
4753 #if defined(TESTING)
4754 HDBGRegAR ("asa");
4755 #endif
4756 bool ovf;
4757 cpu.CY = Add36b (cpup, cpu.rA, cpu.CY, 0, I_ZNOC,
4758 & cpu.cu.IR, & ovf);
4759 overflow (cpup, ovf, true, "asa overflow fault");
4760 }
4761 break;
4762
4763 case x0 (0056):
4764 {
4765
4766 L68_ (cpu.ou.cycle |= ou_GOS;)
4767 #if defined(TESTING)
4768 HDBGRegQR ("asa");
4769 #endif
4770 bool ovf;
4771 cpu.CY = Add36b (cpup, cpu.rQ, cpu.CY, 0, I_ZNOC, & cpu.cu.IR, & ovf);
4772 overflow (cpup, ovf, true, "asq overflow fault");
4773 }
4774 break;
4775
4776
4777 case x0 (0040):
4778 case x0 (0041):
4779 case x0 (0042):
4780 case x0 (0043):
4781 case x0 (0044):
4782 case x0 (0045):
4783 case x0 (0046):
4784 case x0 (0047):
4785 {
4786
4787
4788 L68_ (cpu.ou.cycle |= ou_GOS;)
4789 uint32 n = opcode10 & 07;
4790 #if defined(TESTING)
4791 HDBGRegXR (n, "asxn");
4792 #endif
4793 bool ovf;
4794 word18 tmp18 = Add18b (cpup, cpu.rX[n], GETHI (cpu.CY), 0,
4795 I_ZNOC, & cpu.cu.IR, & ovf);
4796 SETHI (cpu.CY, tmp18);
4797 overflow (cpup, ovf, true, "asxn overflow fault");
4798 }
4799 break;
4800
4801 case x0 (0071):
4802 {
4803
4804
4805
4806 L68_ (cpu.ou.cycle |= ou_GOS;)
4807 #if defined(TESTING)
4808 HDBGRegAR ("awca");
4809 #endif
4810 bool ovf;
4811 cpu.rA = Add36b (cpup, cpu.rA, cpu.CY, TST_I_CARRY ? 1 : 0,
4812 I_ZNOC, & cpu.cu.IR, & ovf);
4813 #if defined(TESTING)
4814 HDBGRegAW ("awca");
4815 #endif
4816 overflow (cpup, ovf, false, "awca overflow fault");
4817 }
4818 break;
4819
4820 case x0 (0072):
4821 {
4822
4823
4824
4825 L68_ (cpu.ou.cycle |= ou_GOS;)
4826 #if defined(TESTING)
4827 HDBGRegQR ("awcq");
4828 #endif
4829 bool ovf;
4830 cpu.rQ = Add36b (cpup, cpu.rQ, cpu.CY, TST_I_CARRY ? 1 : 0,
4831 I_ZNOC, & cpu.cu.IR, & ovf);
4832 #if defined(TESTING)
4833 HDBGRegQW ("awcq");
4834 #endif
4835 overflow (cpup, ovf, false, "awcq overflow fault");
4836 }
4837 break;
4838
4839
4840
4841 case x0 (0175):
4842 {
4843
4844
4845 L68_ (cpu.ou.cycle |= ou_GOS;)
4846 #if defined(TESTING)
4847 HDBGRegAR ("sba");
4848 #endif
4849 bool ovf;
4850 cpu.rA = Sub36b (cpup, cpu.rA, cpu.CY, 1, I_ZNOC, & cpu.cu.IR, & ovf);
4851 #if defined(TESTING)
4852 HDBGRegAW ("sba");
4853 #endif
4854 overflow (cpup, ovf, false, "sba overflow fault");
4855 }
4856 break;
4857
4858 case x0 (0177):
4859 {
4860
4861 L68_ (cpu.ou.cycle |= ou_GOS;)
4862 #if defined(TESTING)
4863 HDBGRegAR ("sbaq");
4864 HDBGRegQR ("sbaq");
4865 #endif
4866 bool ovf;
4867 word72 tmp72 = YPAIRTO72 (cpu.Ypair);
4868 tmp72 = Sub72b (cpup, convert_to_word72 (cpu.rA, cpu.rQ), tmp72, 1,
4869 I_ZNOC, & cpu.cu.IR,
4870 & ovf);
4871 convert_to_word36 (tmp72, & cpu.rA, & cpu.rQ);
4872 #if defined(TESTING)
4873 HDBGRegAW ("sbaq");
4874 HDBGRegQW ("sbaq");
4875 #endif
4876 overflow (cpup, ovf, false, "sbaq overflow fault");
4877 }
4878 break;
4879
4880 case x0 (0135):
4881 {
4882
4883
4884 L68_ (cpu.ou.cycle |= ou_GOS;)
4885 #if defined(TESTING)
4886 HDBGRegAR ("sbla");
4887 #endif
4888 bool ovf;
4889 cpu.rA = Sub36b (cpup, cpu.rA, cpu.CY, 1, I_ZNC, & cpu.cu.IR, & ovf);
4890 #if defined(TESTING)
4891 HDBGRegAW ("sbla");
4892 #endif
4893 }
4894 break;
4895
4896 case x0 (0137):
4897 {
4898
4899
4900
4901
4902
4903
4904 L68_ (cpu.ou.cycle |= ou_GOS;)
4905 #if defined(TESTING)
4906 HDBGRegAR ("sblaq");
4907 HDBGRegQR ("sblaq");
4908 #endif
4909 bool ovf;
4910 word72 tmp72 = YPAIRTO72 (cpu.Ypair);
4911
4912 tmp72 = Sub72b (cpup, convert_to_word72 (cpu.rA, cpu.rQ), tmp72, 1,
4913 I_ZNC, & cpu.cu.IR, & ovf);
4914 convert_to_word36 (tmp72, & cpu.rA, & cpu.rQ);
4915 #if defined(TESTING)
4916 HDBGRegAW ("sblaq");
4917 HDBGRegQW ("sblaq");
4918 #endif
4919 }
4920 break;
4921
4922 case x0 (0136):
4923 {
4924
4925 L68_ (cpu.ou.cycle |= ou_GOS;)
4926 #if defined(TESTING)
4927 HDBGRegQR ("sblq");
4928 #endif
4929 bool ovf;
4930 cpu.rQ = Sub36b (cpup, cpu.rQ, cpu.CY, 1, I_ZNC, & cpu.cu.IR, & ovf);
4931 #if defined(TESTING)
4932 HDBGRegQW ("sblq");
4933 #endif
4934 }
4935 break;
4936
4937
4938 case x0 (0120):
4939 case x0 (0121):
4940 case x0 (0122):
4941 case x0 (0123):
4942 case x0 (0124):
4943 case x0 (0125):
4944 case x0 (0126):
4945 case x0 (0127):
4946 {
4947
4948
4949
4950 L68_ (cpu.ou.cycle |= ou_GOS;)
4951 uint32 n = opcode10 & 07;
4952 #if defined(TESTING)
4953 HDBGRegXR (n, "sblxn");
4954 #endif
4955 bool ovf;
4956 cpu.rX[n] = Sub18b (cpup, cpu.rX[n], GETHI (cpu.CY), 1,
4957 I_ZNC, & cpu.cu.IR, & ovf);
4958 #if defined(TESTING)
4959 HDBGRegXW (n, "sblxn");
4960 #endif
4961 }
4962 break;
4963
4964 case x0 (0176):
4965 {
4966
4967 L68_ (cpu.ou.cycle |= ou_GOS;)
4968 #if defined(TESTING)
4969 HDBGRegQR ("sbq");
4970 #endif
4971 bool ovf;
4972 cpu.rQ = Sub36b (cpup, cpu.rQ, cpu.CY, 1, I_ZNOC, & cpu.cu.IR, & ovf);
4973 #if defined(TESTING)
4974 HDBGRegQW ("sbq");
4975 #endif
4976 overflow (cpup, ovf, false, "sbq overflow fault");
4977 }
4978 break;
4979
4980
4981 case x0 (0160):
4982 case x0 (0161):
4983 case x0 (0162):
4984 case x0 (0163):
4985 case x0 (0164):
4986 case x0 (0165):
4987 case x0 (0166):
4988 case x0 (0167):
4989 {
4990
4991
4992
4993 L68_ (cpu.ou.cycle |= ou_GOS;)
4994 uint32 n = opcode10 & 07;
4995 #if defined(TESTING)
4996 HDBGRegXR (n, "sbxn");
4997 #endif
4998 bool ovf;
4999 cpu.rX[n] = Sub18b (cpup, cpu.rX[n], GETHI (cpu.CY), 1,
5000 I_ZNOC, & cpu.cu.IR, & ovf);
5001 #if defined(TESTING)
5002 HDBGRegXW (n, "sbxn");
5003 #endif
5004 overflow (cpup, ovf, false, "sbxn overflow fault");
5005 }
5006 break;
5007
5008 case x0 (0155):
5009 {
5010
5011
5012 L68_ (cpu.ou.cycle |= ou_GOS;)
5013 #if defined(TESTING)
5014 HDBGRegAR ("ssa");
5015 #endif
5016 bool ovf;
5017 cpu.CY = Sub36b (cpup, cpu.rA, cpu.CY, 1, I_ZNOC, & cpu.cu.IR, & ovf);
5018 overflow (cpup, ovf, true, "ssa overflow fault");
5019 }
5020 break;
5021
5022 case x0 (0156):
5023 {
5024
5025
5026 L68_ (cpu.ou.cycle |= ou_GOS;)
5027 #if defined(TESTING)
5028 HDBGRegQR ("ssq");
5029 #endif
5030 bool ovf;
5031 cpu.CY = Sub36b (cpup, cpu.rQ, cpu.CY, 1, I_ZNOC, & cpu.cu.IR, & ovf);
5032 overflow (cpup, ovf, true, "ssq overflow fault");
5033 }
5034 break;
5035
5036
5037 case x0 (0140):
5038 case x0 (0141):
5039 case x0 (0142):
5040 case x0 (0143):
5041 case x0 (0144):
5042 case x0 (0145):
5043 case x0 (0146):
5044 case x0 (0147):
5045 {
5046
5047
5048
5049 L68_ (cpu.ou.cycle |= ou_GOS;)
5050 uint32 n = opcode10 & 07;
5051 #if defined(TESTING)
5052 HDBGRegXR (n, "ssxn");
5053 #endif
5054 bool ovf;
5055 word18 tmp18 = Sub18b (cpup, cpu.rX[n], GETHI (cpu.CY), 1,
5056 I_ZNOC, & cpu.cu.IR, & ovf);
5057 SETHI (cpu.CY, tmp18);
5058 overflow (cpup, ovf, true, "ssxn overflow fault");
5059 }
5060 break;
5061
5062 case x0 (0171):
5063 {
5064
5065
5066
5067 L68_ (cpu.ou.cycle |= ou_GOS;)
5068 #if defined(TESTING)
5069 HDBGRegAR ("swca");
5070 #endif
5071 bool ovf;
5072 cpu.rA = Sub36b (cpup, cpu.rA, cpu.CY, TST_I_CARRY ? 1 : 0,
5073 I_ZNOC, & cpu.cu.IR, & ovf);
5074 #if defined(TESTING)
5075 HDBGRegAW ("swca");
5076 #endif
5077 overflow (cpup, ovf, false, "swca overflow fault");
5078 }
5079 break;
5080
5081 case x0 (0172):
5082 {
5083
5084
5085
5086 L68_ (cpu.ou.cycle |= ou_GOS;)
5087 #if defined(TESTING)
5088 HDBGRegQR ("swcq");
5089 #endif
5090 bool ovf;
5091 cpu.rQ = Sub36b (cpup, cpu.rQ, cpu.CY, TST_I_CARRY ? 1 : 0,
5092 I_ZNOC, & cpu.cu.IR, & ovf);
5093 #if defined(TESTING)
5094 HDBGRegQW ("swcq");
5095 #endif
5096 overflow (cpup, ovf, false, "swcq overflow fault");
5097 }
5098 break;
5099
5100
5101
5102 case x0 (0401):
5103 {
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113 L68_ (cpu.ou.cycle |= ou_GD1;)
5114 #if defined(NEED_128)
5115 # if defined(TESTING)
5116 HDBGRegAR ("mpf");
5117 HDBGRegQR ("mpf");
5118 # endif
5119 word72 tmp72 = multiply_128 (SIGNEXT36_72 (cpu.rA), SIGNEXT36_72 (cpu.CY));
5120 tmp72 = and_128 (tmp72, MASK72);
5121 tmp72 = lshift_128 (tmp72, 1);
5122 #else
5123
5124
5125 word72 tmp72 = (word72) (((word72s) SIGNEXT36_72 (cpu.rA)) * ((word72s) SIGNEXT36_72 (cpu.CY)));
5126 tmp72 &= MASK72;
5127 tmp72 <<= 1;
5128 #endif
5129 L68_ (cpu.ou.cycle |= ou_GD2;)
5130
5131
5132 if (cpu.rA == MAXNEG && cpu.CY == MAXNEG)
5133 {
5134 SET_I_NEG;
5135 CLR_I_ZERO;
5136 overflow (cpup, true, false, "mpf overflow fault");
5137 }
5138
5139 convert_to_word36 (tmp72, &cpu.rA, &cpu.rQ);
5140 #if defined(TESTING)
5141 HDBGRegAW ("mpf");
5142 HDBGRegQW ("mpf");
5143 #endif
5144 SC_I_ZERO (cpu.rA == 0 && cpu.rQ == 0);
5145 SC_I_NEG (cpu.rA & SIGN36);
5146 }
5147 break;
5148
5149 case x0 (0402):
5150
5151
5152 {
5153 L68_ (cpu.ou.cycle |= ou_GOS;)
5154 #if defined(NEED_128)
5155 # if defined(TESTING)
5156 HDBGRegQR ("mpy");
5157 # endif
5158 int128 prod = multiply_s128 (
5159 SIGNEXT36_128 (cpu.rQ & DMASK),
5160 SIGNEXT36_128 (cpu.CY & DMASK));
5161 convert_to_word36 (cast_128 (prod), &cpu.rA, &cpu.rQ);
5162 #else
5163 int64_t t0 = SIGNEXT36_64 (cpu.rQ & DMASK);
5164 int64_t t1 = SIGNEXT36_64 (cpu.CY & DMASK);
5165
5166 __int128_t prod = (__int128_t) t0 * (__int128_t) t1;
5167
5168 convert_to_word36 ((word72)prod, &cpu.rA, &cpu.rQ);
5169 #endif
5170 #if defined(TESTING)
5171 HDBGRegAW ("mpy");
5172 HDBGRegQW ("mpy");
5173 #endif
5174
5175 SC_I_ZERO (cpu.rA == 0 && cpu.rQ == 0);
5176 SC_I_NEG (cpu.rA & SIGN36);
5177 }
5178 break;
5179
5180
5181
5182
5183
5184 case x0 (0506):
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198 L68_ (cpu.ou.cycle |= ou_GD1;)
5199
5200
5201
5202 #if defined(TESTING)
5203 HDBGRegQR ("div");
5204 #endif
5205 if ((cpu.rQ == MAXNEG && (cpu.CY == 1 || cpu.CY == NEG136)) ||
5206 (cpu.CY == 0))
5207 {
5208
5209
5210
5211
5212 cpu.rA = (cpu.rQ & SIGN36) ? 0 : SIGN36;
5213 #if defined(TESTING)
5214 HDBGRegAW ("div");
5215 #endif
5216
5217
5218 SC_I_ZERO (cpu.CY == 0);
5219 SC_I_NEG (cpu.rQ & SIGN36);
5220
5221 if (cpu.rQ & SIGN36)
5222 {
5223
5224
5225 cpu.rQ = ((word36) (- (word36s) cpu.rQ)) & MASK36;
5226 #if defined(TESTING)
5227 HDBGRegQW ("div");
5228 #endif
5229 }
5230
5231 dlyDoFault (FAULT_DIV,
5232 fst_ill_op,
5233 "div divide check");
5234 }
5235 else
5236 {
5237 t_int64 dividend = (t_int64) (SIGNEXT36_64 (cpu.rQ));
5238 t_int64 divisor = (t_int64) (SIGNEXT36_64 (cpu.CY));
5239 #if defined(TESTING)
5240 # if defined(DIV_TRACE)
5241 sim_debug (DBG_CAC, & cpu_dev, "\n");
5242 sim_debug (DBG_CAC, & cpu_dev,
5243 ">>> dividend cpu.rQ %"PRId64" (%012"PRIo64")\n",
5244 dividend, cpu.rQ);
5245 sim_debug (DBG_CAC, & cpu_dev,
5246 ">>> divisor CY %"PRId64" (%012"PRIo64")\n",
5247 divisor, cpu.CY);
5248 # endif
5249 #endif
5250
5251 t_int64 quotient = dividend / divisor;
5252 L68_ (cpu.ou.cycle |= ou_GD2;)
5253 t_int64 remainder = dividend % divisor;
5254 #if defined(TESTING)
5255 # if defined(DIV_TRACE)
5256 sim_debug (DBG_CAC, & cpu_dev, ">>> quot 1 %"PRId64"\n", quotient);
5257 sim_debug (DBG_CAC, & cpu_dev, ">>> rem 1 %"PRId64"\n", remainder);
5258 # endif
5259 #endif
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280 #if defined(TESTING)
5281 # if defined(DIV_TRACE)
5282
5283 sim_debug (DBG_CAC, & cpu_dev,
5284 "dividend was = %"PRId64"\n", dividend);
5285 sim_debug (DBG_CAC, & cpu_dev,
5286 "quotient * divisor + remainder = %"PRId64"\n",
5287 quotient * divisor + remainder);
5288 if (dividend != quotient * divisor + remainder)
5289 {
5290 sim_debug (DBG_CAC, & cpu_dev,
5291 "---------------------------------^^^^^^^^^^^^^^^\n");
5292 }
5293 # endif
5294 #endif
5295
5296 if (dividend != quotient * divisor + remainder)
5297 {
5298 sim_debug (DBG_ERR, & cpu_dev,
5299 "Internal division error;"
5300 " rQ %012"PRIo64" CY %012"PRIo64"\n", cpu.rQ, cpu.CY);
5301 }
5302
5303 cpu.rA = (word36) remainder & DMASK;
5304 cpu.rQ = (word36) quotient & DMASK;
5305 #if defined(TESTING)
5306 HDBGRegAW ("div");
5307 HDBGRegQW ("div");
5308
5309 # if defined(DIV_TRACE)
5310 sim_debug (DBG_CAC, & cpu_dev, "rA (rem) %012"PRIo64"\n", cpu.rA);
5311 sim_debug (DBG_CAC, & cpu_dev, "rQ (quot) %012"PRIo64"\n", cpu.rQ);
5312 # endif
5313 #endif
5314
5315 SC_I_ZERO (cpu.rQ == 0);
5316 SC_I_NEG (cpu.rQ & SIGN36);
5317 }
5318
5319 break;
5320
5321 case x0 (0507):
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338 dvf (cpup);
5339
5340 break;
5341
5342
5343
5344 case x0 (0531):
5345
5346
5347 #if defined(TESTING)
5348 HDBGRegAR ("neg");
5349 #endif
5350 cpu.rA &= DMASK;
5351 if (cpu.rA == 0400000000000ULL)
5352 {
5353 CLR_I_ZERO;
5354 SET_I_NEG;
5355 overflow (cpup, true, false, "neg overflow fault");
5356 }
5357
5358
5359
5360 cpu.rA = (word36) (- (word36s) cpu.rA);
5361
5362 cpu.rA &= DMASK;
5363 #if defined(TESTING)
5364 HDBGRegAW ("neg");
5365 #endif
5366
5367 SC_I_ZERO (cpu.rA == 0);
5368 SC_I_NEG (cpu.rA & SIGN36);
5369
5370 break;
5371
5372 case x0 (0533):
5373
5374 {
5375 #if defined(TESTING)
5376 HDBGRegAR ("negl");
5377 HDBGRegQR ("negl");
5378 #endif
5379 cpu.rA &= DMASK;
5380 cpu.rQ &= DMASK;
5381
5382 if (cpu.rA == 0400000000000ULL && cpu.rQ == 0)
5383 {
5384 CLR_I_ZERO;
5385 SET_I_NEG;
5386 overflow (cpup, true, false, "negl overflow fault");
5387 }
5388
5389 word72 tmp72 = convert_to_word72 (cpu.rA, cpu.rQ);
5390 #if defined(NEED_128)
5391 tmp72 = negate_128 (tmp72);
5392
5393 SC_I_ZERO (iszero_128 (tmp72));
5394 SC_I_NEG (isnonzero_128 (and_128 (tmp72, SIGN72)));
5395 #else
5396
5397
5398 tmp72 = (word72) (-(word72s) tmp72);
5399
5400 SC_I_ZERO (tmp72 == 0);
5401 SC_I_NEG (tmp72 & SIGN72);
5402 #endif
5403
5404 convert_to_word36 (tmp72, &cpu.rA, &cpu.rQ);
5405 #if defined(TESTING)
5406 HDBGRegAW ("negl");
5407 HDBGRegQW ("negl");
5408 #endif
5409 }
5410 break;
5411
5412
5413
5414 case x0 (0405):
5415
5416
5417
5418 {
5419
5420
5421
5422
5423
5424 #if defined(TESTING)
5425 HDBGRegAR ("cmg");
5426 #endif
5427 t_int64 a = SIGNEXT36_64 (cpu.rA);
5428 if (a < 0)
5429 a = -a;
5430 t_int64 y = SIGNEXT36_64 (cpu.CY);
5431 if (y < 0)
5432 y = -y;
5433
5434 SC_I_ZERO (a == y);
5435 SC_I_NEG (a < y);
5436 }
5437 break;
5438
5439 case x0 (0211):
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458 {
5459 #if defined(TESTING)
5460 HDBGRegAR ("cmk");
5461 HDBGRegQR ("cmk");
5462 HDBGRegYR ("cmk");
5463 #endif
5464 word36 Z = ~cpu.rQ & (cpu.rA ^ cpu.CY);
5465 Z &= DMASK;
5466 #if defined(TESTING)
5467 HDBGRegZW (Z, "cmk");
5468 HDBGRegIR ("cmk");
5469 #endif
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481 SC_I_ZERO (Z == 0);
5482 SC_I_NEG (Z & SIGN36);
5483 }
5484 break;
5485
5486
5487
5488
5489 case x0 (0117):
5490
5491 {
5492 #if defined(TESTING)
5493 HDBGRegAR ("cmpaq");
5494 HDBGRegQR ("cmpaq");
5495 #endif
5496 word72 tmp72 = YPAIRTO72 (cpu.Ypair);
5497 word72 trAQ = convert_to_word72 (cpu.rA, cpu.rQ);
5498 #if defined(NEED_128)
5499 trAQ = and_128 (trAQ, MASK72);
5500 #else
5501 trAQ &= MASK72;
5502 #endif
5503 cmp72 (cpup, trAQ, tmp72, &cpu.cu.IR);
5504 }
5505 break;
5506
5507
5508
5509
5510
5511 case x0 (0100):
5512 case x0 (0101):
5513 case x0 (0102):
5514 case x0 (0103):
5515 case x0 (0104):
5516 case x0 (0105):
5517 case x0 (0106):
5518 case x0 (0107):
5519
5520
5521 {
5522 uint32 n = opcode10 & 07;
5523 #if defined(TESTING)
5524 HDBGRegXR (n, "cmpxn");
5525 #endif
5526 cmp18 (cpup, cpu.rX[n], GETHI (cpu.CY), &cpu.cu.IR);
5527 }
5528 break;
5529
5530 case x0 (0111):
5531
5532
5533
5534
5535
5536
5537
5538 #if defined(TESTING)
5539 HDBGRegAR ("cwl");
5540 HDBGRegQR ("cwl");
5541 #endif
5542 cmp36wl (cpup, cpu.rA, cpu.CY, cpu.rQ, &cpu.cu.IR);
5543 break;
5544
5545
5546
5547 case x0 (0234):
5548
5549 cpu.CY &= DMASK;
5550 SC_I_ZERO (cpu.CY == 0);
5551 SC_I_NEG (cpu.CY & SIGN36);
5552 break;
5553
5554 case x0 (0214):
5555
5556 cpu.CY &= DMASK;
5557 SC_I_ZERO (cpu.CY == 0);
5558 SC_I_NEG (cpu.CY & SIGN36);
5559
5560 cpu.CY = 0;
5561 break;
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573 case x0 (0376):
5574
5575 #if defined(TESTING)
5576 HDBGRegQR ("anq");
5577 #endif
5578 cpu.rQ = cpu.rQ & cpu.CY;
5579 cpu.rQ &= DMASK;
5580 #if defined(TESTING)
5581 HDBGRegQW ("anq");
5582 #endif
5583
5584 SC_I_ZERO (cpu.rQ == 0);
5585 SC_I_NEG (cpu.rQ & SIGN36);
5586 break;
5587
5588 case x0 (0355):
5589
5590 {
5591 #if defined(TESTING)
5592 HDBGRegAR ("ansa");
5593 #endif
5594 cpu.CY = cpu.rA & cpu.CY;
5595 cpu.CY &= DMASK;
5596
5597 SC_I_ZERO (cpu.CY == 0);
5598 SC_I_NEG (cpu.CY & SIGN36);
5599 }
5600 break;
5601
5602 case x0 (0356):
5603
5604 {
5605 #if defined(TESTING)
5606 HDBGRegQR ("ansq");
5607 #endif
5608 cpu.CY = cpu.rQ & cpu.CY;
5609 cpu.CY &= DMASK;
5610
5611 SC_I_ZERO (cpu.CY == 0);
5612 SC_I_NEG (cpu.CY & SIGN36);
5613 }
5614 break;
5615
5616
5617 case x0 (0340):
5618 case x0 (0341):
5619 case x0 (0342):
5620 case x0 (0343):
5621 case x0 (0344):
5622 case x0 (0345):
5623 case x0 (0346):
5624 case x0 (0347):
5625
5626
5627 {
5628 uint32 n = opcode10 & 07;
5629 #if defined(TESTING)
5630 HDBGRegXR (n, "ansxn");
5631 #endif
5632 word18 tmp18 = cpu.rX[n] & GETHI (cpu.CY);
5633 tmp18 &= MASK18;
5634
5635 SC_I_ZERO (tmp18 == 0);
5636 SC_I_NEG (tmp18 & SIGN18);
5637
5638 SETHI (cpu.CY, tmp18);
5639 }
5640
5641 break;
5642
5643
5644 case x0 (0360):
5645 case x0 (0361):
5646 case x0 (0362):
5647 case x0 (0363):
5648 case x0 (0364):
5649 case x0 (0365):
5650 case x0 (0366):
5651 case x0 (0367):
5652
5653
5654 {
5655 uint32 n = opcode10 & 07;
5656 #if defined(TESTING)
5657 HDBGRegXR (n, "anxn");
5658 #endif
5659 cpu.rX[n] &= GETHI (cpu.CY);
5660 cpu.rX[n] &= MASK18;
5661 #if defined(TESTING)
5662 HDBGRegXW (n, "anxn");
5663 #endif
5664
5665 SC_I_ZERO (cpu.rX[n] == 0);
5666 SC_I_NEG (cpu.rX[n] & SIGN18);
5667 }
5668 break;
5669
5670
5671
5672
5673
5674
5675 case x0 (0277):
5676
5677 {
5678 #if defined(TESTING)
5679 HDBGRegAR ("oraq");
5680 HDBGRegQR ("oraq");
5681 #endif
5682 word72 tmp72 = YPAIRTO72 (cpu.Ypair);
5683 word72 trAQ = convert_to_word72 (cpu.rA, cpu.rQ);
5684 #if defined(NEED_128)
5685 trAQ = or_128 (trAQ, tmp72);
5686 trAQ = and_128 (trAQ, MASK72);
5687
5688 SC_I_ZERO (iszero_128 (trAQ));
5689 SC_I_NEG (isnonzero_128 (and_128 (trAQ, SIGN72)));
5690 #else
5691 trAQ = trAQ | tmp72;
5692 trAQ &= MASK72;
5693
5694 SC_I_ZERO (trAQ == 0);
5695 SC_I_NEG (trAQ & SIGN72);
5696 #endif
5697 convert_to_word36 (trAQ, &cpu.rA, &cpu.rQ);
5698 #if defined(TESTING)
5699 HDBGRegAW ("oraq");
5700 HDBGRegQW ("oraq");
5701 #endif
5702 }
5703 break;
5704
5705 case x0 (0276):
5706
5707 #if defined(TESTING)
5708 HDBGRegQR ("orq");
5709 #endif
5710 cpu.rQ = cpu.rQ | cpu.CY;
5711 cpu.rQ &= DMASK;
5712 #if defined(TESTING)
5713 HDBGRegQW ("orq");
5714 #endif
5715
5716 SC_I_ZERO (cpu.rQ == 0);
5717 SC_I_NEG (cpu.rQ & SIGN36);
5718
5719 break;
5720
5721 case x0 (0255):
5722
5723 #if defined(TESTING)
5724 HDBGRegAR ("orsa");
5725 #endif
5726 cpu.CY = cpu.rA | cpu.CY;
5727 cpu.CY &= DMASK;
5728
5729 SC_I_ZERO (cpu.CY == 0);
5730 SC_I_NEG (cpu.CY & SIGN36);
5731 break;
5732
5733 case x0 (0256):
5734
5735 #if defined(TESTING)
5736 HDBGRegQR ("orsq");
5737 #endif
5738 cpu.CY = cpu.rQ | cpu.CY;
5739 cpu.CY &= DMASK;
5740
5741 SC_I_ZERO (cpu.CY == 0);
5742 SC_I_NEG (cpu.CY & SIGN36);
5743 break;
5744
5745
5746 case x0 (0240):
5747 case x0 (0241):
5748 case x0 (0242):
5749 case x0 (0243):
5750 case x0 (0244):
5751 case x0 (0245):
5752 case x0 (0246):
5753 case x0 (0247):
5754
5755
5756 {
5757 uint32 n = opcode10 & 07;
5758
5759 word18 tmp18 = cpu.rX[n] | GETHI (cpu.CY);
5760 tmp18 &= MASK18;
5761
5762 SC_I_ZERO (tmp18 == 0);
5763 SC_I_NEG (tmp18 & SIGN18);
5764
5765 SETHI (cpu.CY, tmp18);
5766 }
5767 break;
5768
5769
5770 case x0 (0260):
5771 case x0 (0261):
5772 case x0 (0262):
5773 case x0 (0263):
5774 case x0 (0264):
5775 case x0 (0265):
5776 case x0 (0266):
5777 case x0 (0267):
5778
5779
5780 {
5781 uint32 n = opcode10 & 07;
5782 #if defined(TESTING)
5783 HDBGRegXR (n, "orxn");
5784 #endif
5785 cpu.rX[n] |= GETHI (cpu.CY);
5786 cpu.rX[n] &= MASK18;
5787 #if defined(TESTING)
5788 HDBGRegXW (n, "orxn");
5789 #endif
5790
5791 SC_I_ZERO (cpu.rX[n] == 0);
5792 SC_I_NEG (cpu.rX[n] & SIGN18);
5793 }
5794 break;
5795
5796
5797
5798 case x0 (0675):
5799
5800 #if defined(TESTING)
5801 HDBGRegAR ("era");
5802 #endif
5803 cpu.rA = cpu.rA ^ cpu.CY;
5804 cpu.rA &= DMASK;
5805 #if defined(TESTING)
5806 HDBGRegAW ("era");
5807 #endif
5808
5809 SC_I_ZERO (cpu.rA == 0);
5810 SC_I_NEG (cpu.rA & SIGN36);
5811
5812 break;
5813
5814
5815
5816
5817 case x0 (0676):
5818
5819 #if defined(TESTING)
5820 HDBGRegQR ("eraq");
5821 #endif
5822 cpu.rQ = cpu.rQ ^ cpu.CY;
5823 cpu.rQ &= DMASK;
5824 #if defined(TESTING)
5825 HDBGRegQW ("eraq");
5826 #endif
5827 SC_I_ZERO (cpu.rQ == 0);
5828 SC_I_NEG (cpu.rQ & SIGN36);
5829 break;
5830
5831 case x0 (0655):
5832
5833 #if defined(TESTING)
5834 HDBGRegAR ("ersa");
5835 #endif
5836 cpu.CY = cpu.rA ^ cpu.CY;
5837 cpu.CY &= DMASK;
5838
5839 SC_I_ZERO (cpu.CY == 0);
5840 SC_I_NEG (cpu.CY & SIGN36);
5841 break;
5842
5843 case x0 (0656):
5844
5845 #if defined(TESTING)
5846 HDBGRegQR ("ersq");
5847 #endif
5848 cpu.CY = cpu.rQ ^ cpu.CY;
5849 cpu.CY &= DMASK;
5850
5851 SC_I_ZERO (cpu.CY == 0);
5852 SC_I_NEG (cpu.CY & SIGN36);
5853
5854 break;
5855
5856
5857 case x0 (0640):
5858 case x0 (0641):
5859 case x0 (0642):
5860 case x0 (0643):
5861 case x0 (0644):
5862 case x0 (0645):
5863 case x0 (0646):
5864 case x0 (0647):
5865
5866
5867 {
5868 uint32 n = opcode10 & 07;
5869 #if defined(TESTING)
5870 HDBGRegXR (n, "ersxn");
5871 #endif
5872
5873 word18 tmp18 = cpu.rX[n] ^ GETHI (cpu.CY);
5874 tmp18 &= MASK18;
5875
5876 SC_I_ZERO (tmp18 == 0);
5877 SC_I_NEG (tmp18 & SIGN18);
5878
5879 SETHI (cpu.CY, tmp18);
5880 }
5881 break;
5882
5883
5884 case x0 (0660):
5885 case x0 (0661):
5886 case x0 (0662):
5887 case x0 (0663):
5888 case x0 (0664):
5889 case x0 (0665):
5890 case x0 (0666):
5891 case x0 (0667):
5892
5893
5894 {
5895 uint32 n = opcode10 & 07;
5896 #if defined(TESTING)
5897 HDBGRegXR (n, "erxn");
5898 #endif
5899 cpu.rX[n] ^= GETHI (cpu.CY);
5900 cpu.rX[n] &= MASK18;
5901 #if defined(TESTING)
5902 HDBGRegXW (n, "erxn");
5903 #endif
5904
5905 SC_I_ZERO (cpu.rX[n] == 0);
5906 SC_I_NEG (cpu.rX[n] & SIGN18);
5907 }
5908 break;
5909
5910
5911
5912
5913
5914
5915 case x0 (0317):
5916
5917 {
5918 #if defined(TESTING)
5919 HDBGRegAR ("canaq");
5920 HDBGRegQR ("canaq");
5921 #endif
5922 word72 tmp72 = YPAIRTO72 (cpu.Ypair);
5923 word72 trAQ = convert_to_word72 (cpu.rA, cpu.rQ);
5924 #if defined(NEED_128)
5925 trAQ = and_128 (trAQ, tmp72);
5926 trAQ = and_128 (trAQ, MASK72);
5927
5928 SC_I_ZERO (iszero_128 (trAQ));
5929 SC_I_NEG (isnonzero_128 (and_128 (trAQ, SIGN72)));
5930 #else
5931 trAQ = trAQ & tmp72;
5932 trAQ &= MASK72;
5933
5934 SC_I_ZERO (trAQ == 0);
5935 SC_I_NEG (trAQ & SIGN72);
5936 #endif
5937 }
5938 break;
5939
5940 case x0 (0316):
5941
5942 {
5943 #if defined(TESTING)
5944 HDBGRegQR ("canq");
5945 #endif
5946 word36 trZ = cpu.rQ & cpu.CY;
5947 trZ &= DMASK;
5948
5949 SC_I_ZERO (trZ == 0);
5950 SC_I_NEG (trZ & SIGN36);
5951 }
5952 break;
5953
5954
5955 case x0 (0300):
5956 case x0 (0301):
5957 case x0 (0302):
5958 case x0 (0303):
5959 case x0 (0304):
5960 case x0 (0305):
5961 case x0 (0306):
5962 case x0 (0307):
5963
5964
5965 {
5966 uint32 n = opcode10 & 07;
5967 #if defined(TESTING)
5968 HDBGRegXR (n, "canxn");
5969 #endif
5970 word18 tmp18 = cpu.rX[n] & GETHI (cpu.CY);
5971 tmp18 &= MASK18;
5972 sim_debug (DBG_TRACEEXT, & cpu_dev,
5973 "n %o rX %06o HI %06o tmp %06o\n",
5974 n, cpu.rX[n], (word18) (GETHI (cpu.CY) & MASK18),
5975 tmp18);
5976
5977 SC_I_ZERO (tmp18 == 0);
5978 SC_I_NEG (tmp18 & SIGN18);
5979 }
5980 break;
5981
5982
5983
5984 case x0 (0215):
5985
5986 {
5987 #if defined(TESTING)
5988 HDBGRegAR ("cnaa");
5989 #endif
5990 word36 trZ = cpu.rA & ~cpu.CY;
5991 trZ &= DMASK;
5992
5993 SC_I_ZERO (trZ == 0);
5994 SC_I_NEG (trZ & SIGN36);
5995 }
5996 break;
5997
5998 case x0 (0217):
5999
6000 {
6001 #if defined(TESTING)
6002 HDBGRegAR ("cnaaq");
6003 HDBGRegQR ("cnaaq");
6004 #endif
6005 word72 tmp72 = YPAIRTO72 (cpu.Ypair);
6006
6007 word72 trAQ = convert_to_word72 (cpu.rA, cpu.rQ);
6008 #if defined(NEED_128)
6009 trAQ = and_128 (trAQ, complement_128 (tmp72));
6010 trAQ = and_128 (trAQ, MASK72);
6011
6012 SC_I_ZERO (iszero_128 (trAQ));
6013 SC_I_NEG (isnonzero_128 (and_128 (trAQ, SIGN72)));
6014 #else
6015 trAQ = trAQ & ~tmp72;
6016 trAQ &= MASK72;
6017
6018 SC_I_ZERO (trAQ == 0);
6019 SC_I_NEG (trAQ & SIGN72);
6020 #endif
6021 }
6022 break;
6023
6024 case x0 (0216):
6025
6026 {
6027 #if defined(TESTING)
6028 HDBGRegQR ("cnaq");
6029 #endif
6030 word36 trZ = cpu.rQ & ~cpu.CY;
6031 trZ &= DMASK;
6032 SC_I_ZERO (trZ == 0);
6033 SC_I_NEG (trZ & SIGN36);
6034 }
6035 break;
6036
6037
6038 case x0 (0200):
6039 case x0 (0201):
6040 case x0 (0202):
6041 case x0 (0203):
6042 case x0 (0204):
6043 case x0 (0205):
6044 case x0 (0206):
6045 case x0 (0207):
6046
6047 {
6048 uint32 n = opcode10 & 07;
6049 #if defined(TESTING)
6050 HDBGRegXR (n, "cnaxn");
6051 #endif
6052 word18 tmp18 = cpu.rX[n] & ~GETHI (cpu.CY);
6053 tmp18 &= MASK18;
6054
6055 SC_I_ZERO (tmp18 == 0);
6056 SC_I_NEG (tmp18 & SIGN18);
6057 }
6058 break;
6059
6060
6061
6062
6063
6064 case x0 (0433):
6065
6066
6067
6068
6069
6070
6071 CPTUR (cptUseE);
6072 cpu.rE = (cpu.Ypair[0] >> 28) & MASK8;
6073
6074 cpu.rA = (cpu.Ypair[0] & FLOAT36MASK) << 8;
6075 cpu.rA |= (cpu.Ypair[1] >> 28) & MASK8;
6076
6077 cpu.rQ = (cpu.Ypair[1] & FLOAT36MASK) << 8;
6078
6079 #if defined(TESTING)
6080 HDBGRegAW ("dfld");
6081 HDBGRegQW ("dfld");
6082 #endif
6083
6084 SC_I_ZERO (cpu.rA == 0 && cpu.rQ == 0);
6085 SC_I_NEG (cpu.rA & SIGN36);
6086 break;
6087
6088
6089
6090
6091
6092
6093 case x0 (0457):
6094
6095
6096
6097 CPTUR (cptUseE);
6098 #if defined(TESTING)
6099 HDBGRegAR ("dfst");
6100 HDBGRegQR ("dfst");
6101 #endif
6102 cpu.Ypair[0] = ((word36)cpu.rE << 28) |
6103 ((cpu.rA & 0777777777400LLU) >> 8);
6104 cpu.Ypair[1] = ((cpu.rA & 0377) << 28) |
6105 ((cpu.rQ & 0777777777400LLU) >> 8);
6106
6107 break;
6108
6109 case x0 (0472):
6110
6111 dfstr (cpup, cpu.Ypair);
6112 break;
6113
6114 case x0 (0455):
6115
6116
6117 CPTUR (cptUseE);
6118 #if defined(TESTING)
6119 HDBGRegAR ("fst");
6120 #endif
6121 cpu.rE &= MASK8;
6122 cpu.rA &= DMASK;
6123 cpu.CY = ((word36)cpu.rE << 28) | (((cpu.rA >> 8) & 01777777777LL));
6124 break;
6125
6126 case x0 (0470):
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150 fstr (cpup, &cpu.CY);
6151
6152 break;
6153
6154
6155
6156 case x0 (0477):
6157
6158
6159
6160 CPTUR (cptUseE);
6161 #if defined(TESTING)
6162 HDBGRegAR ("dfad");
6163 HDBGRegQR ("dfad");
6164 #endif
6165 dufa (cpup, false, true);
6166 #if defined(TESTING)
6167 HDBGRegAW ("dfad");
6168 HDBGRegQW ("dfad");
6169 #endif
6170 break;
6171
6172 case x0 (0437):
6173 dufa (cpup, false, false);
6174 break;
6175
6176 case x0 (0475):
6177
6178
6179
6180
6181 CPTUR (cptUseE);
6182 #if defined(TESTING)
6183 HDBGRegAR ("fad");
6184 HDBGRegQR ("fad");
6185 #endif
6186 ufa (cpup, false, true);
6187 #if defined(TESTING)
6188 HDBGRegAW ("fad");
6189 HDBGRegQW ("fad");
6190 #endif
6191
6192 break;
6193
6194 case x0 (0435):
6195
6196
6197 ufa (cpup, false, false);
6198 break;
6199
6200
6201
6202 case x0 (0577):
6203
6204
6205
6206
6207 CPTUR (cptUseE);
6208 #if defined(TESTING)
6209 HDBGRegAR ("dfsb");
6210 HDBGRegQR ("dfsb");
6211 #endif
6212 dufa (cpup, true, true);
6213 #if defined(TESTING)
6214 HDBGRegAW ("dfsb");
6215 HDBGRegQW ("dfsb");
6216 #endif
6217 break;
6218
6219 case x0 (0537):
6220 dufa (cpup, true, false);
6221 break;
6222
6223 case x0 (0575):
6224
6225
6226 #if defined(TESTING)
6227 HDBGRegAR ("fsb");
6228 HDBGRegQR ("fsb");
6229 #endif
6230 CPTUR (cptUseE);
6231 ufa (cpup, true, true);
6232 #if defined(TESTING)
6233 HDBGRegAW ("fsb");
6234 HDBGRegQW ("fsb");
6235 #endif
6236 break;
6237
6238 case x0 (0535):
6239
6240 ufa (cpup, true, false);
6241 break;
6242
6243
6244
6245 case x0 (0463):
6246
6247
6248
6249 CPTUR (cptUseE);
6250 #if defined(TESTING)
6251 HDBGRegAR ("dfmp");
6252 HDBGRegQR ("dfmp");
6253 #endif
6254 dufm (cpup, true);
6255 #if defined(TESTING)
6256 HDBGRegAW ("dfmp");
6257 HDBGRegQW ("dfmp");
6258 #endif
6259 break;
6260
6261 case x0 (0423):
6262
6263 dufm (cpup, false);
6264 break;
6265
6266 case x0 (0461):
6267
6268
6269
6270 CPTUR (cptUseE);
6271 ufm (cpup, true);
6272 #if defined(TESTING)
6273 HDBGRegAW ("fmp");
6274 HDBGRegQW ("fmp");
6275 #endif
6276 break;
6277
6278 case x0 (0421):
6279
6280 ufm (cpup, false);
6281 break;
6282
6283
6284
6285 case x0 (0527):
6286
6287 dfdi (cpup);
6288 break;
6289
6290 case x0 (0567):
6291
6292 dfdv (cpup);
6293 break;
6294
6295 case x0 (0525):
6296
6297
6298 fdi (cpup);
6299 break;
6300
6301 case x0 (0565):
6302
6303
6304 fdv (cpup);
6305 break;
6306
6307
6308
6309 case x0 (0513):
6310
6311 fneg (cpup);
6312 break;
6313
6314
6315
6316 case x0 (0573):
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331 CPTUR (cptUseE);
6332 fno (cpup, & cpu.rE, & cpu.rA, & cpu.rQ);
6333 #if defined(TESTING)
6334 HDBGRegAW ("fno");
6335 HDBGRegQW ("fno");
6336 #endif
6337 break;
6338
6339
6340
6341 case x0 (0473):
6342
6343
6344
6345 dfrd (cpup);
6346 break;
6347
6348 case x0 (0471):
6349
6350
6351
6352 frd (cpup);
6353 break;
6354
6355
6356
6357 case x0 (0427):
6358
6359
6360
6361 dfcmg (cpup);
6362 break;
6363
6364 case x0 (0517):
6365
6366
6367
6368 dfcmp (cpup);
6369 break;
6370
6371 case x0 (0425):
6372
6373
6374
6375 fcmg (cpup);
6376 break;
6377
6378 case x0 (0515):
6379
6380
6381
6382 fcmp (cpup);
6383 break;
6384
6385
6386
6387 case x0 (0415):
6388
6389 {
6390 CPTUR (cptUseE);
6391 int y = SIGNEXT8_int ((cpu.CY >> 28) & 0377);
6392 int e = SIGNEXT8_int (cpu.rE);
6393 e = e + y;
6394
6395 cpu.rE = e & 0377;
6396 CLR_I_ZERO;
6397 CLR_I_NEG;
6398
6399 if (e > 127)
6400 {
6401 SET_I_EOFL;
6402 if (tstOVFfault (cpup))
6403 doFault (FAULT_OFL, fst_zero, "ade exp overflow fault");
6404 }
6405
6406 if (e < -128)
6407 {
6408 SET_I_EUFL;
6409 if (tstOVFfault (cpup))
6410 doFault (FAULT_OFL, fst_zero, "ade exp underflow fault");
6411 }
6412 }
6413 break;
6414
6415 case x0 (0430):
6416
6417
6418
6419
6420 SC_I_ZERO ((cpu.CY & 001777777777LL) == 0);
6421 SC_I_NEG (cpu.CY & 001000000000LL);
6422
6423 break;
6424
6425 case x0 (0411):
6426
6427
6428 CPTUR (cptUseE);
6429 cpu.rE = (cpu.CY >> 28) & 0377;
6430 CLR_I_ZERO;
6431 CLR_I_NEG;
6432
6433 break;
6434
6435 case x0 (0456):
6436
6437
6438
6439 CPTUR (cptUseE);
6440
6441 cpu.CY = ((word36) (cpu.rE & 0377)) << 28;
6442 cpu.zone = 0777777000000;
6443 cpu.useZone = true;
6444 break;
6445
6446
6447
6448 case x0 (0713):
6449
6450 CPTUR (cptUsePRn + 7);
6451
6452 do_caf (cpup);
6453 read_tra_op (cpup);
6454 sim_debug (DBG_TRACEEXT, & cpu_dev,
6455 "call6 PRR %o PSR %o\n", cpu.PPR.PRR, cpu.PPR.PSR);
6456
6457 return CONT_TRA;
6458
6459 case x0 (0630):
6460 {
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471 do_caf (cpup);
6472 ReadOperandRead (cpup, cpu.TPR.CA, & cpu.CY);
6473
6474 cpu.PPR.IC = GETHI (cpu.CY);
6475 word18 tempIR = GETLO (cpu.CY) & 0777770;
6476
6477 if (is_priv_mode (cpup))
6478 {
6479
6480
6481
6482
6483 SCF (TST_I_MIF, tempIR, I_MIF);
6484 }
6485 else
6486 {
6487 CLRF (tempIR, I_MIF);
6488 }
6489
6490
6491
6492
6493
6494
6495
6496
6497 if (! (TST_I_NBAR && TSTF (tempIR, I_NBAR)))
6498 {
6499 CLRF (tempIR, I_NBAR);
6500 }
6501 if (! (TST_I_ABS && TSTF (tempIR, I_ABS)))
6502 {
6503 CLRF (tempIR, I_ABS);
6504 }
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514 CPTUR (cptUseIR);
6515 cpu.cu.IR = tempIR;
6516 return CONT_RET;
6517 }
6518
6519
6520
6521
6522 case x0 (0614):
6523
6524
6525
6526
6527 if (TST_I_EOFL)
6528 {
6529 CLR_I_EOFL;
6530 do_caf (cpup);
6531 read_tra_op (cpup);
6532 return CONT_TRA;
6533 }
6534 break;
6535
6536 case x0 (0615):
6537
6538
6539
6540 if (TST_I_EUFL)
6541 {
6542 CLR_I_EUFL;
6543 do_caf (cpup);
6544 read_tra_op (cpup);
6545 return CONT_TRA;
6546 }
6547 break;
6548
6549
6550
6551
6552
6553
6554
6555 case x0 (0602):
6556
6557
6558
6559 if (!TST_I_CARRY)
6560 {
6561 do_caf (cpup);
6562 read_tra_op (cpup);
6563 return CONT_TRA;
6564 }
6565 break;
6566
6567
6568
6569
6570 case x0 (0617):
6571
6572
6573
6574 if (TST_I_OFLOW)
6575 {
6576 CLR_I_OFLOW;
6577 do_caf (cpup);
6578 read_tra_op (cpup);
6579 return CONT_TRA;
6580 }
6581 break;
6582
6583 case x0 (0605):
6584
6585
6586
6587 if (! (TST_I_NEG))
6588 {
6589 do_caf (cpup);
6590 read_tra_op (cpup);
6591 return CONT_TRA;
6592 }
6593 break;
6594
6595
6596
6597
6598
6599
6600
6601 case x0 (0603):
6602
6603
6604
6605 if (TST_I_CARRY)
6606 {
6607 do_caf (cpup);
6608 read_tra_op (cpup);
6609 return CONT_TRA;
6610 }
6611 break;
6612
6613 case x1 (0601):
6614
6615
6616
6617 if (!TST_I_TRUNC)
6618 {
6619 do_caf (cpup);
6620 read_tra_op (cpup);
6621 return CONT_TRA;
6622 }
6623 break;
6624
6625 case x1 (0600):
6626
6627
6628
6629 if (TST_I_TRUNC)
6630 {
6631 CLR_I_TRUNC;
6632 do_caf (cpup);
6633 read_tra_op (cpup);
6634 return CONT_TRA;
6635 }
6636 break;
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649 case x0 (0715):
6650 CPTUR (cptUseBAR);
6651 do_caf (cpup);
6652 if (get_bar_mode (cpup))
6653 read_tra_op (cpup);
6654 else
6655 {
6656 cpu.TPR.CA = get_BAR_address (cpup, cpu.TPR.CA);
6657 read_tra_op (cpup);
6658 CLR_I_NBAR;
6659 }
6660 return CONT_TRA;
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673 case x0 (0607):
6674
6675
6676
6677
6678 if (TST_I_TALLY == 0)
6679 {
6680 do_caf (cpup);
6681 read_tra_op (cpup);
6682 return CONT_TRA;
6683 }
6684 break;
6685
6686 case x1 (0606):
6687
6688
6689
6690
6691 if (TST_I_TALLY)
6692 {
6693 do_caf (cpup);
6694 read_tra_op (cpup);
6695 return CONT_TRA;
6696 }
6697 break;
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708 case x0 (0311):
6709
6710 CPTUR (cptUsePRn + 0);
6711 cpu.PR[0].SNR = cpu.TPR.CA & MASK15;
6712 #if defined(TESTING)
6713 HDBGRegPRW (0, "easp0");
6714 #endif
6715 break;
6716
6717 case x1 (0310):
6718
6719 CPTUR (cptUsePRn + 1);
6720 cpu.PR[1].SNR = cpu.TPR.CA & MASK15;
6721 #if defined(TESTING)
6722 HDBGRegPRW (1, "easp1");
6723 #endif
6724 break;
6725
6726 case x0 (0313):
6727
6728 CPTUR (cptUsePRn + 2);
6729 cpu.PR[2].SNR = cpu.TPR.CA & MASK15;
6730 #if defined(TESTING)
6731 HDBGRegPRW (2, "easp2");
6732 #endif
6733 break;
6734
6735 case x1 (0312):
6736
6737 CPTUR (cptUsePRn + 3);
6738 cpu.PR[3].SNR = cpu.TPR.CA & MASK15;
6739 #if defined(TESTING)
6740 HDBGRegPRW (3, "easp3");
6741 #endif
6742 break;
6743
6744 case x0 (0331):
6745
6746 CPTUR (cptUsePRn + 4);
6747 cpu.PR[4].SNR = cpu.TPR.CA & MASK15;
6748 #if defined(TESTING)
6749 HDBGRegPRW (4, "easp4");
6750 #endif
6751 break;
6752
6753 case x1 (0330):
6754
6755 CPTUR (cptUsePRn + 5);
6756 cpu.PR[5].SNR = cpu.TPR.CA & MASK15;
6757 #if defined(TESTING)
6758 HDBGRegPRW (5, "easp5");
6759 #endif
6760 break;
6761
6762 case x0 (0333):
6763
6764 CPTUR (cptUsePRn + 6);
6765 cpu.PR[6].SNR = cpu.TPR.CA & MASK15;
6766 #if defined(TESTING)
6767 HDBGRegPRW (6, "easp6");
6768 #endif
6769 break;
6770
6771 case x1 (0332):
6772
6773 CPTUR (cptUsePRn + 7);
6774 cpu.PR[7].SNR = cpu.TPR.CA & MASK15;
6775 #if defined(TESTING)
6776 HDBGRegPRW (7, "easp7");
6777 #endif
6778 break;
6779
6780
6781
6782 case x0 (0310):
6783
6784
6785
6786 CPTUR (cptUsePRn + 0);
6787 cpu.PR[0].WORDNO = cpu.TPR.CA;
6788 SET_PR_BITNO (0, cpu.TPR.TBR);
6789 #if defined(TESTING)
6790 HDBGRegPRW (0, "eawp0");
6791 #endif
6792 break;
6793
6794 case x1 (0311):
6795
6796
6797
6798 CPTUR (cptUsePRn + 1);
6799 cpu.PR[1].WORDNO = cpu.TPR.CA;
6800 SET_PR_BITNO (1, cpu.TPR.TBR);
6801 #if defined(TESTING)
6802 HDBGRegPRW (1, "eawp1");
6803 #endif
6804 break;
6805
6806 case x0 (0312):
6807
6808
6809
6810 CPTUR (cptUsePRn + 2);
6811 cpu.PR[2].WORDNO = cpu.TPR.CA;
6812 SET_PR_BITNO (2, cpu.TPR.TBR);
6813 #if defined(TESTING)
6814 HDBGRegPRW (2, "eawp2");
6815 #endif
6816 break;
6817
6818 case x1 (0313):
6819
6820
6821
6822 CPTUR (cptUsePRn + 3);
6823 cpu.PR[3].WORDNO = cpu.TPR.CA;
6824 SET_PR_BITNO (3, cpu.TPR.TBR);
6825 #if defined(TESTING)
6826 HDBGRegPRW (3, "eawp3");
6827 #endif
6828 break;
6829
6830 case x0 (0330):
6831
6832
6833
6834 CPTUR (cptUsePRn + 4);
6835 cpu.PR[4].WORDNO = cpu.TPR.CA;
6836 SET_PR_BITNO (4, cpu.TPR.TBR);
6837 #if defined(TESTING)
6838 HDBGRegPRW (4, "eawp4");
6839 #endif
6840 break;
6841
6842 case x1 (0331):
6843
6844
6845
6846 CPTUR (cptUsePRn + 5);
6847 cpu.PR[5].WORDNO = cpu.TPR.CA;
6848 SET_PR_BITNO (5, cpu.TPR.TBR);
6849 #if defined(TESTING)
6850 HDBGRegPRW (5, "eawp5");
6851 #endif
6852 break;
6853
6854 case x0 (0332):
6855
6856
6857
6858 CPTUR (cptUsePRn + 6);
6859 cpu.PR[6].WORDNO = cpu.TPR.CA;
6860 SET_PR_BITNO (6, cpu.TPR.TBR);
6861 #if defined(TESTING)
6862 HDBGRegPRW (6, "eawp6");
6863 #endif
6864 break;
6865
6866 case x1 (0333):
6867
6868
6869
6870 CPTUR (cptUsePRn + 7);
6871 cpu.PR[7].WORDNO = cpu.TPR.CA;
6872 SET_PR_BITNO (7, cpu.TPR.TBR);
6873 #if defined(TESTING)
6874 HDBGRegPRW (7, "eawp7");
6875 #endif
6876 break;
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898 case x0 (0173):
6899
6900
6901
6902
6903
6904
6905
6906 for (uint32 n = 0 ; n < 8 ; n ++)
6907 {
6908 CPTUR (cptUsePRn + n);
6909
6910 cpu.Ypair[0] = cpu.Yblock16[n * 2 + 0];
6911
6912 cpu.Ypair[1] = cpu.Yblock16[n * 2 + 1];
6913
6914
6915 word3 Crr = (GETLO (cpu.Ypair[0]) >> 15) & 07;
6916 if (get_addr_mode (cpup) == APPEND_mode)
6917 cpu.PR[n].RNR = max3 (Crr, cpu.SDW->R1, cpu.TPR.TRR);
6918 else
6919 cpu.PR[n].RNR = Crr;
6920 cpu.PR[n].SNR = (cpu.Ypair[0] >> 18) & MASK15;
6921 cpu.PR[n].WORDNO = GETHI (cpu.Ypair[1]);
6922 word6 bitno = (GETLO (cpu.Ypair[1]) >> 9) & 077;
6923
6924
6925
6926
6927
6928 if (bitno == 077)
6929 bitno = 037;
6930 SET_PR_BITNO (n, bitno);
6931 #if defined(TESTING)
6932 HDBGRegPRW (n, "lpri");
6933 #endif
6934 }
6935
6936 break;
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961 case x0 (0254):
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976 for (uint32 n = 0 ; n < 8 ; n++)
6977 {
6978 CPTUR (cptUsePRn + n);
6979 cpu.Yblock16[2 * n] = 043;
6980 cpu.Yblock16[2 * n] |= ((word36) cpu.PR[n].SNR) << 18;
6981 cpu.Yblock16[2 * n] |= ((word36) cpu.PR[n].RNR) << 15;
6982
6983 cpu.Yblock16[2 * n + 1] = (word36) cpu.PR[n].WORDNO << 18;
6984 cpu.Yblock16[2 * n + 1] |= (word36) GET_PR_BITNO(n) << 9;
6985 }
6986
6987 break;
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000 case x0 (0540):
7001 case x0 (0541):
7002 case x0 (0542):
7003 case x0 (0543):
7004 case x0 (0544):
7005 case x0 (0545):
7006 case x0 (0546):
7007 case x0 (0547):
7008
7009
7010
7011
7012 {
7013 uint32 n = opcode10 & 07;
7014 CPTUR (cptUsePRn + n);
7015
7016
7017
7018
7019
7020 if ((cpu.PR[n].SNR & 070000) != 0 && cpu.PR[n].SNR != MASK15)
7021 doFault (FAULT_STR, fst_str_ptr, "sprpn");
7022
7023 cpu.CY = ((word36) (GET_PR_BITNO(n) & 077)) << 30;
7024
7025 cpu.CY |= ((word36) (cpu.PR[n].SNR & 07777)) << 18;
7026 cpu.CY |= cpu.PR[n].WORDNO & PAMASK;
7027 cpu.CY &= DMASK;
7028 }
7029 break;
7030
7031
7032
7033
7034 case x0 (0050):
7035 case x0 (0051):
7036 case x0 (0052):
7037 case x0 (0053):
7038
7039
7040
7041 {
7042 uint32 n = opcode10 & 03;
7043 CPTUR (cptUsePRn + n);
7044 cpu.PR[n].WORDNO += GETHI (cpu.CY);
7045 cpu.PR[n].WORDNO &= MASK18;
7046 SET_PR_BITNO (n, 0);
7047 #if defined(TESTING)
7048 HDBGRegPRW (n, "adwpn");
7049 #endif
7050 }
7051 break;
7052
7053 case x0 (0150):
7054 case x0 (0151):
7055 case x0 (0152):
7056 case x0 (0153):
7057
7058
7059
7060 {
7061 uint32 n = (opcode10 & MASK3) + 4U;
7062 CPTUR (cptUsePRn + n);
7063 cpu.PR[n].WORDNO += GETHI (cpu.CY);
7064 cpu.PR[n].WORDNO &= MASK18;
7065 SET_PR_BITNO (n, 0);
7066 #if defined(TESTING)
7067 HDBGRegPRW (n, "adwpn");
7068 #endif
7069 }
7070 break;
7071
7072
7073
7074
7075
7076
7077
7078
7079 case x0 (0633):
7080
7081
7082 {
7083
7084
7085
7086
7087 uint cpu_port_num;
7088 if (cpu.tweaks.l68_mode)
7089 cpu_port_num = (cpu.TPR.CA >> 15) & 07;
7090 else
7091 cpu_port_num = (cpu.TPR.CA >> 15) & 03;
7092 if (! get_scu_in_use (current_running_cpu_idx, cpu_port_num))
7093 {
7094 sim_warn ("rccl on CPU %u port %d has no SCU; faulting\n",
7095 current_running_cpu_idx, cpu_port_num);
7096 doFault (FAULT_ONC, fst_onc_nem, "(rccl)");
7097 }
7098 uint scuUnitIdx = get_scu_idx (current_running_cpu_idx, cpu_port_num);
7099
7100 t_stat rc = scu_rscr (cpup, (uint) scuUnitIdx, current_running_cpu_idx,
7101 040, & cpu.rA, & cpu.rQ);
7102 #if defined(TESTING)
7103 HDBGRegAW ("rccl");
7104 HDBGRegQW ("rccl");
7105 #endif
7106 if (rc > 0)
7107 return rc;
7108 #if !defined(SPEED)
7109 if_sim_debug (DBG_TRACEEXT, & cpu_dev)
7110 {
7111
7112
7113
7114 uint64 UnixSecs = 932686778;
7115 uint64 UnixuSecs = UnixSecs * 1000000LL;
7116
7117 uint64 MulticsuSecs = 2177452800000000LL + UnixuSecs;
7118
7119
7120 word72 big = convert_to_word72 (cpu.rA, cpu.rQ);
7121 # if defined(NEED_128)
7122
7123 big = subtract_128 (big, construct_128 (0, MulticsuSecs));
7124 uint32_t remainder;
7125 uint128 bigsecs = divide_128_32 (big, 1000000u, & remainder);
7126 uint64_t uSecs = remainder;
7127 uint64_t secs = bigsecs.l;
7128 sim_debug (DBG_TRACEEXT, & cpu_dev,
7129 "Clock time since boot %4llu.%06llu seconds\n",
7130 secs, uSecs);
7131 # else
7132
7133 big -= MulticsuSecs;
7134 unsigned long uSecs = big % 1000000u;
7135 unsigned long secs = (unsigned long) (big / 1000000u);
7136 sim_debug (DBG_TRACEEXT, & cpu_dev,
7137 "Clock time since boot %4lu.%06lu seconds\n",
7138 secs, uSecs);
7139 # endif
7140 }
7141 #endif
7142 }
7143 break;
7144
7145 case x0 (0002):
7146
7147
7148
7149
7150
7151 if (cpu.tweaks.drl_fatal)
7152 {
7153 return STOP_STOP;
7154 }
7155 doFault (FAULT_DRL, fst_zero, "drl");
7156
7157
7158 case x0 (0716):
7159 cpu.cu.xde = 1;
7160 cpu.cu.xdo = 0;
7161
7162
7163
7164 cpu.cu.IWB = cpu.CY;
7165 return CONT_XEC;
7166
7167 case x0 (0717):
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203 cpu.cu.xde = 1;
7204 cpu.cu.xdo = 1;
7205
7206
7207
7208 cpu.cu.IWB = cpu.Ypair[0];
7209 cpu.cu.IRODD = cpu.Ypair[1];
7210 return CONT_XEC;
7211
7212 case x0 (0001):
7213 #if defined(TESTING)
7214 if (sim_deb_mme_cntdwn > 0)
7215 sim_deb_mme_cntdwn --;
7216 #endif
7217
7218
7219
7220
7221 doFault (FAULT_MME, fst_zero, "Master Mode Entry (mme)");
7222
7223
7224 case x0 (0004):
7225
7226
7227
7228
7229 doFault (FAULT_MME2, fst_zero, "Master Mode Entry 2 (mme2)");
7230
7231
7232 case x0 (0005):
7233
7234
7235
7236
7237 doFault (FAULT_MME3, fst_zero, "Master Mode Entry 3 (mme3)");
7238
7239
7240 case x0 (0007):
7241
7242
7243
7244
7245 doFault (FAULT_MME4, fst_zero, "Master Mode Entry 4 (mme4)");
7246
7247
7248 case x0 (0011):
7249 break;
7250
7251 case x0 (0012):
7252 break;
7253
7254 case x0 (0013):
7255 break;
7256
7257
7258
7259 case x0 (0560):
7260 {
7261 if ((cpu.PPR.IC & 1) == 0)
7262 doFault (FAULT_IPR, fst_ill_proc, "rpd odd");
7263 cpu.cu.delta = i->tag;
7264
7265 word1 c = (i->address >> 7) & 1;
7266 if (c)
7267 {
7268 cpu.rX[0] = i->address;
7269 #if defined(TESTING)
7270 HDBGRegXW (0, "rpd");
7271 #endif
7272 }
7273 cpu.cu.rd = 1;
7274 cpu.cu.repeat_first = 1;
7275 }
7276 break;
7277
7278 case x0 (0500):
7279 {
7280 uint c = (i->address >> 7) & 1;
7281 cpu.cu.delta = i->tag;
7282 if (c)
7283 {
7284 cpu.rX[0] = i->address;
7285 #if defined(TESTING)
7286 HDBGRegXW (0, "rpl");
7287 #endif
7288 }
7289 cpu.cu.rl = 1;
7290 cpu.cu.repeat_first = 1;
7291 }
7292 break;
7293
7294 case x0 (0520):
7295 {
7296 uint c = (i->address >> 7) & 1;
7297 cpu.cu.delta = i->tag;
7298 if (c)
7299 {
7300 cpu.rX[0] = i->address;
7301 #if defined(TESTING)
7302 HDBGRegXW (0, "rpt");
7303 #endif
7304 }
7305 cpu.cu.rpt = 1;
7306 cpu.cu.repeat_first = 1;
7307 }
7308 break;
7309
7310
7311
7312 case x1 (0754):
7313
7314
7315
7316 CPTUR (cptUseRALR);
7317 cpu.CY = (word36)cpu.rRALR;
7318
7319 break;
7320
7321
7322
7323 case x0 (0550):
7324
7325 CPTUR (cptUseBAR);
7326
7327 cpu.CY = ((((word36) cpu.BAR.BASE) << 9) | cpu.BAR.BOUND) << 18;
7328 cpu.zone = 0777777000000;
7329 cpu.useZone = true;
7330 break;
7331
7332
7333
7334 case x0 (0505):
7335
7336
7337
7338
7339
7340
7341
7342 {
7343 word36 tmp1 = cpu.rA & SIGN36;
7344 word36 tmp36 = (cpu.rA << 3) & DMASK;
7345 word36 tmp36q = tmp36 / cpu.CY;
7346 word36 tmp36r = 0;
7347 if (!tmp1) {
7348 tmp36r = tmp36 - tmp36q * cpu.CY;
7349 } else {
7350
7351
7352
7353
7354
7355
7356 tmp36q += 6;
7357 tmp36r = tmp36 + tmp36q * cpu.CY;
7358 }
7359
7360 cpu.rQ <<= 6;
7361 cpu.rQ &= DMASK;
7362
7363
7364 cpu.rQ |= (tmp36q & 017);
7365 #if defined(TESTING)
7366 HDBGRegQW ("bcd");
7367 #endif
7368
7369 cpu.rA = tmp36r & DMASK;
7370 #if defined(TESTING)
7371 HDBGRegAW ("bcd");
7372 #endif
7373
7374 SC_I_ZERO (cpu.rA == 0);
7375
7376 SC_I_NEG (tmp1);
7377
7378 }
7379 break;
7380
7381 case x0 (0774):
7382
7383
7384 {
7385 word36 tmp = cpu.rA & MASK36;
7386 word36 mask = SIGN36;
7387
7388 for (int n=1;n<=35;n++) {
7389 tmp ^= (tmp & mask) >> 1;
7390 mask >>= 1;
7391 }
7392
7393 cpu.rA = tmp;
7394 #if defined(TESTING)
7395 HDBGRegAW ("gtb");
7396 #endif
7397
7398 SC_I_ZERO (cpu.rA == 0);
7399
7400 SC_I_NEG (cpu.rA & SIGN36);
7401
7402 }
7403 break;
7404
7405
7406
7407 case x0 (0230):
7408
7409 CPTUR (cptUseBAR);
7410
7411 cpu.BAR.BASE = (GETHI (cpu.CY) >> 9) & 0777;
7412
7413 cpu.BAR.BOUND = GETHI (cpu.CY) & 0777;
7414 break;
7415
7416
7417
7418
7419
7420 case x0 (0674):
7421
7422 switch (i->tag)
7423 {
7424
7425
7426
7427 case 02:
7428 {
7429
7430
7431
7432
7433
7434 CPTUR (cptUseCMR);
7435
7436
7437
7438 uint csh1_on = getbits36_1 (cpu.CY, 54 - 36);
7439 uint csh2_on = getbits36_1 (cpu.CY, 55 - 36);
7440
7441
7442 cpu.CMR.csh1_on = (word1) csh1_on;
7443 cpu.CMR.csh2_on = (word1) csh2_on;
7444
7445
7446
7447 L68_ (cpu.CMR.opnd_on = getbits36_1 (cpu.CY, 56 - 36);)
7448 cpu.CMR.inst_on = getbits36_1 (cpu.CY, 57 - 36);
7449 cpu.CMR.csh_reg = getbits36_1 (cpu.CY, 59 - 36);
7450 if (cpu.CMR.csh_reg)
7451 sim_warn ("LCPR set csh_reg\n");
7452
7453
7454
7455 DPS8M_ (cpu.CMR.bypass_cache = getbits36_1 (cpu.CY, 68 - 36);)
7456 cpu.CMR.luf = getbits36_2 (cpu.CY, 70 - 36);
7457 }
7458 break;
7459
7460 case 04:
7461 {
7462 CPTUR (cptUseMR);
7463 cpu.MR.r = cpu.CY;
7464
7465 putbits36_1 (& cpu.MR.r, 32, 0);
7466
7467 putbits36_2 (& cpu.MR.r, 33, 0);
7468 L68_ (
7469 cpu.MR.FFV = getbits36_15 (cpu.CY, 0);
7470 cpu.MR.OC_TRAP = getbits36_1 (cpu.CY, 16);
7471 cpu.MR.ADR_TRAP = getbits36_1 (cpu.CY, 17);
7472 cpu.MR.OPCODE = getbits36_9 (cpu.CY, 18);
7473 cpu.MR.OPCODEX = getbits36_1 (cpu.CY, 27);
7474 )
7475 cpu.MR.sdpap = getbits36_1 (cpu.CY, 20);
7476 cpu.MR.separ = getbits36_1 (cpu.CY, 21);
7477 cpu.MR.hrhlt = getbits36_1 (cpu.CY, 28);
7478 DPS8M_ (cpu.MR.hrxfr = getbits36_1 (cpu.CY, 29);)
7479 cpu.MR.ihr = getbits36_1 (cpu.CY, 30);
7480 cpu.MR.ihrrs = getbits36_1 (cpu.CY, 31);
7481 cpu.MR.emr = getbits36_1 (cpu.CY, 35);
7482 if (! cpu.tweaks.l68_mode)
7483 cpu.MR.hexfp = getbits36_1 (cpu.CY, 33);
7484 else
7485 cpu.MR.hexfp = 0;
7486
7487
7488
7489
7490
7491 if (cpu.MR.hrhlt)
7492 {
7493 for (uint hset = 0; hset < N_HIST_SETS; hset ++)
7494 cpu.history_cyclic[hset] = 0;
7495 }
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508 }
7509 break;
7510
7511 case 03:
7512 {
7513 for (uint i = 0; i < N_HIST_SETS; i ++)
7514 add_history_force (cpup, i, 0, 0);
7515
7516
7517
7518
7519
7520 cpu.skip_cu_hist = true;
7521
7522 }
7523 break;
7524
7525 case 07:
7526 {
7527 for (uint i = 0; i < N_HIST_SETS; i ++)
7528 add_history_force (cpup, i, MASK36, MASK36);
7529
7530
7531
7532
7533
7534 cpu.skip_cu_hist = true;
7535 }
7536 break;
7537
7538 default:
7539 doFault (FAULT_IPR,
7540 fst_ill_mod,
7541 "lcpr tag invalid");
7542
7543 }
7544 break;
7545
7546 case x0 (0232):
7547 do_ldbr (cpup, cpu.Ypair);
7548 ucInvalidate (cpup);
7549 break;
7550
7551 case x0 (0637):
7552 CPTUR (cptUseTR);
7553 cpu.rTR = (cpu.CY >> 9) & MASK27;
7554 cpu.rTRticks = 0;
7555 if (cpu.tweaks.isolts_mode)
7556 {
7557 cpu.shadowTR = cpu.TR0 = cpu.rTR;
7558 cpu.rTRlsb = 0;
7559 }
7560 sim_debug (DBG_TRACEEXT, & cpu_dev, "ldt TR %d (%o)\n",
7561 cpu.rTR, cpu.rTR);
7562 #if defined(LOOPTRC)
7563 elapsedtime ();
7564 sim_printf (" ldt %d PSR:IC %05o:%06o\r\n", cpu.rTR, cpu.PPR.PSR, cpu.PPR.IC);
7565 #endif
7566
7567
7568
7569
7570 clearTROFault (cpup);
7571 break;
7572
7573 case x1 (0257):
7574
7575 if (cpu.tweaks.l68_mode) {
7576
7577
7578
7579
7580
7581
7582 for (uint i = 0; i < 16; i ++)
7583 {
7584 word4 m = cpu.PTWAM[i].USE;
7585 cpu.PTWAM[m].POINTER = getbits36_15 (cpu.Yblock16[i], 0);
7586 cpu.PTWAM[m].PAGENO = getbits36_12 (cpu.Yblock16[i], 15);
7587 cpu.PTWAM[m].FE = getbits36_1 (cpu.Yblock16[i], 27);
7588 }
7589 }
7590 break;
7591
7592 case x1 (0173):
7593 if (cpu.tweaks.l68_mode) {
7594
7595
7596
7597
7598 for (uint i = 0; i < 16; i ++)
7599 {
7600 word4 m = cpu.PTWAM[i].USE;
7601 cpu.PTWAM[m].ADDR = getbits36_18 (cpu.Yblock16[i], 0);
7602 cpu.PTWAM[m].M = getbits36_1 (cpu.Yblock16[i], 29);
7603 }
7604 }
7605 break;
7606
7607 case x1 (0774):
7608 CPTUR (cptUseRALR);
7609 cpu.rRALR = cpu.CY & MASK3;
7610 sim_debug (DBG_TRACEEXT, & cpu_dev, "RALR set to %o\n", cpu.rRALR);
7611 #if defined(LOOPTRC)
7612 {
7613 void elapsedtime (void);
7614 elapsedtime ();
7615 sim_printf (" RALR set to %o PSR:IC %05o:%06o\r\n", cpu.rRALR, cpu.PPR.PSR, cpu.PPR.IC);
7616 }
7617 #endif
7618 break;
7619
7620 case x0 (0257):
7621 if (cpu.tweaks.l68_mode) {
7622
7623
7624
7625
7626 for (uint i = 0; i < 16; i ++)
7627 {
7628 word4 m = cpu.SDWAM[i].USE;
7629 cpu.SDWAM[m].POINTER = getbits36_15 (cpu.Yblock16[i], 0);
7630 cpu.SDWAM[m].FE = getbits36_1 (cpu.Yblock16[i], 27);
7631 }
7632 }
7633 break;
7634
7635 case x1 (0232):
7636 if (cpu.tweaks.l68_mode) {
7637
7638
7639
7640
7641
7642
7643
7644 for (uint i = 0; i < 16; i ++)
7645 {
7646 word4 m = cpu.SDWAM[i].USE;
7647 uint j = (uint)m * 2;
7648 cpu.SDWAM[m].ADDR = getbits36_24 (cpu.Yblock32[j], 0);
7649 cpu.SDWAM[m].R1 = getbits36_3 (cpu.Yblock32[j], 24);
7650 cpu.SDWAM[m].R2 = getbits36_3 (cpu.Yblock32[j], 27);
7651 cpu.SDWAM[m].R3 = getbits36_3 (cpu.Yblock32[j], 30);
7652
7653 cpu.SDWAM[m].BOUND = getbits36_14 (cpu.Yblock32[j + 1], 37 - 36);
7654 cpu.SDWAM[m].R = getbits36_1 (cpu.Yblock32[j + 1], 51 - 36);
7655 cpu.SDWAM[m].E = getbits36_1 (cpu.Yblock32[j + 1], 52 - 36);
7656 cpu.SDWAM[m].W = getbits36_1 (cpu.Yblock32[j + 1], 53 - 36);
7657 cpu.SDWAM[m].P = getbits36_1 (cpu.Yblock32[j + 1], 54 - 36);
7658 cpu.SDWAM[m].U = getbits36_1 (cpu.Yblock32[j + 1], 55 - 36);
7659 cpu.SDWAM[m].G = getbits36_1 (cpu.Yblock32[j + 1], 56 - 36);
7660 cpu.SDWAM[m].C = getbits36_1 (cpu.Yblock32[j + 1], 57 - 36);
7661 cpu.SDWAM[m].EB = getbits36_14 (cpu.Yblock32[j + 1], 58 - 36);
7662 }
7663 }
7664 break;
7665
7666 case x0 (0613):
7667 doRCU (cpup);
7668
7669
7670
7671
7672 case x0 (0452):
7673 {
7674 uint tag = (i->tag) & MASK6;
7675 switch (tag)
7676 {
7677 case 000:
7678 {
7679 uint reg = cpu.tweaks.l68_mode ? L68_APU_HIST_REG : DPS8M_APU_HIST_REG;
7680 cpu.Ypair[0] = cpu.history[reg] [cpu.history_cyclic[reg]][0];
7681 cpu.Ypair[1] = cpu.history[reg] [cpu.history_cyclic[reg]][1];
7682 cpu.history_cyclic[reg] = (cpu.history_cyclic[reg] + 1) % N_MODEL_HIST_SIZE;
7683 }
7684 break;
7685
7686 case 001:
7687
7688 {
7689 CPTUR (cptUseFR);
7690 cpu.Ypair[0] = cpu.faultRegister[0];
7691 cpu.Ypair[1] = cpu.faultRegister[1];
7692 cpu.faultRegister[0] = 0;
7693 cpu.faultRegister[1] = 0;
7694 }
7695 break;
7696
7697 case 006:
7698
7699 {
7700 CPTUR (cptUseMR);
7701 cpu.Ypair[0] = cpu.MR.r;
7702 putbits36_1 (& cpu.Ypair[0], 20, cpu.MR.sdpap);
7703 putbits36_1 (& cpu.Ypair[0], 21, cpu.MR.separ);
7704 putbits36_1 (& cpu.Ypair[0], 30, cpu.MR.ihr);
7705 DPS8M_ (putbits36_1 (& cpu.Ypair[0], 33, cpu.MR.hexfp);)
7706 CPTUR (cptUseCMR);
7707 cpu.Ypair[1] = 0;
7708 putbits36_15 (& cpu.Ypair[1], 36 - 36,
7709 cpu.CMR.cache_dir_address);
7710 putbits36_1 (& cpu.Ypair[1], 51 - 36, cpu.CMR.par_bit);
7711 putbits36_1 (& cpu.Ypair[1], 52 - 36, cpu.CMR.lev_ful);
7712 putbits36_1 (& cpu.Ypair[1], 54 - 36, cpu.CMR.csh1_on);
7713 putbits36_1 (& cpu.Ypair[1], 55 - 36, cpu.CMR.csh2_on);
7714 L68_ (putbits36_1 (& cpu.Ypair[1], 56 - 36, cpu.CMR.opnd_on);)
7715 putbits36_1 (& cpu.Ypair[1], 57 - 36, cpu.CMR.inst_on);
7716 putbits36_1 (& cpu.Ypair[1], 59 - 36, cpu.CMR.csh_reg);
7717 putbits36_1 (& cpu.Ypair[1], 60 - 36, cpu.CMR.str_asd);
7718 putbits36_1 (& cpu.Ypair[1], 61 - 36, cpu.CMR.col_ful);
7719 putbits36_2 (& cpu.Ypair[1], 62 - 36, cpu.CMR.rro_AB);
7720 DPS8M_ (putbits36_1 (& cpu.Ypair[1], 68 - 36, cpu.CMR.bypass_cache);)
7721 putbits36_2 (& cpu.Ypair[1], 70 - 36, cpu.CMR.luf);
7722 }
7723 break;
7724
7725 case 010:
7726 {
7727 uint reg = cpu.tweaks.l68_mode ? L68_DU_HIST_REG : DPS8M_EAPU_HIST_REG;
7728 cpu.Ypair[0] = cpu.history[reg] [cpu.history_cyclic[reg]][0];
7729 cpu.Ypair[1] = cpu.history[reg] [cpu.history_cyclic[reg]][1];
7730 cpu.history_cyclic[reg] = (cpu.history_cyclic[reg] + 1) % N_MODEL_HIST_SIZE;
7731 }
7732 break;
7733
7734 case 020:
7735 {
7736 cpu.Ypair[0] =
7737 cpu.history[CU_HIST_REG]
7738 [cpu.history_cyclic[CU_HIST_REG]][0];
7739 cpu.Ypair[1] =
7740 cpu.history[CU_HIST_REG]
7741 [cpu.history_cyclic[CU_HIST_REG]][1];
7742 cpu.history_cyclic[CU_HIST_REG] =
7743 (cpu.history_cyclic[CU_HIST_REG] + 1) % N_MODEL_HIST_SIZE;
7744 }
7745 break;
7746
7747 case 040:
7748 {
7749 uint reg = cpu.tweaks.l68_mode ? L68_OU_HIST_REG : DPS8M_DU_OU_HIST_REG;
7750 cpu.Ypair[0] = cpu.history[reg] [cpu.history_cyclic[reg]][0];
7751 cpu.Ypair[1] = cpu.history[reg] [cpu.history_cyclic[reg]][1];
7752 cpu.history_cyclic[reg] = (cpu.history_cyclic[reg] + 1) % N_MODEL_HIST_SIZE;
7753 }
7754 break;
7755
7756 default:
7757 {
7758 doFault (FAULT_IPR,
7759 fst_ill_mod,
7760 "SCPR Illegal register select value");
7761 }
7762 }
7763 }
7764 break;
7765
7766 case x0 (0657):
7767
7768
7769
7770
7771
7772 if (cpu.cycle == EXEC_cycle)
7773 {
7774
7775
7776
7777
7778
7779
7780 scu2words (cpup, cpu.Yblock8);
7781 }
7782 else
7783 {
7784
7785 for (int j = 0; j < 8; j ++)
7786 cpu.Yblock8[j] = cpu.scu_data[j];
7787 }
7788 break;
7789
7790 case x0 (0154):
7791 {
7792 CPTUR (cptUseDSBR);
7793
7794
7795 cpu.Ypair[0] = ((word36) (cpu.DSBR.ADDR & PAMASK)) << (35 - 23);
7796
7797
7798
7799
7800
7801
7802 cpu.Ypair[1] = ((word36) (cpu.DSBR.BND & 037777)) << (71 - 50) |
7803 ((word36) (cpu.DSBR.U & 1)) << (71 - 55) |
7804 ((word36) (cpu.DSBR.STACK & 07777)) << (71 - 71);
7805 }
7806 break;
7807
7808 case x1 (0557):
7809 {
7810
7811
7812
7813 uint level;
7814 L68_ (level = 0;)
7815 DPS8M_ (level = (cpu.TPR.CA >> 4) & 03;)
7816 uint toffset = level * 16;
7817 for (uint j = 0; j < 16; j ++)
7818 {
7819 cpu.Yblock16[j] = 0;
7820 putbits36_15 (& cpu.Yblock16[j], 0,
7821 cpu.PTWAM[toffset + j].POINTER);
7822 DPS8M_ (
7823 putbits36_12 (& cpu.Yblock16[j], 15, cpu.PTWAM[toffset + j].PAGENO & 07760);
7824
7825 uint parity = 0;
7826 if (cpu.PTWAM[toffset + j].FE) {
7827
7828
7829 parity = ((uint) cpu.PTWAM[toffset + j].POINTER << 4) | (cpu.PTWAM[toffset + j].PAGENO >> 8);
7830 parity = parity ^ (parity >>16);
7831 parity = parity ^ (parity >> 8);
7832 parity = parity ^ (parity >> 4);
7833 parity = ~ (0x6996u >> (parity & 0xf));
7834 }
7835 putbits36_1 (& cpu.Yblock16[j], 23, (word1) (parity & 1));
7836 )
7837 L68_ (putbits36_12 (& cpu.Yblock16[j], 15, cpu.PTWAM[toffset + j].PAGENO); )
7838 putbits36_1 (& cpu.Yblock16[j], 27,
7839 cpu.PTWAM[toffset + j].FE);
7840 DPS8M_ (putbits36_6 (& cpu.Yblock16[j], 30, cpu.PTWAM[toffset + j].USE);)
7841 L68_ (putbits36_4 (& cpu.Yblock16[j], 32, cpu.PTWAM[toffset + j].USE);)
7842 }
7843 }
7844 break;
7845
7846 case x1 (0154):
7847 {
7848
7849
7850
7851
7852 uint level;
7853 DPS8M_ (level = (cpu.TPR.CA >> 4) & 03;)
7854 L68_ (level = 0;)
7855 uint toffset = level * 16;
7856 for (uint j = 0; j < 16; j ++)
7857 {
7858 cpu.Yblock16[j] = 0;
7859 DPS8M_ (putbits36_18 (& cpu.Yblock16[j], 0, cpu.PTWAM[toffset + j].ADDR & 0777760);)
7860 L68_ (putbits36_18 (& cpu.Yblock16[j], 0, cpu.PTWAM[toffset + j].ADDR);)
7861 putbits36_1 (& cpu.Yblock16[j], 29,
7862 cpu.PTWAM[toffset + j].M);
7863 }
7864 }
7865 break;
7866
7867 case x0 (0557):
7868 {
7869
7870
7871
7872 uint level;
7873 DPS8M_ (level = (cpu.TPR.CA >> 4) & 03;)
7874 L68_ (level = 0;)
7875 uint toffset = level * 16;
7876 for (uint j = 0; j < 16; j ++)
7877 {
7878 cpu.Yblock16[j] = 0;
7879 putbits36_15 (& cpu.Yblock16[j], 0,
7880 cpu.SDWAM[toffset + j].POINTER);
7881 putbits36_1 (& cpu.Yblock16[j], 27,
7882 cpu.SDWAM[toffset + j].FE);
7883 DPS8M_ (
7884 uint parity = 0;
7885 if (cpu.SDWAM[toffset + j].FE) {
7886
7887
7888 parity = cpu.SDWAM[toffset + j].POINTER >> 4;
7889
7890 parity = parity ^ (parity >> 8);
7891 parity = parity ^ (parity >> 4);
7892 parity = ~ (0x6996u >> (parity & 0xf));
7893 }
7894 putbits36_1 (& cpu.Yblock16[j], 15, (word1) (parity & 1));
7895
7896 putbits36_6 (& cpu.Yblock16[j], 30, cpu.SDWAM[toffset + j].USE);
7897 )
7898 L68_ (putbits36_4 (& cpu.Yblock16[j], 32, cpu.SDWAM[toffset + j].USE);)
7899 }
7900 }
7901 break;
7902
7903 case x1 (0254):
7904 {
7905
7906
7907
7908
7909
7910 uint level = 0;
7911 DPS8M_ (level = (cpu.TPR.CA >> 5) & 03;)
7912 L68_ (level = 0;)
7913 uint toffset = level * 16;
7914 for (uint j = 0; j < 16; j ++)
7915 {
7916 cpu.Yblock32[j * 2] = 0;
7917 putbits36_24 (& cpu.Yblock32[j * 2], 0,
7918 cpu.SDWAM[toffset + j].ADDR);
7919 putbits36_3 (& cpu.Yblock32[j * 2], 24,
7920 cpu.SDWAM[toffset + j].R1);
7921 putbits36_3 (& cpu.Yblock32[j * 2], 27,
7922 cpu.SDWAM[toffset + j].R2);
7923 putbits36_3 (& cpu.Yblock32[j * 2], 30,
7924 cpu.SDWAM[toffset + j].R3);
7925 cpu.Yblock32[j * 2 + 1] = 0;
7926
7927 putbits36_14 (& cpu.Yblock32[j * 2 + 1], 37 - 36,
7928 cpu.SDWAM[toffset + j].BOUND);
7929 putbits36_1 (& cpu.Yblock32[j * 2 + 1], 51 - 36,
7930 cpu.SDWAM[toffset + j].R);
7931 putbits36_1 (& cpu.Yblock32[j * 2 + 1], 52 - 36,
7932 cpu.SDWAM[toffset + j].E);
7933 putbits36_1 (& cpu.Yblock32[j * 2 + 1], 53 - 36,
7934 cpu.SDWAM[toffset + j].W);
7935 putbits36_1 (& cpu.Yblock32[j * 2 + 1], 54 - 36,
7936 cpu.SDWAM[toffset + j].P);
7937 putbits36_1 (& cpu.Yblock32[j * 2 + 1], 55 - 36,
7938 cpu.SDWAM[toffset + j].U);
7939 putbits36_1 (& cpu.Yblock32[j * 2 + 1], 56 - 36,
7940 cpu.SDWAM[toffset + j].G);
7941 putbits36_1 (& cpu.Yblock32[j * 2 + 1], 57 - 36,
7942 cpu.SDWAM[toffset + j].C);
7943 putbits36_14 (& cpu.Yblock32[j * 2 + 1], 58 - 36,
7944 cpu.SDWAM[toffset + j].EB);
7945 }
7946 }
7947 break;
7948
7949
7950
7951 case x1 (0532):
7952 {
7953
7954
7955
7956
7957
7958 if (cpu.tweaks.enable_wam)
7959 {
7960 if (cpu.tweaks.l68_mode || cpu.cu.PT_ON)
7961 for (uint i = 0; i < N_MODEL_WAM_ENTRIES; i ++)
7962 {
7963 cpu.PTWAM[i].FE = 0;
7964 L68_ (cpu.PTWAM[i].USE = (word4) i;)
7965 DPS8M_ (cpu.PTWAM[i].USE = 0;)
7966 }
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979 DPS8M_ (if (cpu.TPR.CA != 0000002 && (cpu.TPR.CA & 3) != 0)
7980 sim_warn ("CAMP ignores enable/disable %06o\n", cpu.TPR.CA);)
7981 if ((cpu.TPR.CA & 3) == 02)
7982 cpu.cu.PT_ON = 1;
7983 else if ((cpu.TPR.CA & 3) == 01)
7984 cpu.cu.PT_ON = 0;
7985 }
7986 else
7987 {
7988 cpu.PTW0.FE = 0;
7989 cpu.PTW0.USE = 0;
7990 }
7991 }
7992 ucInvalidate (cpup);
7993 break;
7994
7995 case x0 (0532):
7996 {
7997
7998
7999
8000
8001
8002
8003
8004 if (cpu.tweaks.enable_wam)
8005 {
8006 if (cpu.tweaks.l68_mode || cpu.cu.SD_ON)
8007 for (uint i = 0; i < N_MODEL_WAM_ENTRIES; i ++)
8008 {
8009 cpu.SDWAM[i].FE = 0;
8010 L68_ (cpu.SDWAM[i].USE = (word4) i;)
8011 DPS8M_ (cpu.SDWAM[i].USE = 0;)
8012 }
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024 DPS8M_ (if (cpu.TPR.CA != 0000006 && (cpu.TPR.CA & 3) != 0)
8025 sim_warn ("CAMS ignores enable/disable %06o\n", cpu.TPR.CA);)
8026 if ((cpu.TPR.CA & 3) == 02)
8027 cpu.cu.SD_ON = 1;
8028 else if ((cpu.TPR.CA & 3) == 01)
8029 cpu.cu.SD_ON = 0;
8030 }
8031 else
8032 {
8033 cpu.SDW0.FE = 0;
8034 cpu.SDW0.USE = 0;
8035 }
8036 }
8037 ucInvalidate (cpup);
8038 break;
8039
8040
8041
8042 case x0 (0233):
8043 {
8044
8045
8046
8047 uint cpu_port_num;
8048 DPS8M_ (cpu_port_num = (cpu.TPR.CA >> 15) & 03;)
8049 L68_ (cpu_port_num = (cpu.TPR.CA >> 15) & 07;)
8050 if (! get_scu_in_use (current_running_cpu_idx, cpu_port_num))
8051 {
8052 sim_warn ("rmcm to non-existent controller on "
8053 "cpu %d port %d\n",
8054 current_running_cpu_idx, cpu_port_num);
8055 break;
8056 }
8057 uint scuUnitIdx = get_scu_idx (current_running_cpu_idx, cpu_port_num);
8058 t_stat rc = scu_rmcm ((uint) scuUnitIdx,
8059 current_running_cpu_idx,
8060 & cpu.rA, & cpu.rQ);
8061 #if defined(TESTING)
8062 HDBGRegAW ("rmcm");
8063 HDBGRegQW ("rmcm");
8064 #endif
8065 if (rc)
8066 return rc;
8067 SC_I_ZERO (cpu.rA == 0);
8068 SC_I_NEG (cpu.rA & SIGN36);
8069 }
8070 break;
8071
8072 case x0 (0413):
8073 {
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106 uint cpu_port_num;
8107 DPS8M_ (cpu_port_num = (cpu.TPR.CA >> 10) & 03;)
8108 L68_ (cpu_port_num = (cpu.TPR.CA >> 10) & 07;)
8109
8110
8111
8112 if (! get_scu_in_use (current_running_cpu_idx, cpu_port_num))
8113 {
8114
8115
8116
8117 if (cpu_port_num == 0)
8118 putbits36 (& cpu.faultRegister[0], 16, 4, 010);
8119 else if (cpu_port_num == 1)
8120 putbits36 (& cpu.faultRegister[0], 20, 4, 010);
8121 else if (cpu_port_num == 2)
8122 putbits36 (& cpu.faultRegister[0], 24, 4, 010);
8123 else
8124 putbits36 (& cpu.faultRegister[0], 28, 4, 010);
8125
8126 doFault (FAULT_CMD, fst_cmd_ctl, "(rscr)");
8127 }
8128 uint scuUnitIdx = get_scu_idx (current_running_cpu_idx, cpu_port_num);
8129 #if defined(PANEL68)
8130 {
8131 uint function = (cpu.iefpFinalAddress >> 3) & 07;
8132 CPT (cpt13L, function);
8133 }
8134 #endif
8135 t_stat rc = scu_rscr (cpup, (uint) scuUnitIdx, current_running_cpu_idx,
8136 cpu.iefpFinalAddress & MASK15,
8137 & cpu.rA, & cpu.rQ);
8138 #if defined(TESTING)
8139 HDBGRegAW ("rscr");
8140 HDBGRegQW ("rscr");
8141 #endif
8142 if (rc)
8143 return rc;
8144 }
8145 break;
8146
8147 case x0 (0231):
8148 {
8149 if (! cpu.tweaks.l68_mode) {
8150 word6 rTAG = GET_TAG (IWB_IRODD);
8151 word6 Td = GET_TD (rTAG);
8152 word6 Tm = GET_TM (rTAG);
8153 if (Tm == TM_R && Td == TD_DL)
8154 {
8155 unsigned char PROM[1024];
8156 setupPROM (current_running_cpu_idx, PROM);
8157 cpu.rA = PROM[cpu.TPR.CA & 1023];
8158 break;
8159 }
8160 }
8161 uint select = cpu.TPR.CA & 0x7;
8162 switch (select)
8163 {
8164 case 0:
8165 cpu.rA = cpu.switches.data_switches;
8166 break;
8167
8168 case 1:
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195 cpu.rA = 0;
8196 cpu.rA |= (word36) (cpu.switches.assignment [0] & 07LL)
8197 << (35 - (2 + 0));
8198 cpu.rA |= (word36) (cpu.switches.enable [0] & 01LL)
8199 << (35 - (3 + 0));
8200 cpu.rA |= (word36) (cpu.switches.init_enable [0] & 01LL)
8201 << (35 - (4 + 0));
8202 cpu.rA |= (word36) (cpu.switches.interlace [0] ? 1LL:0LL)
8203 << (35 - (5 + 0));
8204 cpu.rA |= (word36) (cpu.switches.store_size [0] & 07LL)
8205 << (35 - (8 + 0));
8206
8207 cpu.rA |= (word36) (cpu.switches.assignment [1] & 07LL)
8208 << (35 - (2 + 9));
8209 cpu.rA |= (word36) (cpu.switches.enable [1] & 01LL)
8210 << (35 - (3 + 9));
8211 cpu.rA |= (word36) (cpu.switches.init_enable [1] & 01LL)
8212 << (35 - (4 + 9));
8213 cpu.rA |= (word36) (cpu.switches.interlace [1] ? 1LL:0LL)
8214 << (35 - (5 + 9));
8215 cpu.rA |= (word36) (cpu.switches.store_size [1] & 07LL)
8216 << (35 - (8 + 9));
8217
8218 cpu.rA |= (word36) (cpu.switches.assignment [2] & 07LL)
8219 << (35 - (2 + 18));
8220 cpu.rA |= (word36) (cpu.switches.enable [2] & 01LL)
8221 << (35 - (3 + 18));
8222 cpu.rA |= (word36) (cpu.switches.init_enable [2] & 01LL)
8223 << (35 - (4 + 18));
8224 cpu.rA |= (word36) (cpu.switches.interlace [2] ? 1LL:0LL)
8225 << (35 - (5 + 18));
8226 cpu.rA |= (word36) (cpu.switches.store_size [2] & 07LL)
8227 << (35 - (8 + 18));
8228
8229 cpu.rA |= (word36) (cpu.switches.assignment [3] & 07LL)
8230 << (35 - (2 + 27));
8231 cpu.rA |= (word36) (cpu.switches.enable [3] & 01LL)
8232 << (35 - (3 + 27));
8233 cpu.rA |= (word36) (cpu.switches.init_enable [3] & 01LL)
8234 << (35 - (4 + 27));
8235 cpu.rA |= (word36) (cpu.switches.interlace [3] ? 1LL:0LL)
8236 << (35 - (5 + 27));
8237 cpu.rA |= (word36) (cpu.switches.store_size [3] & 07LL)
8238 << (35 - (8 + 27));
8239 break;
8240
8241 case 2:
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308 cpu.rA = 0;
8309 DPS8M_ (
8310 cpu.rA |= (word36) ((cpu.switches.interlace[0] == 2 ?
8311 1LL : 0LL) << (35- 0));
8312 cpu.rA |= (word36) ((cpu.switches.interlace[1] == 2 ?
8313 1LL : 0LL) << (35- 1));
8314 cpu.rA |= (word36) ((cpu.switches.interlace[2] == 2 ?
8315 1LL : 0LL) << (35- 2));
8316 cpu.rA |= (word36) ((cpu.switches.interlace[3] == 2 ?
8317 1LL : 0LL) << (35- 3));
8318 )
8319
8320 if (cpu.tweaks.l68_mode)
8321
8322
8323
8324 ;
8325 else
8326 cpu.rA |= (word36) ((01L)
8327 << (35- 5));
8328 cpu.rA |= (word36) ((cpu.switches.FLT_BASE & 0177LL)
8329 << (35-12));
8330 DPS8M_ (cpu.rA |= (word36) ((01L)
8331 << (35-13));)
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341 if (cpu.tweaks.l68_mode)
8342
8343
8344
8345 ;
8346 else
8347 cpu.rA |= (word36) ((01L)
8348 << (35-19));
8349 DPS8M_ (
8350
8351
8352
8353 cpu.rA |= (word36) ((cpu.switches.enable_cache ? 1 : 0)
8354 << (35-20));
8355
8356
8357
8358 cpu.rA |= (word36) ((cpu.switches.procMode)
8359 << (35-23));
8360 cpu.rA |= (word36) ((cpu.switches.procMode & 1U)
8361 << (35-24));
8362
8363
8364
8365
8366
8367
8368 cpu.rA |= (word36) ((cpu.options.proc_speed & 017LL)
8369 << (35-32));
8370 )
8371
8372 L68_ (
8373
8374
8375
8376
8377
8378
8379 cpu.rA |= (word36) ((016L)
8380 << (35-32));
8381 )
8382 cpu.rA |= (word36) ((cpu.switches.cpu_num & 07LL)
8383 << (35-35));
8384 break;
8385
8386 case 3:
8387 if (!cpu.tweaks.l68_mode) {
8388 cpu.rA = 0;
8389 break;
8390 }
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418 cpu.rA = 0;
8419 cpu.rA |= (word36) (cpu.switches.assignment [4] & 07LL)
8420 << (35 - (2 + 0));
8421 cpu.rA |= (word36) (cpu.switches.enable [4] & 01LL)
8422 << (35 - (3 + 0));
8423 cpu.rA |= (word36) (cpu.switches.init_enable [4] & 01LL)
8424 << (35 - (4 + 0));
8425 cpu.rA |= (word36) (cpu.switches.interlace [4] ? 1LL:0LL)
8426 << (35 - (5 + 0));
8427 cpu.rA |= (word36) (cpu.switches.store_size [4] & 07LL)
8428 << (35 - (8 + 0));
8429
8430 cpu.rA |= (word36) (cpu.switches.assignment [5] & 07LL)
8431 << (35 - (2 + 9));
8432 cpu.rA |= (word36) (cpu.switches.enable [5] & 01LL)
8433 << (35 - (3 + 9));
8434 cpu.rA |= (word36) (cpu.switches.init_enable [5] & 01LL)
8435 << (35 - (4 + 9));
8436 cpu.rA |= (word36) (cpu.switches.interlace [5] ? 1LL:0LL)
8437 << (35 - (5 + 9));
8438 cpu.rA |= (word36) (cpu.switches.store_size [5] & 07LL)
8439 << (35 - (8 + 9));
8440
8441 cpu.rA |= (word36) (cpu.switches.assignment [6] & 07LL)
8442 << (35 - (2 + 18));
8443 cpu.rA |= (word36) (cpu.switches.enable [6] & 01LL)
8444 << (35 - (3 + 18));
8445 cpu.rA |= (word36) (cpu.switches.init_enable [6] & 01LL)
8446 << (35 - (4 + 18));
8447 cpu.rA |= (word36) (cpu.switches.interlace [6] ? 1LL:0LL)
8448 << (35 - (5 + 18));
8449 cpu.rA |= (word36) (cpu.switches.store_size [6] & 07LL)
8450 << (35 - (8 + 18));
8451
8452 cpu.rA |= (word36) (cpu.switches.assignment [7] & 07LL)
8453 << (35 - (2 + 27));
8454 cpu.rA |= (word36) (cpu.switches.enable [7] & 01LL)
8455 << (35 - (3 + 27));
8456 cpu.rA |= (word36) (cpu.switches.init_enable [7] & 01LL)
8457 << (35 - (4 + 27));
8458 cpu.rA |= (word36) (cpu.switches.interlace [7] ? 1LL:0LL)
8459 << (35 - (5 + 27));
8460 cpu.rA |= (word36) (cpu.switches.store_size [7] & 07LL)
8461 << (35 - (8 + 27));
8462 break;
8463
8464 case 4:
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480 cpu.rA = 0;
8481 cpu.rA |= (word36) (cpu.switches.interlace [0] == 2 ?
8482 1LL : 0LL) << (35-13);
8483 cpu.rA |= (word36) (cpu.switches.interlace [1] == 2 ?
8484 1LL : 0LL) << (35-15);
8485 cpu.rA |= (word36) (cpu.switches.interlace [2] == 2 ?
8486 1LL : 0LL) << (35-17);
8487 cpu.rA |= (word36) (cpu.switches.interlace [3] == 2 ?
8488 1LL : 0LL) << (35-19);
8489 L68_ (
8490 cpu.rA |= (word36) (cpu.switches.interlace [4] == 2 ?
8491 1LL : 0LL) << (35-21);
8492 cpu.rA |= (word36) (cpu.switches.interlace [5] == 2 ?
8493 1LL : 0LL) << (35-23);
8494 cpu.rA |= (word36) (cpu.switches.interlace [6] == 2 ?
8495 1LL : 0LL) << (35-25);
8496 cpu.rA |= (word36) (cpu.switches.interlace [7] == 2 ?
8497 1LL : 0LL) << (35-27);
8498 )
8499 break;
8500
8501 default:
8502
8503 doFault (FAULT_IPR,
8504 fst_ill_mod,
8505 "Illegal register select value");
8506 }
8507 #if defined(TESTING)
8508 HDBGRegAW ("rsw");
8509 #endif
8510 SC_I_ZERO (cpu.rA == 0);
8511 SC_I_NEG (cpu.rA & SIGN36);
8512 }
8513 break;
8514
8515
8516
8517 case x0 (0015):
8518 {
8519
8520 #if defined(THREADZ) || defined(LOCKLESS)
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532 #endif
8533
8534
8535
8536
8537 int cpu_port_num = lookup_cpu_mem_map (cpup, cpu.iefpFinalAddress);
8538
8539 if (cpu_port_num < 0)
8540 {
8541 doFault (FAULT_ONC, fst_onc_nem, "(cioc)");
8542 }
8543 if (! get_scu_in_use (current_running_cpu_idx, cpu_port_num))
8544 {
8545 doFault (FAULT_ONC, fst_onc_nem, "(cioc)");
8546 }
8547 uint scuUnitIdx = get_scu_idx (current_running_cpu_idx, cpu_port_num);
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561 word8 sub_mask = getbits36_8 (cpu.CY, 0);
8562 word3 expander_command = getbits36_3 (cpu.CY, 21);
8563 uint scu_port_num = (uint) getbits36_3 (cpu.CY, 33);
8564 scu_cioc (current_running_cpu_idx, (uint) scuUnitIdx, scu_port_num,
8565 expander_command, sub_mask);
8566 }
8567 break;
8568
8569 case x0 (0553):
8570 {
8571
8572
8573
8574 uint cpu_port_num;
8575 DPS8M_ (cpu_port_num = (cpu.TPR.CA >> 15) & 03;)
8576 L68_ (cpu_port_num = (cpu.TPR.CA >> 15) & 07;)
8577 if (! get_scu_in_use (current_running_cpu_idx, cpu_port_num))
8578 {
8579 sim_warn ("smcm to non-existent controller on "
8580 "cpu %d port %d\n",
8581 current_running_cpu_idx, cpu_port_num);
8582 break;
8583 }
8584 uint scuUnitIdx = get_scu_idx (current_running_cpu_idx, cpu_port_num);
8585 t_stat rc = scu_smcm ((uint) scuUnitIdx,
8586 current_running_cpu_idx, cpu.rA, cpu.rQ);
8587 if (rc)
8588 return rc;
8589 }
8590 break;
8591
8592 case x0 (0451):
8593 {
8594
8595
8596
8597
8598
8599
8600
8601
8602 uint cpu_port_num;
8603 DPS8M_ (cpu_port_num = (cpu.TPR.CA >> 15) & 03;)
8604 L68_ (cpu_port_num = (cpu.TPR.CA >> 15) & 07;)
8605 if (! get_scu_in_use (current_running_cpu_idx, cpu_port_num))
8606 {
8607 DPS8M_ (return SCPE_OK;)
8608
8609
8610 if (cpu_port_num == 0)
8611 putbits36_4 (& cpu.faultRegister[0], 16, 010);
8612 else if (cpu_port_num == 1)
8613 putbits36_4 (& cpu.faultRegister[0], 20, 010);
8614 else if (cpu_port_num == 2)
8615 putbits36_4 (& cpu.faultRegister[0], 24, 010);
8616 else if (cpu_port_num == 3)
8617 putbits36 (& cpu.faultRegister[0], 28, 4, 010);
8618
8619 doFault (FAULT_CMD, fst_cmd_ctl, "(smic)");
8620 }
8621 uint scuUnitIdx = get_scu_idx (current_running_cpu_idx, cpu_port_num);
8622 t_stat rc = scu_smic ((uint) scuUnitIdx, current_running_cpu_idx,
8623 cpu_port_num, cpu.rA);
8624 if (rc)
8625 return rc;
8626 }
8627 break;
8628
8629 case x0 (0057):
8630 {
8631
8632
8633 uint cpu_port_num;
8634 DPS8M_ (cpu_port_num = (cpu.TPR.CA >> 10) & 03;)
8635 L68_ (cpu_port_num = (cpu.TPR.CA >> 10) & 07;)
8636 if (! get_scu_in_use (current_running_cpu_idx, cpu_port_num))
8637 {
8638
8639 if (cpu_port_num == 0)
8640 putbits36_4 (& cpu.faultRegister[0], 16, 010);
8641 else if (cpu_port_num == 1)
8642 putbits36_4 (& cpu.faultRegister[0], 20, 010);
8643 else if (cpu_port_num == 2)
8644 putbits36_4 (& cpu.faultRegister[0], 24, 010);
8645 else
8646 putbits36 (& cpu.faultRegister[0], 28, 4, 010);
8647 doFault (FAULT_CMD, fst_cmd_ctl, "(sscr)");
8648 }
8649 uint scuUnitIdx = get_scu_idx (current_running_cpu_idx, cpu_port_num);
8650 t_stat rc = scu_sscr (cpup, (uint) scuUnitIdx, current_running_cpu_idx,
8651 cpu_port_num, cpu.iefpFinalAddress & MASK15,
8652 cpu.rA, cpu.rQ);
8653
8654 if (rc)
8655 return rc;
8656 }
8657 break;
8658
8659
8660
8661 case x0 (0212):
8662 {
8663 word36 result;
8664 int rc = doABSA (cpup, & result);
8665 if (rc)
8666 return rc;
8667 cpu.rA = result;
8668 #if defined(TESTING)
8669 HDBGRegAW ("absa");
8670 #endif
8671 SC_I_ZERO (cpu.rA == 0);
8672 SC_I_NEG (cpu.rA & SIGN36);
8673 }
8674 break;
8675
8676 case x0 (0616):
8677
8678 #ifdef SYNCTEST
8679
8680 if (cpu.PPR.PSR == 034 && cpu.PPR.IC == 03535) {
8681 # ifdef HDBG
8682 hdbgPrint ();
8683 # endif
8684 sim_printf ("sys$trouble\r\n");
8685 exit (1);
8686 }
8687 #endif
8688
8689 #if defined(THREADZ) || defined(LOCKLESS)
8690 if (cpu.forceRestart) {
8691 cpu.forceRestart = 0;
8692 longjmp (cpu.jmpMain, JMP_FORCE_RESTART);
8693 }
8694 #endif
8695
8696 if (! cpu.tweaks.dis_enable)
8697 {
8698 return STOP_STOP;
8699 }
8700
8701
8702
8703
8704
8705
8706 advanceG7Faults (cpup);
8707
8708 if ((! cpu.tweaks.tro_enable) &&
8709 (! sample_interrupts (cpup)) &&
8710 (sim_qcount () == 0))
8711
8712 {
8713 sim_printf ("DIS@0%06o with no interrupts pending and"
8714 " no events in queue\n", cpu.PPR.IC);
8715 #if defined(WIN_STDIO)
8716 sim_printf ("\nCycles = %llu\n",
8717 #else
8718 sim_printf ("\nCycles = %'llu\n",
8719 #endif
8720 (unsigned long long)cpu.cycleCnt);
8721 #if defined(WIN_STDIO)
8722 sim_printf ("\nInstructions = %llu\n",
8723 #else
8724 sim_printf ("\nInstructions = %'llu\n",
8725 #endif
8726 (unsigned long long)cpu.cycleCnt);
8727 longjmp (cpu.jmpMain, JMP_STOP);
8728 }
8729
8730
8731 if (cpu.PPR.PSR == 0430 && cpu.PPR.IC == 012)
8732 {
8733 sim_printf ("BCE DIS causes CPU halt\n");
8734 sim_debug (DBG_MSG, & cpu_dev, "BCE DIS causes CPU halt\n");
8735 #if defined(LOCKLESS)
8736 bce_dis_called = true;
8737 #endif
8738 longjmp (cpu.jmpMain, JMP_STOP);
8739 }
8740
8741 #if defined(THREADZ) || defined(LOCKLESS)
8742
8743
8744
8745
8746 if (IWB_IRODD == 0000777616207) {
8747 cpu.rcfDelete = true;
8748 cpu.up = false;
8749 }
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783 if (UNLIKELY (cpu.syncClockModeMaster) &&
8784 (cpu.PPR.PSR != 0 || cpu.PPR.IC != 0)) {
8785 # ifdef SYNCTEST
8786 sim_printf ("giveup DIS %o:%o\r\n", cpu.PPR.PSR, cpu.PPR.IC);
8787 # endif
8788 giveupClockMaster (cpup);
8789 }
8790
8791
8792 #endif
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813 #if defined(ROUND_ROBIN)
8814 if (cpu.PPR.PSR == 034 && cpu.PPR.IC == 03535)
8815 {
8816 sim_printf ("[%lld] sys_trouble$die DIS causes CPU halt\n", cpu.cycleCnt);
8817 sim_debug (DBG_MSG, & cpu_dev, "sys_trouble$die DIS causes CPU halt\n");
8818
8819 cpu.isRunning = false;
8820 }
8821 #endif
8822 sim_debug (DBG_TRACEEXT, & cpu_dev, "entered DIS_cycle\n");
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847 if (sample_interrupts (cpup))
8848 {
8849 sim_debug (DBG_TRACEEXT, & cpu_dev, "DIS sees an interrupt\n");
8850 cpu.interrupt_flag = true;
8851 break;
8852 }
8853
8854
8855
8856 if (GET_I (cpu.cu.IWB) ? bG7PendingNoTRO (cpup) : bG7Pending (cpup))
8857
8858
8859
8860
8861
8862
8863
8864
8865 {
8866 sim_debug (DBG_TRACEEXT, & cpu_dev, "DIS sees a TRO\n");
8867 cpu.g7_flag = true;
8868 break;
8869 }
8870 else
8871 {
8872 sim_debug (DBG_TRACEEXT, & cpu_dev, "DIS refetches\n");
8873 #if defined(ROUND_ROBIN)
8874 if (cpu.tweaks.isolts_mode)
8875 {
8876
8877 cpu.isRunning = false;
8878 }
8879 #endif
8880 return CONT_DIS;
8881 }
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894 case x1 (0560):
8895 case x1 (0561):
8896 case x1 (0562):
8897 case x1 (0563):
8898 case x1 (0564):
8899 case x1 (0565):
8900 case x1 (0566):
8901 case x1 (0567):
8902 {
8903
8904 PNL (L68_ (DU_CYCLE_DDU_LDEA;))
8905
8906 if (getbits36_1 (cpu.CY, 23) != 0)
8907 doFault (FAULT_IPR,
8908 fst_ill_proc,
8909 "aarn C(Y)23 != 0");
8910
8911 uint32 n = opcode10 & 07;
8912 CPTUR (cptUsePRn + n);
8913
8914
8915 cpu.AR[n].WORDNO = GETHI (cpu.CY);
8916
8917 uint TA = getbits36_2 (cpu.CY, 21);
8918 uint CN = getbits36_3 (cpu.CY, 18);
8919
8920 switch (TA)
8921 {
8922 case CTA4:
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949 SET_AR_CHAR_BITNO (n, (word2) (CN/2), (CN % 2) ? 5 : 0);
8950
8951 break;
8952
8953 case CTA6:
8954
8955
8956 if (CN > 5)
8957 {
8958 cpu.AR[n].WORDNO = 0;
8959 SET_AR_CHAR_BITNO (n, 0, 0);
8960 doFault (FAULT_IPR, fst_ill_proc, "aarn TN > 5");
8961 }
8962
8963
8964
8965
8966 SET_AR_CHAR_BITNO (n, (word2) ((6 * CN) / 9),
8967 (6 * CN) % 9);
8968 break;
8969
8970 case CTA9:
8971
8972
8973
8974
8975 SET_AR_CHAR_BITNO (n, (word2) (CN >> 1), 0);
8976 break;
8977
8978 case CTAILL:
8979
8980
8981 cpu.AR[n].WORDNO = 0;
8982 SET_AR_CHAR_BITNO (n, 0, 0);
8983 #if defined(TESTING)
8984 HDBGRegARW (n, "aarn");
8985 #endif
8986 doFault (FAULT_IPR, fst_ill_proc, "aarn TA = 3");
8987 }
8988 #if defined(TESTING)
8989 HDBGRegARW (n, "aarn");
8990 #endif
8991 }
8992 break;
8993
8994
8995
8996 case x1 (0760):
8997 case x1 (0761):
8998 case x1 (0762):
8999 case x1 (0763):
9000 case x1 (0764):
9001 case x1 (0765):
9002 case x1 (0766):
9003 case x1 (0767):
9004 {
9005
9006
9007 PNL (L68_ (DU_CYCLE_DDU_LDEA;))
9008
9009 uint32 n = opcode10 & 07;
9010 CPTUR (cptUsePRn + n);
9011 cpu.AR[n].WORDNO = GETHI (cpu.CY);
9012
9013 SET_AR_CHAR_BITNO (n, getbits36_2 (cpu.CY, 18),
9014 getbits36_4 (cpu.CY, 20));
9015 #if defined(TESTING)
9016 HDBGRegARW (n, "larn");
9017 #endif
9018 }
9019 break;
9020
9021
9022
9023 case x1 (0463):
9024 PNL (L68_ (DU_CYCLE_DDU_LDEA;))
9025
9026 for (uint32 n = 0 ; n < 8 ; n += 1)
9027 {
9028 CPTUR (cptUsePRn + n);
9029 word36 tmp36 = cpu.Yblock8[n];
9030 cpu.AR[n].WORDNO = getbits36_18 (tmp36, 0);
9031 SET_AR_CHAR_BITNO (n, getbits36_2 (tmp36, 18),
9032 getbits36_4 (tmp36, 20));
9033 #if defined(TESTING)
9034 HDBGRegARW (n, "lareg");
9035 #endif
9036 }
9037 break;
9038
9039
9040
9041 case x1 (0467):
9042 PNL (L68_ (DU_CYCLE_DDU_LDEA;))
9043 words2du (cpup, cpu.Yblock8);
9044 break;
9045
9046
9047
9048 case x1 (0660):
9049 case x1 (0661):
9050 case x1 (0662):
9051 case x1 (0663):
9052 case x1 (0664):
9053 case x1 (0665):
9054 case x1 (0666):
9055 case x1 (0667):
9056 {
9057
9058 PNL (L68_ (DU_CYCLE_DDU_LDEA;))
9059
9060 uint32 n = opcode10 & 07;
9061 CPTUR (cptUsePRn + n);
9062
9063
9064 cpu.AR[n].WORDNO = GETHI (cpu.CY);
9065
9066 uint TN = getbits36_1 (cpu.CY, 21);
9067 uint CN = getbits36_3 (cpu.CY, 18);
9068
9069 switch(TN)
9070 {
9071 case CTN4:
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098 SET_AR_CHAR_BITNO (n, (word2) (CN/2), (CN % 2) ? 5 : 0);
9099
9100 break;
9101
9102 case CTN9:
9103
9104
9105 if ((CN & 1) != 0)
9106 doFault (FAULT_IPR, fst_ill_proc, "narn N9 and CN odd");
9107
9108 CN >>= 1;
9109
9110
9111
9112 SET_AR_CHAR_BITNO (n, (word2) CN, 0);
9113 break;
9114 }
9115 #if defined(TESTING)
9116 HDBGRegARW (n, "narn");
9117 #endif
9118 }
9119 break;
9120
9121
9122
9123
9124
9125
9126 case x1 (0540):
9127 case x1 (0541):
9128 case x1 (0542):
9129 case x1 (0543):
9130 case x1 (0544):
9131 case x1 (0545):
9132 case x1 (0546):
9133 case x1 (0547):
9134 {
9135
9136
9137 PNL (L68_ (DU_CYCLE_DDU_STEA;))
9138
9139 uint TA = getbits36_2 (cpu.CY, 21);
9140
9141
9142
9143 if (TA == 03) {
9144 dlyDoFault (FAULT_IPR, fst_ill_proc, "ARAn tag == 3");
9145 break;
9146 }
9147 if (getbits36_1 (cpu.CY, 23) != 0) {
9148 dlyDoFault (FAULT_IPR, fst_ill_proc, "ARAn b23 == 1");
9149 break;
9150 }
9151
9152 uint32 n = opcode10 & 07;
9153 CPTUR (cptUsePRn + n);
9154
9155
9156
9157 putbits36_18 (& cpu.CY, 0, cpu.AR[n].WORDNO & MASK18);
9158
9159
9160
9161
9162
9163 int CN = 0;
9164
9165 switch (TA)
9166 {
9167 case CTA4:
9168
9169
9170 CN = (9 * GET_AR_CHAR (n) + GET_AR_BITNO (n) - 1) / 4;
9171 putbits36_3 (& cpu.CY, 18, (word3) CN & MASK3);
9172 break;
9173
9174 case CTA6:
9175
9176
9177 CN = (9 * GET_AR_CHAR (n) + GET_AR_BITNO (n)) / 6;
9178 putbits36_3 (& cpu.CY, 18, (word3) CN & MASK3);
9179 break;
9180
9181 case CTA9:
9182
9183
9184
9185 putbits36_3 (& cpu.CY, 18,
9186 (word3) ((GET_AR_CHAR (n) & MASK2) << 1));
9187 break;
9188 }
9189 cpu.zone = 0777777700000;
9190 cpu.useZone = true;
9191 }
9192 break;
9193
9194
9195
9196
9197 case x1 (0640):
9198 case x1 (0641):
9199 case x1 (0642):
9200 case x1 (0643):
9201 case x1 (0644):
9202 case x1 (0645):
9203 case x1 (0646):
9204 case x1 (0647):
9205 {
9206 PNL (L68_ (DU_CYCLE_DDU_STEA;))
9207 uint32 n = opcode10 & 07;
9208 CPTUR (cptUsePRn + n);
9209
9210
9211
9212
9213 uint TN = getbits36_1 (cpu.CY, 21);
9214
9215
9216
9217 putbits36_18 (& cpu.CY, 0, cpu.AR[n].WORDNO & MASK18);
9218
9219 switch (TN)
9220 {
9221 case CTN4:
9222 {
9223
9224
9225
9226 word3 CN = (9 * GET_AR_CHAR (n) +
9227 GET_AR_BITNO (n) - 1) / 4;
9228 putbits36_3 (& cpu.CY, 18, CN & MASK3);
9229 break;
9230 }
9231 case CTN9:
9232
9233
9234
9235 putbits36_3 (& cpu.CY, 18,
9236 (word3) ((GET_AR_CHAR (n) & MASK2) << 1));
9237 break;
9238 }
9239 cpu.zone = 0777777700000;
9240 cpu.useZone = true;
9241 }
9242 break;
9243
9244
9245
9246
9247 case x1 (0740):
9248 case x1 (0741):
9249 case x1 (0742):
9250 case x1 (0743):
9251 case x1 (0744):
9252 case x1 (0745):
9253 case x1 (0746):
9254 case x1 (0747):
9255
9256
9257
9258 {
9259 PNL (L68_ (DU_CYCLE_DDU_STEA;))
9260 uint32 n = opcode10 & 07;
9261 CPTUR (cptUsePRn + n);
9262 putbits36 (& cpu.CY, 0, 18, cpu.PR[n].WORDNO);
9263
9264 putbits36 (& cpu.CY, 18, 2, GET_AR_CHAR (n));
9265 putbits36 (& cpu.CY, 20, 4, GET_AR_BITNO (n));
9266
9267 cpu.zone = 0777777770000;
9268 cpu.useZone = true;
9269 }
9270 break;
9271
9272
9273
9274 case x1 (0443):
9275
9276
9277 PNL (L68_ (DU_CYCLE_DDU_STEA;))
9278 (void)memset (cpu.Yblock8, 0, sizeof (cpu.Yblock8));
9279 for (uint32 n = 0 ; n < 8 ; n += 1)
9280 {
9281 CPTUR (cptUsePRn + n);
9282 word36 arx = 0;
9283 putbits36 (& arx, 0, 18, cpu.PR[n].WORDNO);
9284 putbits36 (& arx, 18, 2, GET_AR_CHAR (n));
9285 putbits36 (& arx, 20, 4, GET_AR_BITNO (n));
9286 cpu.Yblock8[n] = arx;
9287 }
9288 break;
9289
9290
9291
9292 case x1 (0447):
9293 PNL (L68_ (DU_CYCLE_DDU_STEA;))
9294 du2words (cpup, cpu.Yblock8);
9295 break;
9296
9297
9298
9299
9300
9301 case x1 (0502):
9302 asxbd (cpup, 4, false);
9303 break;
9304
9305
9306
9307 case x1 (0501):
9308 asxbd (cpup, 6, false);
9309 break;
9310
9311
9312
9313 case x1 (0500):
9314 asxbd (cpup, 9, false);
9315 break;
9316
9317
9318
9319 case x1 (0503):
9320 asxbd (cpup, 1, false);
9321 break;
9322
9323
9324
9325 case x1 (0507):
9326 asxbd (cpup, 36, false);
9327 break;
9328
9329
9330
9331 case x1 (0522):
9332 asxbd (cpup, 4, true);
9333 break;
9334
9335
9336
9337 case x1 (0521):
9338 asxbd (cpup, 6, true);
9339 break;
9340
9341
9342
9343 case x1 (0520):
9344 asxbd (cpup, 9, true);
9345 break;
9346
9347
9348
9349 case x1 (0523):
9350 asxbd (cpup, 1, true);
9351 break;
9352
9353
9354
9355 case x1 (0527):
9356 asxbd (cpup, 36, true);
9357 break;
9358
9359
9360
9361 case x1 (0106):
9362 cmpc (cpup);
9363 break;
9364
9365 case x1 (0120):
9366 scd (cpup);
9367 break;
9368
9369 case x1 (0121):
9370 scdr (cpup);
9371 break;
9372
9373 case x1 (0124):
9374 scm (cpup);
9375 break;
9376
9377 case x1 (0125):
9378 scmr (cpup);
9379 break;
9380
9381 case x1 (0164):
9382 tct (cpup);
9383 break;
9384
9385 case x1 (0165):
9386 tctr (cpup);
9387 break;
9388
9389
9390
9391 case x1 (0100):
9392 mlr (cpup);
9393 break;
9394
9395 case x1 (0101):
9396 mrl (cpup);
9397 break;
9398
9399 case x1 (0020):
9400 mve (cpup);
9401 break;
9402
9403 case x1 (0160):
9404 mvt (cpup);
9405 break;
9406
9407
9408
9409 case x1 (0303):
9410 cmpn (cpup);
9411 break;
9412
9413
9414
9415 case x1 (0300):
9416 mvn (cpup);
9417 break;
9418
9419 case x1 (0024):
9420 mvne (cpup);
9421 break;
9422
9423
9424
9425 case x1 (0060):
9426 csl (cpup);
9427 break;
9428
9429 case x1 (0061):
9430 csr (cpup);
9431 break;
9432
9433
9434
9435 case x1 (0066):
9436 cmpb (cpup);
9437 break;
9438
9439
9440
9441 case x1 (0064):
9442
9443
9444
9445 sztl (cpup);
9446 break;
9447
9448 case x1 (0065):
9449
9450
9451
9452 sztr (cpup);
9453 break;
9454
9455
9456
9457 case x1 (0301):
9458 btd (cpup);
9459 break;
9460
9461 case x1 (0305):
9462 dtb (cpup);
9463 break;
9464
9465
9466
9467 case x1 (0202):
9468 ad2d (cpup);
9469 break;
9470
9471 case x1 (0222):
9472 ad3d (cpup);
9473 break;
9474
9475
9476
9477 case x1 (0203):
9478 sb2d (cpup);
9479 break;
9480
9481 case x1 (0223):
9482 sb3d (cpup);
9483 break;
9484
9485
9486
9487 case x1 (0206):
9488 mp2d (cpup);
9489 break;
9490
9491 case x1 (0226):
9492 mp3d (cpup);
9493 break;
9494
9495
9496
9497 case x1 (0207):
9498 dv2d (cpup);
9499 break;
9500
9501 case x1 (0227):
9502 dv3d (cpup);
9503 break;
9504
9505 case x1 (0420):
9506 {
9507 if (cpu.tweaks.enable_emcall) {
9508 int ret = emCall (cpup);
9509 if (ret)
9510 return ret;
9511 break;
9512 }
9513 goto unimp;
9514 }
9515
9516 default:
9517 unimp:
9518 if (cpu.tweaks.halt_on_unimp)
9519 return STOP_STOP;
9520 doFault (FAULT_IPR,
9521 fst_ill_op,
9522 "Illegal instruction");
9523 }
9524 L68_ (
9525 cpu.ou.STR_OP = (is_ou && (i->info->flags & (STORE_OPERAND | STORE_YPAIR))) ? 1 : 0;
9526 cpu.ou.cycle |= ou_GOF;
9527 if (cpu.MR_cache.emr && cpu.MR_cache.ihr && is_ou)
9528 add_l68_OU_history (cpup);
9529 if (cpu.MR_cache.emr && cpu.MR_cache.ihr && is_du)
9530 add_l68_DU_history (cpup);
9531 )
9532 return SCPE_OK;
9533 }
9534
9535 #include <ctype.h>
9536 #include <time.h>
9537
9538
9539
9540
9541
9542
9543
9544 static uv_rusage_t startTime;
9545 static unsigned long long startInstrCnt;
9546
9547 static int emCall (cpu_state_t * cpup)
9548 {
9549 DCDstruct * i = & cpu.currentInstruction;
9550
9551
9552
9553
9554
9555 word36 op = M[i->address];
9556 switch (op)
9557 {
9558
9559
9560 case 1:
9561 sim_printf ("%lld\n", (long long int) M[i->address+1]);
9562 break;
9563
9564
9565 case 2:
9566 #if defined(LOCKLESS)
9567 bce_dis_called = true;
9568 #endif
9569 return STOP_STOP;
9570
9571
9572 case 3:
9573 startInstrCnt = cpu.instrCnt;
9574 uv_getrusage (& startTime);
9575 break;
9576
9577
9578 case 4:
9579 {
9580 #define ns_sec (1000000000L)
9581 #define ns_msec (1000000000L / 1000L)
9582 #define ns_usec (1000000000L / 1000L / 1000L)
9583 uv_rusage_t now;
9584 uv_getrusage (& now);
9585 uint64_t start = (uint64_t)((uint64_t)startTime.ru_utime.tv_usec * 1000ULL +
9586 (uint64_t)startTime.ru_utime.tv_sec * (uint64_t)ns_sec);
9587 uint64_t stop = (uint64_t)((uint64_t)now.ru_utime.tv_usec * 1000ULL +
9588 (uint64_t)now.ru_utime.tv_sec * (uint64_t)ns_sec);
9589 uint64_t delta = stop - start;
9590 uint64_t seconds = delta / ns_sec;
9591 uint64_t milliseconds = (delta / ns_msec) % 1000ULL;
9592 uint64_t microseconds = (delta / ns_usec) % 1000ULL;
9593 uint64_t nanoseconds = delta % 1000ULL;
9594 unsigned long long nInsts = (unsigned long long)((unsigned long long)cpu.instrCnt -
9595 (unsigned long long)startInstrCnt);
9596 double secs = (double)(((long double) delta) / ((long double) ns_sec));
9597 long double ips = (long double)(((long double) nInsts) / ((long double) secs));
9598 long double mips = (long double)(ips / 1000000.0L);
9599
9600 #if defined(WIN_STDIO)
9601 sim_printf ("CPU time %llu.%03llu,%03llu,%03llu\n",
9602 #else
9603 sim_printf ("CPU time %'llu.%03llu,%03llu,%03llu\n",
9604 #endif
9605 (unsigned long long) seconds,
9606 (unsigned long long) milliseconds,
9607 (unsigned long long) microseconds,
9608 (unsigned long long) nanoseconds);
9609 #if defined(WIN_STDIO)
9610 sim_printf ("%llu instructions\n", (unsigned long long) nInsts);
9611 sim_printf ("%f MIPS\n", (double) mips);
9612 #else
9613 sim_printf ("%'llu instructions\n", (unsigned long long) nInsts);
9614 sim_printf ("%'f MIPS\n", (double) mips);
9615 #endif
9616 break;
9617 }
9618 default:
9619 sim_printf ("emcall unknown op %llo\n", (unsigned long long)op);
9620 }
9621 return 0;
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
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 static int doABSA (cpu_state_t * cpup, word36 * result)
9817 {
9818 word36 res;
9819 sim_debug (DBG_APPENDING, & cpu_dev, "absa CA:%08o\n", cpu.TPR.CA);
9820
9821
9822
9823 if (get_addr_mode (cpup) == ABSOLUTE_mode && ! (cpu.cu.XSF || cpu.currentInstruction.b29))
9824 {
9825 * result = ((word36) (cpu.TPR.CA & MASK18)) << 12;
9826 return SCPE_OK;
9827 }
9828
9829
9830
9831
9832
9833
9834
9835
9836 res = (word36) doAppendCycleABSA (cpup, NULL, 0) << 12;
9837
9838 * result = res;
9839
9840 return SCPE_OK;
9841 }
9842
9843 void doRCU (cpu_state_t * cpup)
9844 {
9845 #if defined(LOOPTRC)
9846 elapsedtime ();
9847 sim_printf (" rcu to %05o:%06o PSR:IC %05o:%06o\r\n",
9848 (cpu.Yblock8[0]>>18)&MASK15, (cpu.Yblock8[4]>>18)&MASK18, cpu.PPR.PSR, cpu.PPR.IC);
9849 #endif
9850
9851 if_sim_debug (DBG_FAULT, & cpu_dev)
9852 {
9853 dump_words(cpup, cpu.Yblock8);
9854
9855
9856
9857
9858
9859 }
9860
9861 words2scu (cpup, cpu.Yblock8);
9862 decode_instruction (cpup, IWB_IRODD, & cpu.currentInstruction);
9863
9864
9865
9866 word1 saveP = cpu.PPR.P;
9867 if (TST_I_ABS == 0)
9868 set_addr_mode (cpup, APPEND_mode);
9869 else
9870 set_addr_mode (cpup, ABSOLUTE_mode);
9871 cpu.PPR.P = saveP;
9872
9873 if (getbits36_1 (cpu.Yblock8[1], 35) == 0)
9874 {
9875 sim_debug (DBG_FAULT, & cpu_dev, "RCU interrupt return\n");
9876 longjmp (cpu.jmpMain, JMP_REFETCH);
9877 }
9878
9879
9880 fauxDoAppendCycle (cpup, INSTRUCTION_FETCH);
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943 #define rework
9944 #if defined(rework)
9945 if (cpu.cu.FIF)
9946 {
9947
9948
9949
9950
9951
9952
9953 cpu.cu.rfi = 0;
9954 sim_debug (DBG_FAULT, & cpu_dev, "RCU FIF REFETCH return\n");
9955 longjmp (cpu.jmpMain, JMP_REFETCH);
9956 }
9957
9958
9959 if (cpu.cu.rfi)
9960 {
9961
9962 sim_debug (DBG_FAULT, & cpu_dev, "RCU rfi refetch return\n");
9963
9964
9965
9966 cpu.cu.rfi = 0;
9967 longjmp (cpu.jmpMain, JMP_REFETCH);
9968 }
9969
9970
9971
9972
9973 word5 fi_addr = getbits36_5 (cpu.Yblock8[1], 30);
9974 if (fi_addr == FAULT_MME ||
9975 fi_addr == FAULT_MME2 ||
9976 fi_addr == FAULT_MME3 ||
9977 fi_addr == FAULT_MME4 ||
9978 fi_addr == FAULT_DRL)
9979
9980 {
9981
9982 sim_debug (DBG_FAULT, & cpu_dev, "RCU MME2 restart return\n");
9983 cpu.cu.rfi = 0;
9984 longjmp (cpu.jmpMain, JMP_RESTART);
9985 }
9986 #else
9987 if (cpu.cu.rfi ||
9988 cpu.cu.FIF)
9989 {
9990
9991
9992
9993
9994
9995
9996 cpu.cu.rfi = 0;
9997 sim_debug (DBG_FAULT, & cpu_dev, "RCU rfi/FIF REFETCH return\n");
9998 longjmp (cpu.jmpMain, JMP_REFETCH);
9999 }
10000
10001
10002
10003
10004
10005 if (fi_addr == FAULT_MME2)
10006 {
10007
10008 sim_debug (DBG_FAULT, & cpu_dev, "RCU MME2 restart return\n");
10009 cpu.cu.rfi = 1;
10010 longjmp (cpu.jmpMain, JMP_RESTART);
10011 }
10012 #endif
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034 #if defined(rework)
10035 if (fi_addr == FAULT_DIV ||
10036 fi_addr == FAULT_OFL ||
10037 fi_addr == FAULT_IPR)
10038 {
10039 sim_debug (DBG_FAULT, & cpu_dev, "RCU sync fault return\n");
10040 cpu.cu.rfi = 0;
10041 longjmp (cpu.jmpMain, JMP_SYNC_FAULT_RETURN);
10042 }
10043 #else
10044 if (fi_addr == FAULT_MME ||
10045
10046 fi_addr == FAULT_MME3 ||
10047 fi_addr == FAULT_MME4 ||
10048 fi_addr == FAULT_DRL ||
10049 fi_addr == FAULT_DIV ||
10050 fi_addr == FAULT_OFL ||
10051 fi_addr == FAULT_IPR)
10052 {
10053 sim_debug (DBG_FAULT, & cpu_dev, "RCU MMEx sync fault return\n");
10054 cpu.cu.rfi = 0;
10055 longjmp (cpu.jmpMain, JMP_SYNC_FAULT_RETURN);
10056 }
10057 #endif
10058
10059
10060 if (fi_addr == FAULT_LUF)
10061 {
10062 cpu.cu.rfi = 1;
10063 sim_debug (DBG_FAULT, & cpu_dev, "RCU LUF RESTART return\n");
10064 longjmp (cpu.jmpMain, JMP_RESTART);
10065 }
10066
10067 if (fi_addr == FAULT_DF0 ||
10068 fi_addr == FAULT_DF1 ||
10069 fi_addr == FAULT_DF2 ||
10070 fi_addr == FAULT_DF3 ||
10071 fi_addr == FAULT_ACV ||
10072 fi_addr == FAULT_F1 ||
10073 fi_addr == FAULT_F2 ||
10074 fi_addr == FAULT_F3 ||
10075 fi_addr == FAULT_CMD ||
10076 fi_addr == FAULT_EXF)
10077 {
10078
10079 cpu.cu.rfi = 1;
10080 sim_debug (DBG_FAULT, & cpu_dev, "RCU ACV RESTART return\n");
10081 longjmp (cpu.jmpMain, JMP_RESTART);
10082 }
10083 sim_printf ("doRCU dies with unhandled fault number %d\n", fi_addr);
10084 doFault (FAULT_TRB,
10085 (_fault_subtype) {.bits=fi_addr},
10086 "doRCU dies with unhandled fault number");
10087 }