opINCB(void)1 static UINT32 opINCB(void) /* TRUSTED */
2 {
3 UINT8 appb;
4 modAdd=PC+1;
5 modDim=0;
6
7 amLength1=ReadAMAddress();
8
9 if (amFlag)
10 appb=(UINT8)v60.reg[amOut];
11 else
12 appb=MemRead8(amOut);
13
14 ADDB(appb, 1);
15
16 if (amFlag)
17 SETREG8(v60.reg[amOut], appb);
18 else
19 MemWrite8(amOut, appb);
20
21 return amLength1+1;
22 }
23
opINCH(void)24 static UINT32 opINCH(void) /* TRUSTED */
25 {
26 UINT16 apph;
27 modAdd=PC+1;
28 modDim=1;
29
30 amLength1=ReadAMAddress();
31
32 if (amFlag)
33 apph=(UINT16)v60.reg[amOut];
34 else
35 apph=MemRead16(amOut);
36
37 ADDW(apph, 1);
38
39 if (amFlag)
40 SETREG16(v60.reg[amOut], apph);
41 else
42 MemWrite16(amOut, apph);
43
44 return amLength1+1;
45 }
46
opINCW(void)47 static UINT32 opINCW(void) /* TRUSTED */
48 {
49 UINT32 appw;
50 modAdd=PC+1;
51 modDim=2;
52
53 amLength1=ReadAMAddress();
54
55 if (amFlag)
56 appw=v60.reg[amOut];
57 else
58 appw=MemRead32(amOut);
59
60 ADDL(appw, 1);
61
62 if (amFlag)
63 v60.reg[amOut]=appw;
64 else
65 MemWrite32(amOut,appw);
66
67 return amLength1+1;
68 }
69
opDECB(void)70 static UINT32 opDECB(void) /* TRUSTED */
71 {
72 UINT8 appb;
73 modAdd=PC+1;
74 modDim=0;
75
76 amLength1=ReadAMAddress();
77
78 if (amFlag)
79 appb=(UINT8)v60.reg[amOut];
80 else
81 appb=MemRead8(amOut);
82
83 SUBB(appb, 1);
84
85 if (amFlag)
86 SETREG8(v60.reg[amOut], appb);
87 else
88 MemWrite8(amOut, appb);
89
90 return amLength1+1;
91 }
92
opDECH(void)93 static UINT32 opDECH(void) /* TRUSTED */
94 {
95 UINT16 apph;
96 modAdd=PC+1;
97 modDim=1;
98
99 amLength1=ReadAMAddress();
100
101 if (amFlag)
102 apph=(UINT16)v60.reg[amOut];
103 else
104 apph=MemRead16(amOut);
105
106 SUBW(apph, 1);
107
108 if (amFlag)
109 SETREG16(v60.reg[amOut], apph);
110 else
111 MemWrite16(amOut, apph);
112
113 return amLength1+1;
114 }
115
opDECW(void)116 static UINT32 opDECW(void) /* TRUSTED */
117 {
118 UINT32 appw;
119 modAdd=PC+1;
120 modDim=2;
121
122 amLength1=ReadAMAddress();
123
124 if (amFlag)
125 appw=v60.reg[amOut];
126 else
127 appw=MemRead32(amOut);
128
129 SUBL(appw, 1);
130
131 if (amFlag)
132 v60.reg[amOut]=appw;
133 else
134 MemWrite32(amOut,appw);
135
136 return amLength1+1;
137 }
138
opJMP(void)139 static UINT32 opJMP(void) /* TRUSTED */
140 {
141 modAdd=PC+1;
142 modDim=0;
143
144 // Read the address of the operand
145 ReadAMAddress();
146
147 // It cannot be a register!!
148 assert(amFlag==0);
149
150 // Jump there
151 PC=amOut;
152 ChangePC(PC);
153
154 return 0;
155 }
156
opJSR(void)157 static UINT32 opJSR(void) /* TRUSTED */
158 {
159 modAdd=PC + 1;
160 modDim=0;
161
162 // Read the address of the operand
163 amLength1=ReadAMAddress();
164
165 // It cannot be a register!!
166 assert(amFlag==0);
167
168 // Save NextPC into the stack
169 SP -= 4;
170 MemWrite32(SP, PC + amLength1 + 1);
171
172 // Jump there
173 PC=amOut;
174 ChangePC(PC);
175
176 return 0;
177 }
178
opPREPARE(void)179 static UINT32 opPREPARE(void) /* somewhat TRUSTED */
180 {
181 modAdd=PC+1;
182 modDim=2;
183
184 // Read the operand
185 amLength1=ReadAM();
186
187 // step 1: save frame pointer on the stack
188 SP -= 4;
189 MemWrite32(SP, FP);
190
191 // step 2: FP = new SP
192 FP = SP;
193
194 // step 3: SP -= operand
195 SP -= amOut;
196
197 return amLength1 + 1;
198 }
199
opRET(void)200 static UINT32 opRET(void) /* TRUSTED */
201 {
202 modAdd=PC + 1;
203 modDim=2;
204
205 // Read the operand
206 ReadAM();
207
208 // Read return address from stack
209 PC=MemRead32(SP);
210 SP+=4;
211 ChangePC(PC);
212
213 // Restore AP from stack
214 AP=MemRead32(SP);
215 SP+=4;
216
217 // Skip stack frame
218 SP += amOut;
219
220 return 0;
221 }
222
opTRAP(void)223 static UINT32 opTRAP(void)
224 {
225 UINT32 oldPSW;
226
227 modAdd=PC + 1;
228 modDim=0;
229
230 // Read the operand
231 amLength1=ReadAM();
232
233 // Normalize the flags
234 NORMALIZEFLAGS();
235
236 switch ((amOut >> 4) & 0xF)
237 {
238 case 0:
239 if (!_OV) return amLength1+1;
240 else break;
241 case 1:
242 if (_OV) return amLength1+1;
243 else break;
244 case 2:
245 if (!_CY) return amLength1+1;
246 else break;
247 case 3:
248 if (_CY) return amLength1+1;
249 else break;
250 case 4:
251 if (!_Z) return amLength1+1;
252 else break;
253 case 5:
254 if (_Z) return amLength1+1;
255 else break;
256 case 6:
257 if (!(_CY | _Z)) return amLength1+1;
258 else break;
259 case 7:
260 if ((_CY | _Z)) return amLength1+1;
261 else break;
262 case 8:
263 if (!_S) return amLength1+1;
264 else break;
265 case 9:
266 if (_S) return amLength1+1;
267 else break;
268 case 10:
269 break;
270 case 11:
271 return amLength1+1;
272 case 12:
273 if (!(_S^_OV)) return amLength1+1;
274 else break;
275 case 13:
276 if ((_S^_OV)) return amLength1+1;
277 else break;
278 case 14:
279 if (!((_S^_OV)|_Z)) return amLength1+1;
280 else break;
281 case 15:
282 if (((_S^_OV)|_Z)) return amLength1+1;
283 else break;
284 }
285
286 oldPSW = v60_update_psw_for_exception(0, 0);
287
288 // Issue the software trap with interrupts
289 SP -= 4;
290 MemWrite32(SP, EXCEPTION_CODE_AND_SIZE(0x3000 + 0x100 * (amOut&0xF), 4));
291
292 SP -= 4;
293 MemWrite32(SP, oldPSW);
294
295 SP -= 4;
296 MemWrite32(SP, PC + amLength1 + 1);
297
298 PC = GETINTVECT(48 + (amOut&0xF));
299 ChangePC(PC);
300
301 return 0;
302 }
303
opRETIU(void)304 static UINT32 opRETIU(void) /* TRUSTED */
305 {
306 UINT32 newPSW;
307 modAdd=PC + 1;
308 modDim=1;
309
310 // Read the operand
311 ReadAM();
312
313 // Restore PC and PSW from stack
314 PC = MemRead32(SP);
315 SP += 4;
316 ChangePC(PC);
317
318 newPSW = MemRead32(SP);
319 SP += 4;
320
321 // Destroy stack frame
322 SP += amOut;
323
324 v60WritePSW(newPSW);
325
326 return 0;
327 }
328
opRETIS(void)329 static UINT32 opRETIS(void)
330 {
331 UINT32 newPSW;
332
333 modAdd=PC + 1;
334 modDim=1;
335
336 // Read the operand
337 ReadAM();
338
339 // Restore PC and PSW from stack
340 PC = MemRead32(SP);
341 SP += 4;
342 ChangePC(PC);
343
344 newPSW = MemRead32(SP);
345 SP += 4;
346
347 // Destroy stack frame
348 SP += amOut;
349
350 v60WritePSW(newPSW);
351
352 return 0;
353 }
354
opSTTASK(void)355 static UINT32 opSTTASK(void)
356 {
357 int i;
358 UINT32 adr;
359
360 modAdd=PC + 1;
361 modDim=2;
362
363 amLength1 = ReadAM();
364
365 adr = TR;
366
367 v60WritePSW(v60ReadPSW() | 0x10000000);
368 v60SaveStack();
369
370 MemWrite32(adr, TKCW);
371 adr += 4;
372 if(SYCW & 0x100) {
373 MemWrite32(adr, L0SP);
374 adr += 4;
375 }
376 if(SYCW & 0x200) {
377 MemWrite32(adr, L1SP);
378 adr += 4;
379 }
380 if(SYCW & 0x400) {
381 MemWrite32(adr, L2SP);
382 adr += 4;
383 }
384 if(SYCW & 0x800) {
385 MemWrite32(adr, L3SP);
386 adr += 4;
387 }
388
389 // 31 registers supported, _not_ 32
390 for(i=0; i<31; i++)
391 if(amOut & (1<<i)) {
392 MemWrite32(adr, v60.reg[i]);
393 adr += 4;
394 }
395
396 // #### Ignore the virtual addressing crap.
397
398 return amLength1 + 1;
399 }
400
opGETPSW(void)401 static UINT32 opGETPSW(void)
402 {
403 modAdd=PC + 1;
404 modDim=2;
405 modWriteValW=v60ReadPSW();
406
407 // Write PSW to the operand
408 amLength1=WriteAM();
409
410 return amLength1 + 1;
411 }
412
opTASI(void)413 static UINT32 opTASI(void)
414 {
415 UINT8 appb;
416 modAdd=PC + 1;
417 modDim=0;
418
419 // Load the address of the operand
420 amLength1=ReadAMAddress();
421
422 // Load UINT8 from the address
423 if (amFlag)
424 appb=(UINT8)v60.reg[amOut&0x1F];
425 else
426 appb=MemRead8(amOut);
427
428 // Set the flags for SUB appb,FF
429 SUBB(appb, 0xff);
430
431 // Write FF in the operand
432 if (amFlag)
433 SETREG8(v60.reg[amOut&0x1F], 0xFF);
434 else
435 MemWrite8(amOut,0xFF);
436
437 return amLength1 + 1;
438 }
439
440 #if 0
441 static UINT32 opCLRTLB(void)
442 {
443 modAdd=PC+1;
444 modDim=2;
445
446 // Read the operand
447 amLength1=ReadAM();
448
449 // @@@ TLB not yet emulated
450
451 return amLength1 + 1;
452 }
453 #endif
454
opPOPM(void)455 static UINT32 opPOPM(void)
456 {
457 int i;
458
459 modAdd=PC+1;
460 modDim=2;
461
462 // Read the bit register list
463 amLength1=ReadAM();
464
465 for (i=0;i<31;i++)
466 if (amOut & (1<<i))
467 {
468 v60.reg[i] = MemRead32(SP);
469 SP += 4;
470 }
471
472 if (amOut & (1<<31))
473 {
474 v60WritePSW((v60ReadPSW() & 0xffff0000) | MemRead16(SP));
475 SP += 4;
476 }
477
478 return amLength1 + 1;
479 }
480
opPUSHM(void)481 static UINT32 opPUSHM(void)
482 {
483 int i;
484
485 modAdd=PC+1;
486 modDim=2;
487
488 // Read the bit register list
489 amLength1=ReadAM();
490
491 if (amOut & (1<<31))
492 {
493 SP -= 4;
494 MemWrite32(SP,v60ReadPSW());
495 }
496
497 for (i=0;i<31;i++)
498 if (amOut & (1<<(30-i)))
499 {
500 SP -= 4;
501 MemWrite32(SP,v60.reg[(30-i)]);
502 }
503
504
505 return amLength1 + 1;
506 }
507
opTESTB(void)508 static UINT32 opTESTB(void) /* TRUSTED */
509 {
510 modAdd=PC+1;
511 modDim=0;
512
513 // Read the operand
514 amLength1=ReadAM();
515
516 _Z = (amOut == 0);
517 _S = ((amOut & 0x80) != 0);
518 _CY = 0;
519 _OV = 0;
520
521 return amLength1 + 1;
522 }
523
opTESTH(void)524 static UINT32 opTESTH(void) /* TRUSTED */
525 {
526 modAdd=PC+1;
527 modDim=1;
528
529 // Read the operand
530 amLength1=ReadAM();
531
532 _Z = (amOut == 0);
533 _S = ((amOut & 0x8000) != 0);
534 _CY = 0;
535 _OV = 0;
536
537 return amLength1 + 1;
538 }
539
opTESTW(void)540 static UINT32 opTESTW(void) /* TRUSTED */
541 {
542 modAdd=PC+1;
543 modDim=2;
544
545 // Read the operand
546 amLength1=ReadAM();
547
548 _Z = (amOut == 0);
549 _S = ((amOut & 0x80000000) != 0);
550 _CY = 0;
551 _OV = 0;
552
553 return amLength1 + 1;
554 }
555
opPUSH(void)556 static UINT32 opPUSH(void)
557 {
558 modAdd=PC+1;
559 modDim=2;
560
561 amLength1=ReadAM();
562
563 SP-=4;
564 MemWrite32(SP,amOut);
565
566 return amLength1 + 1;
567 }
568
opPOP(void)569 static UINT32 opPOP(void)
570 {
571 modAdd=PC+1;
572 modDim=2;
573 modWriteValW=MemRead32(SP);
574 SP+=4;
575 amLength1=WriteAM();
576
577 return amLength1 + 1;
578 }
579
580
opINCB_0(void)581 static UINT32 opINCB_0(void) { modM=0; return opINCB(); }
opINCB_1(void)582 static UINT32 opINCB_1(void) { modM=1; return opINCB(); }
opINCH_0(void)583 static UINT32 opINCH_0(void) { modM=0; return opINCH(); }
opINCH_1(void)584 static UINT32 opINCH_1(void) { modM=1; return opINCH(); }
opINCW_0(void)585 static UINT32 opINCW_0(void) { modM=0; return opINCW(); }
opINCW_1(void)586 static UINT32 opINCW_1(void) { modM=1; return opINCW(); }
587
opDECB_0(void)588 static UINT32 opDECB_0(void) { modM=0; return opDECB(); }
opDECB_1(void)589 static UINT32 opDECB_1(void) { modM=1; return opDECB(); }
opDECH_0(void)590 static UINT32 opDECH_0(void) { modM=0; return opDECH(); }
opDECH_1(void)591 static UINT32 opDECH_1(void) { modM=1; return opDECH(); }
opDECW_0(void)592 static UINT32 opDECW_0(void) { modM=0; return opDECW(); }
opDECW_1(void)593 static UINT32 opDECW_1(void) { modM=1; return opDECW(); }
594
opJMP_0(void)595 static UINT32 opJMP_0(void) { modM=0; return opJMP(); }
opJMP_1(void)596 static UINT32 opJMP_1(void) { modM=1; return opJMP(); }
597
opJSR_0(void)598 static UINT32 opJSR_0(void) { modM=0; return opJSR(); }
opJSR_1(void)599 static UINT32 opJSR_1(void) { modM=1; return opJSR(); }
600
opPREPARE_0(void)601 static UINT32 opPREPARE_0(void) { modM=0; return opPREPARE(); }
opPREPARE_1(void)602 static UINT32 opPREPARE_1(void) { modM=1; return opPREPARE(); }
603
opRET_0(void)604 static UINT32 opRET_0(void) { modM=0; return opRET(); }
opRET_1(void)605 static UINT32 opRET_1(void) { modM=1; return opRET(); }
606
opTRAP_0(void)607 static UINT32 opTRAP_0(void) { modM=0; return opTRAP(); }
opTRAP_1(void)608 static UINT32 opTRAP_1(void) { modM=1; return opTRAP(); }
609
opRETIU_0(void)610 static UINT32 opRETIU_0(void) { modM=0; return opRETIU(); }
opRETIU_1(void)611 static UINT32 opRETIU_1(void) { modM=1; return opRETIU(); }
612
opRETIS_0(void)613 static UINT32 opRETIS_0(void) { modM=0; return opRETIS(); }
opRETIS_1(void)614 static UINT32 opRETIS_1(void) { modM=1; return opRETIS(); }
615
opGETPSW_0(void)616 static UINT32 opGETPSW_0(void) { modM=0; return opGETPSW(); }
opGETPSW_1(void)617 static UINT32 opGETPSW_1(void) { modM=1; return opGETPSW(); }
618
opTASI_0(void)619 static UINT32 opTASI_0(void) { modM=0; return opTASI(); }
opTASI_1(void)620 static UINT32 opTASI_1(void) { modM=1; return opTASI(); }
621
622 #if 0 // iq_132 - not used??
623 static UINT32 opCLRTLB_0(void) { modM=0; return opCLRTLB(); }
624 static UINT32 opCLRTLB_1(void) { modM=1; return opCLRTLB(); }
625 #endif
626
opPOPM_0(void)627 static UINT32 opPOPM_0(void) { modM=0; return opPOPM(); }
opPOPM_1(void)628 static UINT32 opPOPM_1(void) { modM=1; return opPOPM(); }
629
opPUSHM_0(void)630 static UINT32 opPUSHM_0(void) { modM=0; return opPUSHM(); }
opPUSHM_1(void)631 static UINT32 opPUSHM_1(void) { modM=1; return opPUSHM(); }
632
opTESTB_0(void)633 static UINT32 opTESTB_0(void) { modM=0; return opTESTB(); }
opTESTB_1(void)634 static UINT32 opTESTB_1(void) { modM=1; return opTESTB(); }
635
opTESTH_0(void)636 static UINT32 opTESTH_0(void) { modM=0; return opTESTH(); }
opTESTH_1(void)637 static UINT32 opTESTH_1(void) { modM=1; return opTESTH(); }
638
opTESTW_0(void)639 static UINT32 opTESTW_0(void) { modM=0; return opTESTW(); }
opTESTW_1(void)640 static UINT32 opTESTW_1(void) { modM=1; return opTESTW(); }
641
opPUSH_0(void)642 static UINT32 opPUSH_0(void) { modM=0; return opPUSH(); }
opPUSH_1(void)643 static UINT32 opPUSH_1(void) { modM=1; return opPUSH(); }
644
opPOP_0(void)645 static UINT32 opPOP_0(void) { modM=0; return opPOP(); }
opPOP_1(void)646 static UINT32 opPOP_1(void) { modM=1; return opPOP(); }
647
opSTTASK_0(void)648 static UINT32 opSTTASK_0(void) { modM=0; return opSTTASK(); }
opSTTASK_1(void)649 static UINT32 opSTTASK_1(void) { modM=1; return opSTTASK(); }
650