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