1
2 // AM2 Functions (for ReadAMAddress)
3 // *********************************
4
am2Register(void)5 static UINT32 am2Register(void)
6 {
7 amFlag = 1;
8 amOut = modVal&0x1F;
9 return 1;
10 }
11
am2RegisterIndirect(void)12 static UINT32 am2RegisterIndirect(void)
13 {
14 amFlag = 0;
15 amOut = v60.reg[modVal&0x1F];
16 return 1;
17 }
18
bam2RegisterIndirect(void)19 static UINT32 bam2RegisterIndirect(void)
20 {
21 amFlag = 0;
22 amOut = v60.reg[modVal&0x1F];
23 bamOffset = 0;
24 return 1;
25 }
26
am2RegisterIndirectIndexed(void)27 static UINT32 am2RegisterIndirectIndexed(void)
28 {
29 amFlag = 0;
30
31 switch (modDim)
32 {
33 case 0:
34 amOut = v60.reg[modVal2&0x1F] + v60.reg[modVal&0x1F];
35 break;
36 case 1:
37 amOut = v60.reg[modVal2&0x1F] + v60.reg[modVal&0x1F] * 2;
38 break;
39 case 2:
40 amOut = v60.reg[modVal2&0x1F] + v60.reg[modVal&0x1F] * 4;
41 break;
42 case 3:
43 amOut = v60.reg[modVal2&0x1F] + v60.reg[modVal&0x1F] * 8;
44 break;
45 }
46
47 return 2;
48 }
49
bam2RegisterIndirectIndexed(void)50 static UINT32 bam2RegisterIndirectIndexed(void)
51 {
52 amFlag = 0;
53 amOut = v60.reg[modVal2&0x1F];
54 bamOffset = v60.reg[modVal&0x1F];
55 return 2;
56 }
57
am2Autoincrement(void)58 static UINT32 am2Autoincrement(void)
59 {
60 amFlag = 0;
61 amOut = v60.reg[modVal&0x1F];
62
63 switch (modDim)
64 {
65 case 0:
66 v60.reg[modVal&0x1F] += 1;
67 break;
68 case 1:
69 v60.reg[modVal&0x1F] += 2;
70 break;
71 case 2:
72 v60.reg[modVal&0x1F] += 4;
73 break;
74 case 3:
75 v60.reg[modVal&0x1F] += 8;
76 break;
77 }
78
79 return 1;
80 }
81
bam2Autoincrement(void)82 static UINT32 bam2Autoincrement(void)
83 {
84 amFlag = 0;
85 amOut = v60.reg[modVal&0x1F];
86 bamOffset = 0;
87
88 switch (modDim)
89 {
90 case 10:
91 v60.reg[modVal&0x1F]+=1;
92 break;
93 case 11:
94 v60.reg[modVal&0x1F]+=4;
95 break;
96 default:
97 //fatalerror("CPU - AM2 - 7 (t0 PC=%x)", PC);
98 break;
99 }
100
101 return 1;
102 }
103
am2Autodecrement(void)104 static UINT32 am2Autodecrement(void)
105 {
106 amFlag = 0;
107
108 switch (modDim)
109 {
110 case 0:
111 v60.reg[modVal&0x1F] -= 1;
112 break;
113 case 1:
114 v60.reg[modVal&0x1F] -= 2;
115 break;
116 case 2:
117 v60.reg[modVal&0x1F] -= 4;
118 break;
119 case 3:
120 v60.reg[modVal&0x1F] -= 8;
121 break;
122 }
123
124 amOut = v60.reg[modVal&0x1F];
125 return 1;
126 }
127
bam2Autodecrement(void)128 static UINT32 bam2Autodecrement(void)
129 {
130 amFlag = 0;
131 bamOffset = 0;
132
133 switch (modDim)
134 {
135 case 10:
136 v60.reg[modVal&0x1F]-=1;
137 break;
138 case 11:
139 v60.reg[modVal&0x1F]-=4;
140 break;
141 default:
142 //fatalerror("CPU - BAM2 - 7 (PC=%06x)", PC);
143 break;
144 }
145
146 amOut = v60.reg[modVal&0x1F];
147 return 1;
148 }
149
150
am2Displacement8(void)151 static UINT32 am2Displacement8(void)
152 {
153 amFlag = 0;
154 amOut = v60.reg[modVal&0x1F] + (INT8)OpRead8(modAdd+1);
155
156 return 2;
157 }
158
bam2Displacement8(void)159 static UINT32 bam2Displacement8(void)
160 {
161 amFlag = 0;
162 amOut = v60.reg[modVal&0x1F];
163 bamOffset = (INT8)OpRead8(modAdd+1);
164
165 return 2;
166 }
167
am2Displacement16(void)168 static UINT32 am2Displacement16(void)
169 {
170 amFlag = 0;
171 amOut = v60.reg[modVal&0x1F] + (INT16)OpRead16(modAdd+1);
172
173 return 3;
174 }
175
bam2Displacement16(void)176 static UINT32 bam2Displacement16(void)
177 {
178 amFlag = 0;
179 amOut = v60.reg[modVal&0x1F];
180 bamOffset = (INT16)OpRead16(modAdd+1);
181
182 return 3;
183 }
184
am2Displacement32(void)185 static UINT32 am2Displacement32(void)
186 {
187 amFlag = 0;
188 amOut = v60.reg[modVal&0x1F] + OpRead32(modAdd+1);
189
190 return 5;
191 }
192
bam2Displacement32(void)193 static UINT32 bam2Displacement32(void)
194 {
195 amFlag = 0;
196 amOut = v60.reg[modVal&0x1F];
197 bamOffset = OpRead32(modAdd+1);
198
199 return 5;
200 }
201
am2DisplacementIndexed8(void)202 static UINT32 am2DisplacementIndexed8(void)
203 {
204 amFlag = 0;
205
206 switch (modDim)
207 {
208 case 0:
209 amOut = v60.reg[modVal2&0x1F] + (INT8)OpRead8(modAdd+2) + v60.reg[modVal&0x1F];
210 break;
211 case 1:
212 amOut = v60.reg[modVal2&0x1F] + (INT8)OpRead8(modAdd+2) + v60.reg[modVal&0x1F] * 2;
213 break;
214 case 2:
215 amOut = v60.reg[modVal2&0x1F] + (INT8)OpRead8(modAdd+2) + v60.reg[modVal&0x1F] * 4;
216 break;
217 case 3:
218 amOut = v60.reg[modVal2&0x1F] + (INT8)OpRead8(modAdd+2) + v60.reg[modVal&0x1F] * 8;
219 break;
220 }
221
222 return 3;
223 }
224
bam2DisplacementIndexed8(void)225 static UINT32 bam2DisplacementIndexed8(void)
226 {
227 amFlag = 0;
228 amOut = v60.reg[modVal2&0x1F] + (INT8)OpRead8(modAdd+2);
229 bamOffset = v60.reg[modVal&0x1F];
230
231 return 3;
232 }
233
am2DisplacementIndexed16(void)234 static UINT32 am2DisplacementIndexed16(void)
235 {
236 amFlag = 0;
237
238 switch (modDim)
239 {
240 case 0:
241 amOut = v60.reg[modVal2&0x1F] + (INT16)OpRead16(modAdd+2) + v60.reg[modVal&0x1F];
242 break;
243 case 1:
244 amOut = v60.reg[modVal2&0x1F] + (INT16)OpRead16(modAdd+2) + v60.reg[modVal&0x1F] * 2;
245 break;
246 case 2:
247 amOut = v60.reg[modVal2&0x1F] + (INT16)OpRead16(modAdd+2) + v60.reg[modVal&0x1F] * 4;
248 break;
249 case 3:
250 amOut = v60.reg[modVal2&0x1F] + (INT16)OpRead16(modAdd+2) + v60.reg[modVal&0x1F] * 8;
251 break;
252 }
253
254 return 4;
255 }
256
bam2DisplacementIndexed16(void)257 static UINT32 bam2DisplacementIndexed16(void)
258 {
259 amFlag = 0;
260 amOut = v60.reg[modVal2&0x1F] + (INT16)OpRead16(modAdd+2);
261 bamOffset = v60.reg[modVal&0x1F];
262
263 return 4;
264 }
265
am2DisplacementIndexed32(void)266 static UINT32 am2DisplacementIndexed32(void)
267 {
268 amFlag = 0;
269
270 switch (modDim)
271 {
272 case 0:
273 amOut = v60.reg[modVal2&0x1F] + OpRead32(modAdd+2) + v60.reg[modVal&0x1F];
274 break;
275 case 1:
276 amOut = v60.reg[modVal2&0x1F] + OpRead32(modAdd+2) + v60.reg[modVal&0x1F] * 2;
277 break;
278 case 2:
279 amOut = v60.reg[modVal2&0x1F] + OpRead32(modAdd+2) + v60.reg[modVal&0x1F] * 4;
280 break;
281 case 3:
282 amOut = v60.reg[modVal2&0x1F] + OpRead32(modAdd+2) + v60.reg[modVal&0x1F] * 8;
283 break;
284 }
285
286 return 6;
287 }
288
bam2DisplacementIndexed32(void)289 static UINT32 bam2DisplacementIndexed32(void)
290 {
291 amFlag = 0;
292 amOut = v60.reg[modVal2&0x1F] + OpRead32(modAdd+2);
293 bamOffset = v60.reg[modVal&0x1F];
294
295 return 6;
296 }
297
am2PCDisplacement8(void)298 static UINT32 am2PCDisplacement8(void)
299 {
300 amFlag = 0;
301 amOut = PC + (INT8)OpRead8(modAdd+1);
302
303 return 2;
304 }
305
bam2PCDisplacement8(void)306 static UINT32 bam2PCDisplacement8(void)
307 {
308 amFlag = 0;
309 amOut = PC;
310 bamOffset = (INT8)OpRead8(modAdd+1);
311
312 return 2;
313 }
314
am2PCDisplacement16(void)315 static UINT32 am2PCDisplacement16(void)
316 {
317 amFlag = 0;
318 amOut = PC + (INT16)OpRead16(modAdd+1);
319
320 return 3;
321 }
322
bam2PCDisplacement16(void)323 static UINT32 bam2PCDisplacement16(void)
324 {
325 amFlag = 0;
326 amOut = PC;
327 bamOffset = (INT16)OpRead16(modAdd+1);
328
329 return 3;
330 }
331
am2PCDisplacement32(void)332 static UINT32 am2PCDisplacement32(void)
333 {
334 amFlag = 0;
335 amOut = PC + OpRead32(modAdd+1);
336
337 return 5;
338 }
339
bam2PCDisplacement32(void)340 static UINT32 bam2PCDisplacement32(void)
341 {
342 amFlag = 0;
343 amOut = PC;
344 bamOffset = OpRead32(modAdd+1);
345
346 return 5;
347 }
348
349
am2PCDisplacementIndexed8(void)350 static UINT32 am2PCDisplacementIndexed8(void)
351 {
352 amFlag = 0;
353
354 switch (modDim)
355 {
356 case 0:
357 amOut = PC + (INT8)OpRead8(modAdd+2) + v60.reg[modVal&0x1F];
358 break;
359 case 1:
360 amOut = PC + (INT8)OpRead8(modAdd+2) + v60.reg[modVal&0x1F] * 2;
361 break;
362 case 2:
363 amOut = PC + (INT8)OpRead8(modAdd+2) + v60.reg[modVal&0x1F] * 4;
364 break;
365 case 3:
366 amOut = PC + (INT8)OpRead8(modAdd+2) + v60.reg[modVal&0x1F] * 8;
367 break;
368 }
369
370 return 3;
371 }
372
bam2PCDisplacementIndexed8(void)373 static UINT32 bam2PCDisplacementIndexed8(void)
374 {
375 amFlag = 0;
376 amOut = PC + (INT8)OpRead8(modAdd+2);
377 bamOffset = v60.reg[modVal&0x1F];
378
379 return 3;
380 }
381
am2PCDisplacementIndexed16(void)382 static UINT32 am2PCDisplacementIndexed16(void)
383 {
384 amFlag = 0;
385
386 switch (modDim)
387 {
388 case 0:
389 amOut = PC + (INT16)OpRead16(modAdd+2) + v60.reg[modVal&0x1F];
390 break;
391 case 1:
392 amOut = PC + (INT16)OpRead16(modAdd+2) + v60.reg[modVal&0x1F] * 2;
393 break;
394 case 2:
395 amOut = PC + (INT16)OpRead16(modAdd+2) + v60.reg[modVal&0x1F] * 4;
396 break;
397 case 3:
398 amOut = PC + (INT16)OpRead16(modAdd+2) + v60.reg[modVal&0x1F] * 8;
399 break;
400 }
401
402 return 4;
403 }
404
bam2PCDisplacementIndexed16(void)405 static UINT32 bam2PCDisplacementIndexed16(void)
406 {
407 amFlag = 0;
408 amOut = PC + (INT16)OpRead16(modAdd+2);
409 bamOffset = v60.reg[modVal&0x1F];
410
411 return 4;
412 }
413
am2PCDisplacementIndexed32(void)414 static UINT32 am2PCDisplacementIndexed32(void)
415 {
416 amFlag = 0;
417
418 switch (modDim)
419 {
420 case 0:
421 amOut = PC + OpRead32(modAdd+2) + v60.reg[modVal&0x1F];
422 break;
423 case 1:
424 amOut = PC + OpRead32(modAdd+2) + v60.reg[modVal&0x1F] * 2;
425 break;
426 case 2:
427 amOut = PC + OpRead32(modAdd+2) + v60.reg[modVal&0x1F] * 4;
428 break;
429 case 3:
430 amOut = PC + OpRead32(modAdd+2) + v60.reg[modVal&0x1F] * 8;
431 break;
432 }
433
434 return 6;
435 }
436
bam2PCDisplacementIndexed32(void)437 static UINT32 bam2PCDisplacementIndexed32(void)
438 {
439 amFlag = 0;
440 amOut = PC + OpRead32(modAdd+2);
441 bamOffset = v60.reg[modVal&0x1F];
442
443 return 6;
444 }
445
am2DisplacementIndirect8(void)446 static UINT32 am2DisplacementIndirect8(void)
447 {
448 amFlag = 0;
449 amOut = MemRead32(v60.reg[modVal&0x1F] + (INT8)OpRead8(modAdd+1));
450
451 return 2;
452 }
453
bam2DisplacementIndirect8(void)454 static UINT32 bam2DisplacementIndirect8(void)
455 {
456 amFlag = 0;
457 amOut = MemRead32(v60.reg[modVal&0x1F] + (INT8)OpRead8(modAdd+1));
458 bamOffset = 0;
459 return 2;
460 }
461
am2DisplacementIndirect16(void)462 static UINT32 am2DisplacementIndirect16(void)
463 {
464 amFlag = 0;
465 amOut = MemRead32(v60.reg[modVal&0x1F] + (INT16)OpRead16(modAdd+1));
466
467 return 3;
468 }
469
bam2DisplacementIndirect16(void)470 static UINT32 bam2DisplacementIndirect16(void)
471 {
472 amFlag = 0;
473 amOut = MemRead32(v60.reg[modVal&0x1F] + (INT16)OpRead16(modAdd+1));
474 bamOffset = 0;
475 return 3;
476 }
477
am2DisplacementIndirect32(void)478 static UINT32 am2DisplacementIndirect32(void)
479 {
480 amFlag = 0;
481 amOut = MemRead32(v60.reg[modVal&0x1F] + OpRead32(modAdd+1));
482
483 return 5;
484 }
485
bam2DisplacementIndirect32(void)486 static UINT32 bam2DisplacementIndirect32(void)
487 {
488 amFlag = 0;
489 amOut = MemRead32(v60.reg[modVal&0x1F] + OpRead32(modAdd+1));
490 bamOffset = 0;
491
492 return 5;
493 }
494
am2DisplacementIndirectIndexed8(void)495 static UINT32 am2DisplacementIndirectIndexed8(void)
496 {
497 amFlag = 0;
498
499 switch (modDim)
500 {
501 case 0:
502 amOut = MemRead32(v60.reg[modVal2&0x1F] + (INT8)OpRead8(modAdd+2)) + v60.reg[modVal&0x1F];
503 break;
504 case 1:
505 amOut = MemRead32(v60.reg[modVal2&0x1F] + (INT8)OpRead8(modAdd+2)) + v60.reg[modVal&0x1F] * 2;
506 break;
507 case 2:
508 amOut = MemRead32(v60.reg[modVal2&0x1F] + (INT8)OpRead8(modAdd+2)) + v60.reg[modVal&0x1F] * 4;
509 break;
510 case 3:
511 amOut = MemRead32(v60.reg[modVal2&0x1F] + (INT8)OpRead8(modAdd+2)) + v60.reg[modVal&0x1F] * 8;
512 break;
513 }
514
515 return 3;
516 }
517
bam2DisplacementIndirectIndexed8(void)518 static UINT32 bam2DisplacementIndirectIndexed8(void)
519 {
520 amFlag = 0;
521 amOut = MemRead32(v60.reg[modVal2&0x1F] + (INT8)OpRead8(modAdd+2));
522 bamOffset = v60.reg[modVal&0x1F];
523
524 return 3;
525 }
526
am2DisplacementIndirectIndexed16(void)527 static UINT32 am2DisplacementIndirectIndexed16(void)
528 {
529 amFlag = 0;
530
531 switch (modDim)
532 {
533 case 0:
534 amOut = MemRead32(v60.reg[modVal2&0x1F] + (INT16)OpRead16(modAdd+2)) + v60.reg[modVal&0x1F];
535 break;
536 case 1:
537 amOut = MemRead32(v60.reg[modVal2&0x1F] + (INT16)OpRead16(modAdd+2)) + v60.reg[modVal&0x1F] * 2;
538 break;
539 case 2:
540 amOut = MemRead32(v60.reg[modVal2&0x1F] + (INT16)OpRead16(modAdd+2)) + v60.reg[modVal&0x1F] * 4;
541 break;
542 case 3:
543 amOut = MemRead32(v60.reg[modVal2&0x1F] + (INT16)OpRead16(modAdd+2)) + v60.reg[modVal&0x1F] * 8;
544 break;
545 }
546
547 return 4;
548 }
549
bam2DisplacementIndirectIndexed16(void)550 static UINT32 bam2DisplacementIndirectIndexed16(void)
551 {
552 amFlag = 0;
553 amOut = MemRead32(v60.reg[modVal2&0x1F] + (INT16)OpRead16(modAdd+2));
554 bamOffset = v60.reg[modVal&0x1F];
555
556 return 4;
557 }
558
am2DisplacementIndirectIndexed32(void)559 static UINT32 am2DisplacementIndirectIndexed32(void)
560 {
561 amFlag = 0;
562
563 switch (modDim)
564 {
565 case 0:
566 amOut = MemRead32(v60.reg[modVal2&0x1F] + OpRead32(modAdd+2)) + v60.reg[modVal&0x1F];
567 break;
568 case 1:
569 amOut = MemRead32(v60.reg[modVal2&0x1F] + OpRead32(modAdd+2)) + v60.reg[modVal&0x1F] * 2;
570 break;
571 case 2:
572 amOut = MemRead32(v60.reg[modVal2&0x1F] + OpRead32(modAdd+2)) + v60.reg[modVal&0x1F] * 4;
573 break;
574 case 3:
575 amOut = MemRead32(v60.reg[modVal2&0x1F] + OpRead32(modAdd+2)) + v60.reg[modVal&0x1F] * 8;
576 break;
577 }
578
579 return 6;
580 }
581
bam2DisplacementIndirectIndexed32(void)582 static UINT32 bam2DisplacementIndirectIndexed32(void)
583 {
584 amFlag = 0;
585 amOut = MemRead32(v60.reg[modVal2&0x1F] + OpRead32(modAdd+2));
586 bamOffset = v60.reg[modVal&0x1F];
587
588 return 6;
589 }
590
am2PCDisplacementIndirect8(void)591 static UINT32 am2PCDisplacementIndirect8(void)
592 {
593 amFlag = 0;
594 amOut = MemRead32(PC + (INT8)OpRead8(modAdd+1));
595
596 return 2;
597 }
598
bam2PCDisplacementIndirect8(void)599 static UINT32 bam2PCDisplacementIndirect8(void)
600 {
601 amFlag = 0;
602 amOut = MemRead32(PC + (INT8)OpRead8(modAdd+1));
603 bamOffset = 0;
604
605 return 2;
606 }
607
am2PCDisplacementIndirect16(void)608 static UINT32 am2PCDisplacementIndirect16(void)
609 {
610 amFlag = 0;
611 amOut = MemRead32(PC + (INT16)OpRead16(modAdd+1));
612
613 return 3;
614 }
615
bam2PCDisplacementIndirect16(void)616 static UINT32 bam2PCDisplacementIndirect16(void)
617 {
618 amFlag = 0;
619 amOut = MemRead32(PC + (INT16)OpRead16(modAdd+1));
620 bamOffset = 0;
621
622 return 3;
623 }
624
am2PCDisplacementIndirect32(void)625 static UINT32 am2PCDisplacementIndirect32(void)
626 {
627 amFlag = 0;
628 amOut = MemRead32(PC + OpRead32(modAdd+1));
629
630 return 5;
631 }
632
bam2PCDisplacementIndirect32(void)633 static UINT32 bam2PCDisplacementIndirect32(void)
634 {
635 amFlag = 0;
636 amOut = MemRead32(PC + OpRead32(modAdd+1));
637 bamOffset = 0;
638
639 return 5;
640 }
641
am2PCDisplacementIndirectIndexed8(void)642 static UINT32 am2PCDisplacementIndirectIndexed8(void)
643 {
644 amFlag = 0;
645
646 switch (modDim)
647 {
648 case 0:
649 amOut = MemRead32(PC + (INT8)OpRead8(modAdd+2)) + v60.reg[modVal&0x1F];
650 break;
651 case 1:
652 amOut = MemRead32(PC + (INT8)OpRead8(modAdd+2)) + v60.reg[modVal&0x1F] * 2;
653 break;
654 case 2:
655 amOut = MemRead32(PC + (INT8)OpRead8(modAdd+2)) + v60.reg[modVal&0x1F] * 4;
656 break;
657 case 3:
658 amOut = MemRead32(PC + (INT8)OpRead8(modAdd+2)) + v60.reg[modVal&0x1F] * 8;
659 break;
660 }
661
662 return 3;
663 }
664
bam2PCDisplacementIndirectIndexed8(void)665 static UINT32 bam2PCDisplacementIndirectIndexed8(void)
666 {
667 amFlag = 0;
668 amOut = MemRead32(PC + (INT8)OpRead8(modAdd+2));
669 bamOffset = v60.reg[modVal&0x1F];
670
671 return 3;
672 }
673
am2PCDisplacementIndirectIndexed16(void)674 static UINT32 am2PCDisplacementIndirectIndexed16(void)
675 {
676 amFlag = 0;
677
678 switch (modDim)
679 {
680 case 0:
681 amOut = MemRead32(PC + (INT16)OpRead16(modAdd+2)) + v60.reg[modVal&0x1F];
682 break;
683 case 1:
684 amOut = MemRead32(PC + (INT16)OpRead16(modAdd+2)) + v60.reg[modVal&0x1F] * 2;
685 break;
686 case 2:
687 amOut = MemRead32(PC + (INT16)OpRead16(modAdd+2)) + v60.reg[modVal&0x1F] * 4;
688 break;
689 case 3:
690 amOut = MemRead32(PC + (INT16)OpRead16(modAdd+2)) + v60.reg[modVal&0x1F] * 8;
691 break;
692 }
693
694 return 4;
695 }
696
697
bam2PCDisplacementIndirectIndexed16(void)698 static UINT32 bam2PCDisplacementIndirectIndexed16(void)
699 {
700 amFlag = 0;
701 amOut = MemRead32(PC + (INT16)OpRead16(modAdd+2));
702 bamOffset = v60.reg[modVal&0x1F];
703
704 return 4;
705 }
706
707
am2PCDisplacementIndirectIndexed32(void)708 static UINT32 am2PCDisplacementIndirectIndexed32(void)
709 {
710 amFlag = 0;
711
712 switch (modDim)
713 {
714 case 0:
715 amOut = MemRead32(PC + OpRead32(modAdd+2)) + v60.reg[modVal&0x1F];
716 break;
717 case 1:
718 amOut = MemRead32(PC + OpRead32(modAdd+2)) + v60.reg[modVal&0x1F] * 2;
719 break;
720 case 2:
721 amOut = MemRead32(PC + OpRead32(modAdd+2)) + v60.reg[modVal&0x1F] * 4;
722 break;
723 case 3:
724 amOut = MemRead32(PC + OpRead32(modAdd+2)) + v60.reg[modVal&0x1F] * 8;
725 break;
726 }
727
728 return 6;
729 }
730
bam2PCDisplacementIndirectIndexed32(void)731 static UINT32 bam2PCDisplacementIndirectIndexed32(void)
732 {
733 amFlag = 0;
734 amOut = MemRead32(PC + OpRead32(modAdd+2));
735 bamOffset = v60.reg[modVal&0x1F];
736
737 return 6;
738 }
739
am2DoubleDisplacement8(void)740 static UINT32 am2DoubleDisplacement8(void)
741 {
742 amFlag = 0;
743 amOut = MemRead32(v60.reg[modVal&0x1F] + (INT8)OpRead8(modAdd+1)) + (INT8)OpRead8(modAdd+2);
744
745 return 3;
746 }
747
bam2DoubleDisplacement8(void)748 static UINT32 bam2DoubleDisplacement8(void)
749 {
750 amFlag = 0;
751 amOut = MemRead32(v60.reg[modVal&0x1F] + (INT8)OpRead8(modAdd+1));
752 bamOffset = (INT8)OpRead8(modAdd+2);
753
754 return 3;
755 }
756
am2DoubleDisplacement16(void)757 static UINT32 am2DoubleDisplacement16(void)
758 {
759 amFlag = 0;
760 amOut = MemRead32(v60.reg[modVal&0x1F] + (INT16)OpRead16(modAdd+1)) + (INT16)OpRead16(modAdd+3);
761
762 return 5;
763 }
764
bam2DoubleDisplacement16(void)765 static UINT32 bam2DoubleDisplacement16(void)
766 {
767 amFlag = 0;
768 amOut = MemRead32(v60.reg[modVal&0x1F] + (INT16)OpRead16(modAdd+1));
769 bamOffset = (INT8)OpRead8(modAdd+3);
770
771 return 5;
772 }
773
am2DoubleDisplacement32(void)774 static UINT32 am2DoubleDisplacement32(void)
775 {
776 amFlag = 0;
777 amOut = MemRead32(v60.reg[modVal&0x1F] + OpRead32(modAdd+1)) + OpRead32(modAdd+5);
778
779 return 9;
780 }
781
bam2DoubleDisplacement32(void)782 static UINT32 bam2DoubleDisplacement32(void)
783 {
784 amFlag = 0;
785 amOut = MemRead32(v60.reg[modVal&0x1F] + OpRead32(modAdd+1));
786 bamOffset = OpRead32(modAdd+5);
787
788 return 9;
789 }
790
791
am2PCDoubleDisplacement8(void)792 static UINT32 am2PCDoubleDisplacement8(void)
793 {
794 amFlag = 0;
795 amOut = MemRead32(PC + (INT8)OpRead8(modAdd+1)) + (INT8)OpRead8(modAdd+2);
796
797 return 3;
798 }
799
bam2PCDoubleDisplacement8(void)800 static UINT32 bam2PCDoubleDisplacement8(void)
801 {
802 amFlag = 0;
803 amOut = MemRead32(PC + (INT8)OpRead8(modAdd+1));
804 bamOffset = (INT8)OpRead8(modAdd+2);
805
806 return 3;
807 }
808
am2PCDoubleDisplacement16(void)809 static UINT32 am2PCDoubleDisplacement16(void)
810 {
811 amFlag = 0;
812 amOut = MemRead32(PC + (INT16)OpRead16(modAdd+1)) + (INT16)OpRead16(modAdd+3);
813
814 return 5;
815 }
816
bam2PCDoubleDisplacement16(void)817 static UINT32 bam2PCDoubleDisplacement16(void)
818 {
819 amFlag = 0;
820 amOut = MemRead32(PC + (INT16)OpRead16(modAdd+1));
821 bamOffset = (INT8)OpRead8(modAdd+3);
822
823 return 5;
824 }
825
am2PCDoubleDisplacement32(void)826 static UINT32 am2PCDoubleDisplacement32(void)
827 {
828 amFlag = 0;
829 amOut = MemRead32(PC + OpRead32(modAdd+1)) + OpRead32(modAdd+5);
830
831 return 9;
832 }
833
bam2PCDoubleDisplacement32(void)834 static UINT32 bam2PCDoubleDisplacement32(void)
835 {
836 amFlag = 0;
837 amOut = MemRead32(PC + OpRead32(modAdd+1));
838 bamOffset = OpRead32(modAdd+5);
839
840 return 9;
841 }
842
am2DirectAddress(void)843 static UINT32 am2DirectAddress(void)
844 {
845 amFlag = 0;
846 amOut = OpRead32(modAdd+1);
847
848 return 5;
849 }
850
bam2DirectAddress(void)851 static UINT32 bam2DirectAddress(void)
852 {
853 amFlag = 0;
854 amOut = OpRead32(modAdd+1);
855 bamOffset = 0;
856
857 return 5;
858 }
859
am2DirectAddressIndexed(void)860 static UINT32 am2DirectAddressIndexed(void)
861 {
862 amFlag = 0;
863
864 switch (modDim)
865 {
866 case 0:
867 amOut = OpRead32(modAdd+2) + v60.reg[modVal&0x1F];
868 break;
869 case 1:
870 amOut = OpRead32(modAdd+2) + v60.reg[modVal&0x1F] * 2;
871 break;
872 case 2:
873 amOut = OpRead32(modAdd+2) + v60.reg[modVal&0x1F] * 4;
874 break;
875 case 3:
876 amOut = OpRead32(modAdd+2) + v60.reg[modVal&0x1F] * 8;
877 break;
878 }
879
880 return 6;
881 }
882
bam2DirectAddressIndexed(void)883 static UINT32 bam2DirectAddressIndexed(void)
884 {
885 amFlag = 0;
886 amOut = OpRead32(modAdd+2);
887 bamOffset = v60.reg[modVal&0x1F];
888
889 return 6;
890 }
891
am2DirectAddressDeferred(void)892 static UINT32 am2DirectAddressDeferred(void)
893 {
894 amFlag = 0;
895 amOut = MemRead32(OpRead32(modAdd+1));
896
897 return 5;
898 }
899
bam2DirectAddressDeferred(void)900 static UINT32 bam2DirectAddressDeferred(void)
901 {
902 amFlag = 0;
903 amOut = MemRead32(OpRead32(modAdd+1));
904 bamOffset = 0;
905
906 return 5;
907 }
908
am2DirectAddressDeferredIndexed(void)909 static UINT32 am2DirectAddressDeferredIndexed(void)
910 {
911 amFlag = 0;
912
913 switch (modDim)
914 {
915 case 0:
916 amOut = MemRead32(OpRead32(modAdd+2)) + v60.reg[modVal&0x1F];
917 break;
918 case 1:
919 amOut = MemRead32(OpRead32(modAdd+2)) + v60.reg[modVal&0x1F] * 2;
920 break;
921 case 2:
922 amOut = MemRead32(OpRead32(modAdd+2)) + v60.reg[modVal&0x1F] * 4;
923 break;
924 case 3:
925 amOut = MemRead32(OpRead32(modAdd+2)) + v60.reg[modVal&0x1F] * 8;
926 break;
927 }
928
929 return 6;
930 }
931
bam2DirectAddressDeferredIndexed(void)932 static UINT32 bam2DirectAddressDeferredIndexed(void)
933 {
934 amFlag = 0;
935 amOut = MemRead32(OpRead32(modAdd+2));
936 bamOffset = v60.reg[modVal&0x1F];
937
938 return 6;
939 }
940
am2Immediate(void)941 static UINT32 am2Immediate(void)
942 {
943 // Fuck off LDPR
944 return am1Immediate();
945 }
946
am2ImmediateQuick(void)947 static UINT32 am2ImmediateQuick(void)
948 {
949 // fuck off LDPR
950 return am1ImmediateQuick();
951 }
952
953
954 // AM2 Tables (for ReadAMAddress)
955 // ******************************
956
am2Error1(void)957 static UINT32 am2Error1(void)
958 {
959 //fatalerror("CPU - AM2 - 1 (PC=%06x)", PC);
960 return 0; /* never reached, fatalerror won't return */
961 }
962
am2Error2(void)963 static UINT32 am2Error2(void)
964 {
965 //fatalerror("CPU - AM2 - 2 (PC=%06x)", PC);
966 return 0; /* never reached, fatalerror won't return */
967 }
968
969 #if 0
970 static UINT32 am2Error3(void)
971 {
972 //fatalerror("CPU - AM2 - 3 (PC=%06x)", PC);
973 return 0; /* never reached, fatalerror won't return */
974 }
975 #endif
976
am2Error4(void)977 static UINT32 am2Error4(void)
978 {
979 //fatalerror("CPU - AM2 - 4 (PC=%06x)", PC);
980 return 0; /* never reached, fatalerror won't return */
981 }
982
am2Error5(void)983 static UINT32 am2Error5(void)
984 {
985 //fatalerror("CPU - AM2 - 5 (PC=%06x)", PC);
986 return 0; /* never reached, fatalerror won't return */
987 }
988
bam2Error1(void)989 static UINT32 bam2Error1(void)
990 {
991 //fatalerror("CPU - BAM2 - 1 (PC=%06x)", PC);
992 return 0; /* never reached, fatalerror won't return */
993 }
994
bam2Error2(void)995 static UINT32 bam2Error2(void)
996 {
997 //fatalerror("CPU - BAM2 - 2 (PC=%06x)", PC);
998 return 0; /* never reached, fatalerror won't return */
999 }
1000
1001 #if 0
1002 static UINT32 bam2Error3(void)
1003 {
1004 //fatalerror("CPU - BAM2 - 3 (PC=%06x)", PC);
1005 return 0; /* never reached, fatalerror won't return */
1006 }
1007 #endif
1008
bam2Error4(void)1009 static UINT32 bam2Error4(void)
1010 {
1011 //fatalerror("CPU - BAM2 - 4 (PC=%06x)", PC);
1012 return 0; /* never reached, fatalerror won't return */
1013 }
1014
bam2Error5(void)1015 static UINT32 bam2Error5(void)
1016 {
1017 //fatalerror("CPU - BAM2 - 5 (PC=%06x)", PC);
1018 return 0; /* never reached, fatalerror won't return */
1019 }
1020
bam2Error6(void)1021 static UINT32 bam2Error6(void)
1022 {
1023 //fatalerror("CPU - BAM2 - 6 (PC=%06x)", PC);
1024 return 0; /* never reached, fatalerror won't return */
1025 }
1026
1027
1028 static UINT32 (*const AMTable2_G7a[16])(void) =
1029 {
1030 am2PCDisplacementIndexed8,
1031 am2PCDisplacementIndexed16,
1032 am2PCDisplacementIndexed32,
1033 am2DirectAddressIndexed,
1034 am2Error5,
1035 am2Error5,
1036 am2Error5,
1037 am2Error5,
1038 am2PCDisplacementIndirectIndexed8,
1039 am2PCDisplacementIndirectIndexed16,
1040 am2PCDisplacementIndirectIndexed32,
1041 am2DirectAddressDeferredIndexed,
1042 am2Error5,
1043 am2Error5,
1044 am2Error5,
1045 am2Error5
1046 };
1047
1048 static UINT32 (*const BAMTable2_G7a[16])(void) =
1049 {
1050 bam2PCDisplacementIndexed8,
1051 bam2PCDisplacementIndexed16,
1052 bam2PCDisplacementIndexed32,
1053 bam2DirectAddressIndexed,
1054 bam2Error5,
1055 bam2Error5,
1056 bam2Error5,
1057 bam2Error5,
1058 bam2PCDisplacementIndirectIndexed8,
1059 bam2PCDisplacementIndirectIndexed16,
1060 bam2PCDisplacementIndirectIndexed32,
1061 bam2DirectAddressDeferredIndexed,
1062 bam2Error5,
1063 bam2Error5,
1064 bam2Error5,
1065 bam2Error5
1066 };
1067
am2Group7a(void)1068 static UINT32 am2Group7a(void)
1069 {
1070 if (!(modVal2&0x10))
1071 return am2Error4();
1072
1073 return AMTable2_G7a[modVal2&0xF]();
1074 }
1075
bam2Group7a(void)1076 static UINT32 bam2Group7a(void)
1077 {
1078 if (!(modVal2&0x10))
1079 return bam2Error4();
1080
1081 return BAMTable2_G7a[modVal2&0xF]();
1082 }
1083
1084 static UINT32 (*const AMTable2_G7[32])(void) =
1085 {
1086 am2ImmediateQuick,
1087 am2ImmediateQuick,
1088 am2ImmediateQuick,
1089 am2ImmediateQuick,
1090 am2ImmediateQuick,
1091 am2ImmediateQuick,
1092 am2ImmediateQuick,
1093 am2ImmediateQuick,
1094 am2ImmediateQuick,
1095 am2ImmediateQuick,
1096 am2ImmediateQuick,
1097 am2ImmediateQuick,
1098 am2ImmediateQuick,
1099 am2ImmediateQuick,
1100 am2ImmediateQuick,
1101 am2ImmediateQuick,
1102 am2PCDisplacement8,
1103 am2PCDisplacement16,
1104 am2PCDisplacement32,
1105 am2DirectAddress,
1106 am2Immediate,
1107 am2Error2,
1108 am2Error2,
1109 am2Error2,
1110 am2PCDisplacementIndirect8,
1111 am2PCDisplacementIndirect16,
1112 am2PCDisplacementIndirect32,
1113 am2DirectAddressDeferred,
1114 am2PCDoubleDisplacement8,
1115 am2PCDoubleDisplacement16,
1116 am2PCDoubleDisplacement32,
1117 am2Error2
1118 };
1119
1120 static UINT32 (*const BAMTable2_G7[32])(void) =
1121 {
1122 bam2Error6,
1123 bam2Error6,
1124 bam2Error6,
1125 bam2Error6,
1126 bam2Error6,
1127 bam2Error6,
1128 bam2Error6,
1129 bam2Error6,
1130 bam2Error6,
1131 bam2Error6,
1132 bam2Error6,
1133 bam2Error6,
1134 bam2Error6,
1135 bam2Error6,
1136 bam2Error6,
1137 bam2Error6,
1138 bam2PCDisplacement8,
1139 bam2PCDisplacement16,
1140 bam2PCDisplacement32,
1141 bam2DirectAddress,
1142 bam2Error6,
1143 bam2Error2,
1144 bam2Error2,
1145 bam2Error2,
1146 bam2PCDisplacementIndirect8,
1147 bam2PCDisplacementIndirect16,
1148 bam2PCDisplacementIndirect32,
1149 bam2DirectAddressDeferred,
1150 bam2PCDoubleDisplacement8,
1151 bam2PCDoubleDisplacement16,
1152 bam2PCDoubleDisplacement32,
1153 bam2Error2
1154 };
1155
1156 static UINT32 (*const AMTable2_G6[8])(void) =
1157 {
1158 am2DisplacementIndexed8,
1159 am2DisplacementIndexed16,
1160 am2DisplacementIndexed32,
1161 am2RegisterIndirectIndexed,
1162 am2DisplacementIndirectIndexed8,
1163 am2DisplacementIndirectIndexed16,
1164 am2DisplacementIndirectIndexed32,
1165 am2Group7a
1166 };
1167
1168 static UINT32 (*const BAMTable2_G6[8])(void) =
1169 {
1170 bam2DisplacementIndexed8,
1171 bam2DisplacementIndexed16,
1172 bam2DisplacementIndexed32,
1173 bam2RegisterIndirectIndexed,
1174 bam2DisplacementIndirectIndexed8,
1175 bam2DisplacementIndirectIndexed16,
1176 bam2DisplacementIndirectIndexed32,
1177 bam2Group7a
1178 };
1179
1180
1181
1182
am2Group6(void)1183 static UINT32 am2Group6(void)
1184 {
1185 modVal2=OpRead8(modAdd+1);
1186 return AMTable2_G6[modVal2>>5]();
1187 }
bam2Group6(void)1188 static UINT32 bam2Group6(void)
1189 {
1190 modVal2=OpRead8(modAdd+1);
1191 return BAMTable2_G6[modVal2>>5]();
1192 }
1193
am2Group7(void)1194 static UINT32 am2Group7(void)
1195 {
1196 return AMTable2_G7[modVal&0x1F]();
1197 }
bam2Group7(void)1198 static UINT32 bam2Group7(void)
1199 {
1200 return BAMTable2_G7[modVal&0x1F]();
1201 }
1202
1203
1204 static UINT32 (*const AMTable2[2][8])(void) =
1205 {
1206 {
1207 am2Displacement8,
1208 am2Displacement16,
1209 am2Displacement32,
1210 am2RegisterIndirect,
1211 am2DisplacementIndirect8,
1212 am2DisplacementIndirect16,
1213 am2DisplacementIndirect32,
1214 am2Group7
1215 },
1216
1217 {
1218 am2DoubleDisplacement8,
1219 am2DoubleDisplacement16,
1220 am2DoubleDisplacement32,
1221 am2Register,
1222 am2Autoincrement,
1223 am2Autodecrement,
1224 am2Group6,
1225 am2Error1
1226 }
1227 };
1228
1229 static UINT32 (*const BAMTable2[2][8])(void) =
1230 {
1231 {
1232 bam2Displacement8,
1233 bam2Displacement16,
1234 bam2Displacement32,
1235 bam2RegisterIndirect,
1236 bam2DisplacementIndirect8,
1237 bam2DisplacementIndirect16,
1238 bam2DisplacementIndirect32,
1239 bam2Group7
1240 },
1241
1242 {
1243 bam2DoubleDisplacement8,
1244 bam2DoubleDisplacement16,
1245 bam2DoubleDisplacement32,
1246 bam2Error6,
1247 bam2Autoincrement,
1248 bam2Autodecrement,
1249 bam2Group6,
1250 bam2Error1
1251 }
1252 };
1253
1254
1255
1256
1257