summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/cpu/cp1610/cp1610.c
blob: d6bef729de06c63d75a81b2d0760b79755ffd56d (plain) (blame)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
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
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
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
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
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
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
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
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
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
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
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
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
/*****************************************************************************
 *
 *   cp1610.c
 *   Portable CP1610 emulator (General Instrument CP1610)
 *
 *   Copyright Frank Palazzolo, all rights reserved.
 *
 *   - This source code is released as freeware for non-commercial purposes.
 *   - You are free to use and redistribute this code in modified or
 *     unmodified form, provided you list me in the credits.
 *   - If you modify this source code, you must add a notice to each modified
 *     source file that it has been changed.  If you're a nice person, you
 *     will clearly mark each change too.  :)
 *   - If you wish to use this for commercial purposes, please contact me at
 *     palazzol@comcast.net
 *   - This entire notice must remain in the source code.
 *
 *  This work is based on Juergen Buchmueller's F8 emulation,
 *  and the 'General Instruments CP1610' data sheets.
 *  Special thanks to Joe Zbiciak for his GPL'd CP1610 emulator
 *
 *****************************************************************************/

#include "emu.h"
#include "debugger.h"
#include "cp1610.h"

#define S  0x80
#define Z  0x40
#define OV 0x20
#define C  0x10

typedef struct _cp1610_state cp1610_state;
struct _cp1610_state
{
	UINT16	r[8];	/* registers */
	UINT8	flags;	/* flags */
	int 	intr_enabled;
	//int       (*reset_callback)(cp1610_state *cpustate);
	cpu_irq_callback irq_callback;
	UINT16	intr_vector;
	int 	reset_state;
	int		intr_state;
	int		intrm_state;
	int 	reset_pending;
	int		intr_pending;
	int		intrm_pending;
	int		mask_interrupts;
	running_device *device;
	const address_space *program;
	int icount;
};

INLINE cp1610_state *get_safe_token(running_device *device)
{
	assert(device != NULL);
	assert(device->token != NULL);
	assert(device->type == CPU);
	assert(cpu_get_type(device) == CPU_CP1610);
	return (cp1610_state *)device->token;
}

#define cp1610_readop(A) memory_read_word_16be(cpustate->program, (A)<<1)
#define cp1610_readmem16(A) memory_read_word_16be(cpustate->program, (A)<<1)
#define cp1610_writemem16(A,B) memory_write_word_16be(cpustate->program, (A)<<1,B)

/* clear all flags */
#define CLR_SZOC                \
	cpustate->flags &= ~(S|Z|C|OV)

/* clear sign and zero flags */
#define CLR_SZ              	\
	cpustate->flags &= ~(S|Z)

/* clear sign,zero, and carry flags */
#define CLR_SZC             	\
	cpustate->flags &= ~(S|Z|C)

/* set sign and zero flags */
#define SET_SZ(n)               \
	if (n == 0) 				\
		cpustate->flags |= Z;		\
	else						\
	if (n & 0x8000)				\
		cpustate->flags |= S

/* set sign zero, and carry flags */
#define SET_SZC(n,m)            \
	if (n == 0) 				\
		cpustate->flags |= Z;		\
	else						\
	if (n & 0x8000)				\
		cpustate->flags |= S;		\
	if ((n + m) & 0x10000)		\
		cpustate->flags |= C

/* set carry and overflow flags */
#define SET_COV(n,m,qq)         \
  { unsigned int pp = n + m;	\
	if (pp & 0x10000)			\
		cpustate->flags |= C;		\
	if (qq)						\
	{							\
		if ((n^pp)&(~(m^n))&0x8000)	\
			cpustate->flags |= OV; \
		if (m == 0x8000)		\
			cpustate->flags ^= OV;	\
	}							\
	else						\
	{							\
		if ((n^pp)&(~(m^n))&0x8000)	\
			cpustate->flags |= OV;		\
	}							\
  }

#if 0
#define SET_COV(n,m)         \
	if ((n&0x7fff)+(m&0x7fff) > 0x7fff)	\
	{							\
		if (!(cpustate->flags & C))\
			cpustate->flags |= OV;	\
	}							\
	else						\
	{							\
		if (cpustate->flags & C)	\
			cpustate->flags |= OV;	\
	}
#endif

/***********************************
 *  illegal opcodes
 ***********************************/
static void cp1610_illegal(cp1610_state *cpustate)
{
	logerror("cp1610 illegal opcode at 0x%04x\n", cpustate->r[7]);
}

/***************************************************
 *  S Z C OV 0 000 000 000
 *  - - - -  HLT
 ***************************************************/
static void cp1610_hlt(cp1610_state *cpustate)
{
	/* TBD */
	cpustate->icount -= 4;
}

/***************************************************
 *  S Z C OV 0 000 000 010
 *  - - - -  EIS
 ***************************************************/
static void cp1610_eis(cp1610_state *cpustate)
{
	cpustate->mask_interrupts = 1;
	cpustate->intr_enabled = 1;
	cpustate->icount -= 4;
}

/***************************************************
 *  S Z C OV 0 000 000 011
 *  - - - -  DIS
 ***************************************************/
static void cp1610_dis(cp1610_state *cpustate)
{
	cpustate->mask_interrupts = 1;
	cpustate->intr_enabled = 0;
	cpustate->icount -= 4;
}

/***************************************************
 *  S Z C OV 0 000 000 101
 *  - - - -  TCI
 ***************************************************/
static void cp1610_tci(cp1610_state *cpustate)
{
	/* TBD */
	cpustate->mask_interrupts = 1;
	cpustate->icount -= 4;
}

/***************************************************
 *  S Z C OV 0 000 000 110
 *  - - 0 -  CLRC
 ***************************************************/
static void cp1610_clrc(cp1610_state *cpustate)
{
	cpustate->mask_interrupts = 1;
	cpustate->flags &= ~C;
	cpustate->icount -= 4;
}

/***************************************************
 *  S Z C OV 0 000 000 111
 *  - - 1 -  SETC
 ***************************************************/
static void cp1610_setc(cp1610_state *cpustate)
{
	cpustate->mask_interrupts = 1;
	cpustate->flags |= C;
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 000 001 ddd
 *  x x - -  INCR  Rd
 ***************************************************/
static void cp1610_incr(cp1610_state *cpustate, int n)
{
	cpustate->r[n]++;
	CLR_SZ;
	SET_SZ(cpustate->r[n]);
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 000 010 ddd
 *  x x - -  DECR  Rd
 ***************************************************/
static void cp1610_decr(cp1610_state *cpustate, int n)
{
	cpustate->r[n]--;
	CLR_SZ;
	SET_SZ(cpustate->r[n]);
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 000 011 ddd
 *  x x - -  COMR  Rd
 ***************************************************/
static void cp1610_comr(cp1610_state *cpustate, int n)
{
	cpustate->r[n] ^= 0xffff;
	CLR_SZ;
	SET_SZ(cpustate->r[n]);
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 000 100 ddd
 *  x x x x  NEGR  Rd
 ***************************************************/
static void cp1610_negr(cp1610_state *cpustate, int n)
{
	UINT32 temp;
	CLR_SZOC;
	temp = (cpustate->r[n] ^ 0xffff) + 1;
	SET_COV(0,temp,1);
	cpustate->r[n] = temp&0xffff;
	SET_SZ(cpustate->r[n]);
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 000 101 ddd
 *  x x x x  ADCR  Rd
 ***************************************************/
static void cp1610_adcr(cp1610_state *cpustate, int n)
{
	UINT16 offset = 0;
	if (cpustate->flags & C)
		offset = 1;
	CLR_SZOC;
	SET_COV(cpustate->r[n],offset,0);
	cpustate->r[n] += offset;
	SET_SZ(cpustate->r[n]);
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 000 110 0dd
 *  - - - -  GSWD  Rd
 ***************************************************/
static void cp1610_gswd(cp1610_state *cpustate, int n)
{
	cpustate->r[n] = (cpustate->flags << 8) + cpustate->flags;
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 000 110 10x
 *  - - - -  NOP
 ***************************************************/
static void cp1610_nop(cp1610_state *cpustate)
{
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 000 110 11x
 *  - - - -  SIN
 ***************************************************/
static void cp1610_sin(cp1610_state *cpustate)
{
	/* TBD */
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 000 111 sss
 *  x x x x  RSWD Rs
 ***************************************************/
static void cp1610_rswd(cp1610_state *cpustate, int n)
{
	cpustate->flags = cpustate->r[n];
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 001 000 0rr
 *  x x - -  SWAP Rr,1
 ***************************************************/
static void cp1610_swap(cp1610_state *cpustate, int r)
{
	UINT8 temp;
	cpustate->mask_interrupts = 1;
	CLR_SZ;
	temp = cpustate->r[r] >> 8;
	cpustate->r[r] = (cpustate->r[r] << 8) | temp;
	SET_SZ(cpustate->r[r]);
	/* S flag is set on bit 7 not bit 15 */
	cpustate->flags &= ~S;
	if (cpustate->r[r] & 0x80)
		cpustate->flags |= S;
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 001 000 1rr
 *  x x - -  SWAP Rr,2
 ***************************************************/
static void cp1610_dswap(cp1610_state *cpustate, int r)
{
	/* This instruction was not officially supported by GI */
	UINT16 temp;
	cpustate->mask_interrupts = 1;
	CLR_SZ;
	temp = cpustate->r[r] & 0xff;
	cpustate->r[r] = (temp << 8) | temp;
	SET_SZ(cpustate->r[r]);
	/* S flag is set on bit 7 not bit 15 */
	cpustate->flags &= ~S;
	if (cpustate->r[r] & 0x80)
		cpustate->flags |= S;
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 0 001 001 0rr
 *  x x - -  SLL Rr,1
 ***************************************************/
static void cp1610_sll_1(cp1610_state *cpustate, int r)
{
	cpustate->mask_interrupts = 1;
	CLR_SZ;
	cpustate->r[r] <<= 1;
	SET_SZ(cpustate->r[r]);
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 001 001 1rr
 *  x x - -  SLL Rr,2
 ***************************************************/
static void cp1610_sll_2(cp1610_state *cpustate, int r)
{
	cpustate->mask_interrupts = 1;
	CLR_SZ;
	cpustate->r[r] <<= 2;
	SET_SZ(cpustate->r[r]);
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 0 001 010 0rr
 *  x x x -  RLC Rr,1
 ***************************************************/
static void cp1610_rlc_1(cp1610_state *cpustate, int r)
{
	UINT16 offset = 0;
	cpustate->mask_interrupts = 1;
	if (cpustate->flags & C)
		offset = 1;
	CLR_SZC;
	if (cpustate->r[r] & 0x8000)
		cpustate->flags |= C;
	cpustate->r[r] = (cpustate->r[r] << 1) + offset;
	SET_SZ(cpustate->r[r]);
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 001 010 1rr
 *  x x x x  RLC Rr,2
 ***************************************************/
static void cp1610_rlc_2(cp1610_state *cpustate, int r)
{
	UINT16 offset = 0;
	cpustate->mask_interrupts = 1;
	switch(cpustate->flags & (C | OV))
	{
		case 0:
			offset = 0;
		break;
		case OV:
			offset = 1;
		break;
		case C:
			offset = 2;
		break;
		case (C | OV):
			offset = 3;
		break;
	}

	CLR_SZOC;
	if (cpustate->r[r] & 0x8000)
		cpustate->flags |= C;
	if (cpustate->r[r] & 0x4000)
		cpustate->flags |= OV;
	cpustate->r[r] <<= 2;
	cpustate->r[r] += offset;
	SET_SZ(cpustate->r[r]);
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 0 001 011 0rr
 *  x x x -  SLLC Rr,1
 ***************************************************/
static void cp1610_sllc_1(cp1610_state *cpustate, int r)
{
	cpustate->mask_interrupts = 1;
	CLR_SZC;
	if (cpustate->r[r] & 0x8000)
		cpustate->flags |= C;
	cpustate->r[r] <<= 1;
	SET_SZ(cpustate->r[r]);
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 001 011 1rr
 *  x x x x  SLLC Rr,2
 ***************************************************/
static void cp1610_sllc_2(cp1610_state *cpustate, int r)
{
	cpustate->mask_interrupts = 1;
	CLR_SZOC;
	if (cpustate->r[r] & 0x8000)
		cpustate->flags |= C;
	if (cpustate->r[r] & 0x4000)
		cpustate->flags |= OV;
	cpustate->r[r] <<= 2;
	SET_SZ(cpustate->r[r]);
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 0 001 100 0rr
 *  x x - -  SLR Rr,1
 ***************************************************/
static void cp1610_slr_1(cp1610_state *cpustate, int r)
{
	cpustate->mask_interrupts = 1;
	CLR_SZ;
	cpustate->r[r] >>= 1;
	SET_SZ(cpustate->r[r]);
	/* S flag is set on bit 7 not bit 15 */
	cpustate->flags &= ~S;
	if (cpustate->r[r] & 0x80)
		cpustate->flags |= S;
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 001 100 1rr
 *  x x - -  SLR Rr,2
 ***************************************************/
static void cp1610_slr_2(cp1610_state *cpustate, int r)
{
	cpustate->mask_interrupts = 1;
	CLR_SZ;
	cpustate->r[r] >>= 2;
	SET_SZ(cpustate->r[r]);
	/* S flag is set on bit 7 not bit 15 */
	cpustate->flags &= ~S;
	if (cpustate->r[r] & 0x80)
		cpustate->flags |= S;
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 0 001 101 0rr
 *  x x - -  SAR Rr,1
 ***************************************************/
static void cp1610_sar_1(cp1610_state *cpustate, int r)
{
	cpustate->mask_interrupts = 1;
	CLR_SZ;
	cpustate->r[r] = (UINT16)(((INT16)(cpustate->r[r])) >> 1);
	SET_SZ(cpustate->r[r]);
	/* S flag is set on bit 7 not bit 15 */
	cpustate->flags &= ~S;
	if (cpustate->r[r] & 0x80)
		cpustate->flags |= S;
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 001 101 1rr
 *  x x - -  SAR Rr,2
 ***************************************************/
static void cp1610_sar_2(cp1610_state *cpustate, int r)
{
	cpustate->mask_interrupts = 1;
	CLR_SZ;
	cpustate->r[r] = (UINT16)(((INT16)(cpustate->r[r])) >> 2);
	SET_SZ(cpustate->r[r]);
	/* S flag is set on bit 7 not bit 15 */
	cpustate->flags &= ~S;
	if (cpustate->r[r] & 0x80)
		cpustate->flags |= S;
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 0 001 110 0rr
 *  x x x -  RRC Rr,1
 ***************************************************/
static void cp1610_rrc_1(cp1610_state *cpustate, int r)
{
	UINT16 offset = 0;
	cpustate->mask_interrupts = 1;
	if (cpustate->flags & C)
		offset = 0x8000;
	CLR_SZC;
	if (cpustate->r[r] & 1)
		cpustate->flags |= C;
	cpustate->r[r] >>= 1;
	cpustate->r[r] += offset;
	SET_SZ(cpustate->r[r]);
	/* S flag is set on bit 7 not bit 15 */
	cpustate->flags &= ~S;
	if (cpustate->r[r] & 0x80)
		cpustate->flags |= S;
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 001 110 1rr
 *  x x x x  RRC Rr,2
 ***************************************************/
static void cp1610_rrc_2(cp1610_state *cpustate, int r)
{
	UINT16 offset = 0;
	cpustate->mask_interrupts = 1;
	if (cpustate->flags & C)
		offset |= 0x4000;
	if (cpustate->flags & OV)
		offset |= 0x8000;
	CLR_SZOC;
	if (cpustate->r[r] & 1)
		cpustate->flags |= C;
	if (cpustate->r[r] & 2)
		cpustate->flags |= OV;
	cpustate->r[r] >>= 2;
	cpustate->r[r] += offset;
	SET_SZ(cpustate->r[r]);
	/* S flag is set on bit 7 not bit 15 */
	cpustate->flags &= ~S;
	if (cpustate->r[r] & 0x80)
		cpustate->flags |= S;
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 0 001 111 0rr
 *  x x x -  SARC Rr,1
 ***************************************************/
static void cp1610_sarc_1(cp1610_state *cpustate, int r)
{
	cpustate->mask_interrupts = 1;
	CLR_SZC;
	if (cpustate->r[r] & 1)
		cpustate->flags |= C;
	cpustate->r[r] = (UINT16)(((INT16)cpustate->r[r]) >> 1);
	SET_SZ(cpustate->r[r]);
	/* S flag is set on bit 7 not bit 15 */
	cpustate->flags &= ~S;
	if (cpustate->r[r] & 0x80)
		cpustate->flags |= S;
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 001 111 1rr
 *  x x x x  SARC Rr,2
 ***************************************************/
static void cp1610_sarc_2(cp1610_state *cpustate, int r)
{
	cpustate->mask_interrupts = 1;
	CLR_SZOC;
	if (cpustate->r[r] & 1)
		cpustate->flags |= C;
	if (cpustate->r[r] & 2)
		cpustate->flags |= OV;
	cpustate->r[r] = (UINT16)(((INT16)cpustate->r[r]) >> 2);
	SET_SZ(cpustate->r[r]);
	/* S flag is set on bit 7 not bit 15 */
	cpustate->flags &= ~S;
	if (cpustate->r[r] & 0x80)
		cpustate->flags |= S;
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 010 sss sss
 *  x x - -  TSTR Rs
 ***************************************************/
static void cp1610_tstr(cp1610_state *cpustate, int n)
{
	CLR_SZ;
	SET_SZ(cpustate->r[n]);
	cpustate->icount -= 6;
	if (n > 5)
		cpustate->icount -= 1;
}

/***************************************************
 *  S Z C OV 0 010 sss ddd      (sss != ddd)
 *  x x - -  MOVR Rs,Rd
 ***************************************************/
static void cp1610_movr(cp1610_state *cpustate, int s, int d)
{
	CLR_SZ;
	cpustate->r[d] = cpustate->r[s];
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 6;
	if (d > 5)
		cpustate->icount -= 1;
}

/***************************************************
 *  S Z C OV 0 011 sss ddd
 *  x x x x  ADDR Rs, Rd
 ***************************************************/
static void cp1610_addr(cp1610_state *cpustate, int s, int d)
{
	CLR_SZOC;
	SET_COV(cpustate->r[s],cpustate->r[d],0);
	cpustate->r[d] += cpustate->r[s];
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 100 sss ddd
 *  x x x x  SUBR Rs, Rd
 ***************************************************/
static void cp1610_subr(cp1610_state *cpustate, int s, int d)
{
	CLR_SZOC;
	SET_COV(cpustate->r[d],(UINT32)((cpustate->r[s]^0xffff)+1),1);
	cpustate->r[d] -= cpustate->r[s];
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 101 sss ddd
 *  x x x x  CMPR Rs, Rd
 ***************************************************/
static void cp1610_cmpr(cp1610_state *cpustate, int s, int d)
{
	UINT16 temp;
	CLR_SZOC;
	SET_COV(cpustate->r[d],(UINT32)((cpustate->r[s]^0xffff)+1),1);
	temp = cpustate->r[d] - cpustate->r[s];
	SET_SZ(temp);
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 110 sss ddd
 *  x x - -  ANDR Rs, Rd
 ***************************************************/
static void cp1610_andr(cp1610_state *cpustate, int s, int d)
{
	CLR_SZ;
	cpustate->r[d] &= cpustate->r[s];
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 111 sss ddd  (sss != ddd)
 *  x x - -  XORR Rs, Rd
 ***************************************************/
static void cp1610_xorr(cp1610_state *cpustate, int s, int d)
{
	CLR_SZ;
	cpustate->r[d] ^= cpustate->r[s];
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 0 111 ddd ddd
 *  x x - -  CLRR Rd
 ***************************************************/
static void cp1610_clrr(cp1610_state *cpustate, int d)
{
	CLR_SZ;
	cpustate->r[d] = 0;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 6;
}

/***************************************************
 *  S Z C OV 1 000 s00 000 p ppp ppp ppp ppp ppp
 *  - - - -  B ADDR
 ***************************************************/
static void cp1610_b(cp1610_state *cpustate, int dir)
{
	UINT16 offset = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	cpustate->r[7] += (offset ^ dir);
	cpustate->icount -= 9;
}

/***************************************************
 *  S Z C OV 1 000 s01 000 p ppp ppp ppp ppp ppp
 *  - - - -  NOPP
 ***************************************************/
static void cp1610_nopp(cp1610_state *cpustate, int dir)
{
	cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	cpustate->icount -= 7;
}

/***************************************************
 *  S Z C OV 1 000 s00 001 p ppp ppp ppp ppp ppp
 *  - - - -  BC ADDR
 ***************************************************/
static void cp1610_bc(cp1610_state *cpustate, int dir)
{
	UINT16 offset = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	if (cpustate->flags & C)
	{
		cpustate->r[7] += (offset ^ dir);
		cpustate->icount -= 9;
	}
	else
	{
		cpustate->icount -= 7;
	}
}

/***************************************************
 *  S Z C OV 1 000 s01 001 p ppp ppp ppp ppp ppp
 *  - - - -  BNC ADDR
 ***************************************************/
static void cp1610_bnc(cp1610_state *cpustate, int dir)
{
	UINT16 offset = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	if (!(cpustate->flags & C))
	{
		cpustate->r[7] += (offset ^ dir);
		cpustate->icount -= 9;
	}
	else
	{
		cpustate->icount -= 7;
	}
}

/***************************************************
 *  S Z C OV 1 000 s00 010 p ppp ppp ppp ppp ppp
 *  - - - -  BOV ADDR
 ***************************************************/
static void cp1610_bov(cp1610_state *cpustate, int dir)
{
	UINT16 offset = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	if (cpustate->flags & OV)
	{
		cpustate->r[7] += (offset ^ dir);
		cpustate->icount -= 9;
	}
	else
	{
		cpustate->icount -= 7;
	}
}

/***************************************************
 *  S Z C OV 1 000 s01 010 p ppp ppp ppp ppp ppp
 *  - - - -  BNOV ADDR
 ***************************************************/
static void cp1610_bnov(cp1610_state *cpustate, int dir)
{
	UINT16 offset = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	if (!(cpustate->flags & OV))
	{
		cpustate->r[7] += (offset ^ dir);
		cpustate->icount -= 9;
	}
	else
	{
		cpustate->icount -= 7;
	}
}

/***************************************************
 *  S Z C OV 1 000 s00 011 p ppp ppp ppp ppp ppp
 *  - - - -  BPL ADDR
 ***************************************************/
static void cp1610_bpl(cp1610_state *cpustate, int dir)
{
	UINT16 offset = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	if (!(cpustate->flags & S))
	{
		cpustate->r[7] += (offset ^ dir);
		cpustate->icount -= 9;
	}
	else
	{
		cpustate->icount -= 7;
	}
}

/***************************************************
 *  S Z C OV 1 000 s01 011 p ppp ppp ppp ppp ppp
 *  - - - -  BMI ADDR
 ***************************************************/
static void cp1610_bmi(cp1610_state *cpustate, int dir)
{
	UINT16 offset = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	if (cpustate->flags & S)
	{
		cpustate->r[7] += (offset ^ dir);
		cpustate->icount -= 9;
	}
	else
	{
		cpustate->icount -= 7;
	}
}

/***************************************************
 *  S Z C OV 1 000 s00 100 p ppp ppp ppp ppp ppp
 *  - - - -  BZE ADDR
 ***************************************************/
static void cp1610_bze(cp1610_state *cpustate, int dir)
{
	UINT16 offset = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	if (cpustate->flags & Z)
	{
		cpustate->r[7] += (offset ^ dir);
		cpustate->icount -= 9;
	}
	else
	{
		cpustate->icount -= 7;
	}
}

/***************************************************
 *  S Z C OV 1 000 s01 100 p ppp ppp ppp ppp ppp
 *  - - - -  BNZE ADDR
 ***************************************************/
static void cp1610_bnze(cp1610_state *cpustate, int dir)
{
	UINT16 offset = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	if (!(cpustate->flags & Z))
	{
		cpustate->r[7] += (offset ^ dir);
		cpustate->icount -= 9;
	}
	else
	{
		cpustate->icount -= 7;
	}
}

/***************************************************
 *  S Z C OV 1 000 s00 101 p ppp ppp ppp ppp ppp
 *  - - - -  BLT ADDR
 ***************************************************/
static void cp1610_blt(cp1610_state *cpustate, int dir)
{
	int condition1 = 0;
	int condition2 = 0;
	UINT16 offset = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	if (cpustate->flags & S) condition1 = 1;
	if (cpustate->flags & OV) condition2 = 1;
	if (condition1 ^ condition2)
	{
		cpustate->r[7] += (offset ^ dir);
		cpustate->icount -= 9;
	}
	else
	{
		cpustate->icount -= 7;
	}
}

/***************************************************
 *  S Z C OV 1 000 s01 101 p ppp ppp ppp ppp ppp
 *  - - - -  BGE ADDR
 ***************************************************/
static void cp1610_bge(cp1610_state *cpustate, int dir)
{
	int condition1 = 0;
	int condition2 = 0;
	UINT16 offset = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	if (cpustate->flags & S) condition1 = 1;
	if (cpustate->flags & OV) condition2 = 1;
	if (!(condition1 ^ condition2))
	{
		cpustate->r[7] += (offset ^ dir);
		cpustate->icount -= 9;
	}
	else
	{
		cpustate->icount -= 7;
	}
}

/***************************************************
 *  S Z C OV 1 000 s00 110 p ppp ppp ppp ppp ppp
 *  - - - -  BLE ADDR
 ***************************************************/
static void cp1610_ble(cp1610_state *cpustate, int dir)
{
	int condition1 = 0;
	int condition2 = 0;
	UINT16 offset = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	if (cpustate->flags & S) condition1 = 1;
	if (cpustate->flags & OV) condition2 = 1;
	if ((cpustate->flags & Z) || (condition1 ^ condition2))
	{
		cpustate->r[7] += (offset ^ dir);
		cpustate->icount -= 9;
	}
	else
	{
		cpustate->icount -= 7;
	}
}

/***************************************************
 *  S Z C OV 1 000 s01 110 p ppp ppp ppp ppp ppp
 *  - - - -  BGT ADDR
 ***************************************************/
static void cp1610_bgt(cp1610_state *cpustate, int dir)
{
	int condition1 = 0;
	int condition2 = 0;
	UINT16 offset = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	if (cpustate->flags & S) condition1 = 1;
	if (cpustate->flags & OV) condition2 = 1;
	if (!((cpustate->flags & Z) || (condition1 ^ condition2)))
	{
		cpustate->r[7] += (offset ^ dir);
		cpustate->icount -= 9;
	}
	else
	{
		cpustate->icount -= 7;
	}
}

/***************************************************
 *  S Z C OV 1 000 s00 111 p ppp ppp ppp ppp ppp
 *  - - - -  BUSC ADDR
 ***************************************************/
static void cp1610_busc(cp1610_state *cpustate, int dir)
{
	int condition1 = 0;
	int condition2 = 0;
	UINT16 offset = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	if (cpustate->flags & C) condition1 = 1;
	if (cpustate->flags & S) condition2 = 1;
	if (condition1 ^ condition2)
	{
		cpustate->r[7] += (offset ^ dir);
		cpustate->icount -= 9;
	}
	else
	{
		cpustate->icount -= 7;
	}
}

/***************************************************
 *  S Z C OV 1 000 s01 111 p ppp ppp ppp ppp ppp
 *  - - - -  BESC ADDR
 ***************************************************/
static void cp1610_besc(cp1610_state *cpustate, int dir)
{
	int condition1 = 0;
	int condition2 = 0;
	UINT16 offset = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	if (cpustate->flags & C) condition1 = 1;
	if (cpustate->flags & S) condition2 = 1;
	if (!(condition1 ^ condition2))
	{
		cpustate->r[7] += (offset ^ dir);
		cpustate->icount -= 9;
	}
	else
	{
		cpustate->icount -= 7;
	}
}

/***************************************************
 *  S Z C OV 1 000 s1e e p ppp ppp ppp ppp ppp
 *  - - - -  BEXT ADDR, eeee
 ***************************************************/
static void cp1610_bext(cp1610_state *cpustate, int ext, int dir)
{
	UINT16 offset = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	/* TBD */
	if (0)
	{
		cpustate->r[7] += (offset ^ dir);
		cpustate->icount -= 9;
	}
	else
	{
		cpustate->icount -= 7;
	}
}

/***************************************************
 *  S Z C OV 1 001 000 sss a aaa aaa aaa aaa aaa
 *  - - - -  MVO Rs, ADDR
 ***************************************************/
static void cp1610_mvo(cp1610_state *cpustate, int s)
{
	UINT16 addr;
	cpustate->mask_interrupts = 1;
	addr = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	cp1610_writemem16(addr,cpustate->r[s]);
	cpustate->icount -= 11;
}

/***************************************************
 *  S Z C OV 1 001 mmm sss  (mmm = 0xx)
 *  - - - -  MVO@ Rs, Rm
 ***************************************************/
static void cp1610_mvoat(cp1610_state *cpustate, int s, int m)
{
	cpustate->mask_interrupts = 1;
	cp1610_writemem16(cpustate->r[m],cpustate->r[s]);
	cpustate->icount -= 9;
}

/***************************************************
 *  S Z C OV 1 001 mmm sss  (m = 10x or 110)
 *  - - - -  MVO@ Rs, Rm
 ***************************************************/
static void cp1610_mvoat_i(cp1610_state *cpustate, int s, int m)
{
	cpustate->mask_interrupts = 1;
	cp1610_writemem16(cpustate->r[m],cpustate->r[s]);
	cpustate->r[m]++;
	cpustate->icount -= 9;
}

/***************************************************
 *  S Z C OV 1 001 111 sss I III III III III III
 *  - - - -  MVOI Rs, II
 ***************************************************/
static void cp1610_mvoi(cp1610_state *cpustate, int s)
{
	cpustate->mask_interrupts = 1;
	cp1610_writemem16(cpustate->r[7],cpustate->r[s]);
	cpustate->r[7]++;
	cpustate->icount -= 9;
}

/***************************************************
 *  S Z C OV 1 010 000 ddd a aaa aaa aaa aaa aaa
 *  - - - -  MVI ADDR, Rd
 ***************************************************/
static void cp1610_mvi(cp1610_state *cpustate, int d)
{
	UINT16 addr = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	cpustate->r[d] = cp1610_readmem16(addr);
	cpustate->icount -= 10;
}

/***************************************************
 *  S Z C OV 1 010 mmm ddd  (mmm = 0xx)
 *  - - - -  MVI@ Rm, Rd
 ***************************************************/
static void cp1610_mviat(cp1610_state *cpustate, int m, int d)
{
	cpustate->r[d] = cp1610_readmem16(cpustate->r[m]);
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 1 010 mmm ddd  (mmm = 10x)
 *  - - - -  MVI@ Rm, Rd
 ***************************************************/
static void cp1610_mviat_i(cp1610_state *cpustate, int m, int d)
{
	UINT16 temp = cp1610_readmem16(cpustate->r[m]);
	cpustate->r[m]++;
	cpustate->r[d] = temp;
	cpustate->icount -= 8;

	//cpustate->r[d] = cp1610_readmem16(cpustate->r[m]);
	//cpustate->r[m]++;
	//cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 1 010 110 ddd
 *  - - - -  PULR Rd
 ***************************************************/
static void cp1610_pulr(cp1610_state *cpustate, int d)
{
	cpustate->r[6]--;
	cpustate->r[d] = cp1610_readmem16(cpustate->r[6]);
	cpustate->icount -= 11;
}

/***************************************************
 *  S Z C OV 1 010 111 ddd I III III III III III
 *  - - - -  MVII II, Rd
 ***************************************************/
static void cp1610_mvii(cp1610_state *cpustate, int d)
{
	UINT16 temp = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	cpustate->r[d] = temp;
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 1 011 000 ddd a aaa aaa aaa aaa aaa
 *  x x x x  ADD ADDR, Rd
 ***************************************************/
static void cp1610_add(cp1610_state *cpustate, int d)
{
	UINT16 addr = cp1610_readop(cpustate->r[7]);
	UINT16 data = cp1610_readmem16(addr);
	cpustate->r[7]++;
	CLR_SZOC;
	SET_COV(cpustate->r[d],data,0);
	cpustate->r[d] += data;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 10;
}

/***************************************************
 *  S Z C OV 1 011 mmm ddd  (mmm = 0xx)
 *  x x x x  ADD@ Rm, Rd
 ***************************************************/
static void cp1610_addat(cp1610_state *cpustate, int m, int d)
{
	UINT16 data = cp1610_readmem16(cpustate->r[m]);
	CLR_SZOC;
	SET_COV(cpustate->r[d],data,0);
	cpustate->r[d] += data;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 1 011 mmm ddd  (mmm = 10x)
 *  x x x x  ADD@ Rm, Rd
 ***************************************************/
static void cp1610_addat_i(cp1610_state *cpustate, int m, int d)
{
	UINT16 data = cp1610_readmem16(cpustate->r[m]);
	cpustate->r[m]++;
	CLR_SZOC;
	SET_COV(cpustate->r[d],data,0);
	cpustate->r[d] += data;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 1 011 mmm ddd  (mmm = 110)
 *  x x x x  ADD@ Rm, Rd
 ***************************************************/
static void cp1610_addat_d(cp1610_state *cpustate, int m, int d)
{
	UINT16 data;
	cpustate->r[m]--;
	data = cp1610_readmem16(cpustate->r[m]);
	CLR_SZOC;
	SET_COV(cpustate->r[d],data,0);
	cpustate->r[d] += data;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 11;
}

/***************************************************
 *  S Z C OV 1 011 111 ddd I III III III III III
 *  x x x x  ADDI II, Rd
 ***************************************************/
static void cp1610_addi(cp1610_state *cpustate, int d)
{
	UINT16 data;
	data = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	CLR_SZOC;
	SET_COV(cpustate->r[d],data,0);
	cpustate->r[d] += data;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 1 100 000 ddd a aaa aaa aaa aaa aaa
 *  x x x x  SUB ADDR, Rd
 ***************************************************/
static void cp1610_sub(cp1610_state *cpustate, int d)
{
	UINT16 addr = cp1610_readop(cpustate->r[7]);
	UINT32 data = cp1610_readmem16(addr);
	cpustate->r[7]++;
	CLR_SZOC;
	data = (data ^ 0xffff) + 1;
	SET_COV(cpustate->r[d],data,1);
	data &= 0xffff;
	cpustate->r[d] += data;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 10;
}

/***************************************************
 *  S Z C OV 1 100 mmm ddd  (mmm = 0xx)
 *  x x x x  SUB@ Rm, Rd
 ***************************************************/
static void cp1610_subat(cp1610_state *cpustate, int m, int d)
{
	UINT32 data = cp1610_readmem16(cpustate->r[m]);
	CLR_SZOC;
	data = (data ^ 0xffff) + 1;
	SET_COV(cpustate->r[d],data,1);
	data &= 0xffff;
	cpustate->r[d] += data;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 1 100 mmm ddd  (mmm = 10x)
 *  x x x x  SUB@ Rm, Rd
 ***************************************************/
static void cp1610_subat_i(cp1610_state *cpustate, int m, int d)
{
	UINT32 data = cp1610_readmem16(cpustate->r[m]);
	cpustate->r[m]++;
	CLR_SZOC;
	data = (data ^ 0xffff) + 1;
	SET_COV(cpustate->r[d],data,1);
	data &= 0xffff;
	cpustate->r[d] += data;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 1 100 mmm ddd  (mmm = 110)
 *  x x x x  SUB@ Rm, Rd
 ***************************************************/
static void cp1610_subat_d(cp1610_state *cpustate, int m, int d)
{
	UINT32 data;
	cpustate->r[m]--;
	data = cp1610_readmem16(cpustate->r[m]);
	CLR_SZOC;
	data = (data ^ 0xffff) + 1;
	SET_COV(cpustate->r[d],data,1);
	data &= 0xffff;
	cpustate->r[d] += data;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 11;
}

/***************************************************
 *  S Z C OV 1 100 111 ddd I III III III III III
 *  x x x x  SUBI II, Rd
 ***************************************************/
static void cp1610_subi(cp1610_state *cpustate, int d)
{
	UINT32 data;
	data = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	data = (data ^ 0xffff) + 1;
	CLR_SZOC;
	SET_COV(cpustate->r[d],data,1);
	data &= 0xffff;
	cpustate->r[d] += data;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 1 101 000 ddd a aaa aaa aaa aaa aaa
 *  x x x x  CMP ADDR, Rd
 ***************************************************/
static void cp1610_cmp(cp1610_state *cpustate, int d)
{
	UINT16 addr = cp1610_readop(cpustate->r[7]);
	UINT32 data = cp1610_readmem16(addr);
	UINT16 res;
	cpustate->r[7]++;
	CLR_SZOC;
	data = (data ^ 0xffff) + 1;
	SET_COV(cpustate->r[d],data,1);
	data &= 0xffff;
	res = cpustate->r[d] + data;
	SET_SZ(res);
	cpustate->icount -= 10;
}

/***************************************************
 *  S Z C OV 1 101 mmm ddd  (mmm = 0xx)
 *  x x x x  CMP@ Rm, Rd
 ***************************************************/
static void cp1610_cmpat(cp1610_state *cpustate, int m, int d)
{
	UINT32 data = cp1610_readmem16(cpustate->r[m]);
	UINT16 res;
	CLR_SZOC;
	data = (data ^ 0xffff) + 1;
	SET_COV(cpustate->r[d],data,1);
	data &= 0xffff;
	res = cpustate->r[d] + data;
	SET_SZ(res);
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 1 101 mmm ddd  (mmm = 10x)
 *  x x x x  CMP@ Rm, Rd
 ***************************************************/
static void cp1610_cmpat_i(cp1610_state *cpustate, int m, int d)
{
	UINT32 data = cp1610_readmem16(cpustate->r[m]);
	UINT16 res;
	cpustate->r[m]++;
	CLR_SZOC;
	data = (data ^ 0xffff) + 1;
	SET_COV(cpustate->r[d],data,1);
	data &= 0xffff;
	res = cpustate->r[d] + data;
	SET_SZ(res);
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 1 101 mmm ddd  (mmm = 110)
 *  x x x x  CMP@ Rm, Rd
 ***************************************************/
static void cp1610_cmpat_d(cp1610_state *cpustate, int m, int d)
{
	UINT32 data;
	UINT16 res;
	cpustate->r[m]--;
	data = cp1610_readmem16(cpustate->r[m]);
	CLR_SZOC;
	data = (data ^ 0xffff) + 1;
	SET_COV(cpustate->r[d],data,1);
	data &= 0xffff;
	res = cpustate->r[d] + data;
	SET_SZ(res);
	cpustate->icount -= 11;
}

/***************************************************
 *  S Z C OV 1 101 111 ddd I III III III III III
 *  x x x x  CMPI II, Rd
 ***************************************************/
static void cp1610_cmpi(cp1610_state *cpustate, int d)
{
	UINT32 data;
	UINT16 res;
	data = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	data = (data ^ 0xffff) + 1;
	CLR_SZOC;
	SET_COV(cpustate->r[d],data,1);
	data &= 0xffff;
	res = cpustate->r[d] + data;
	SET_SZ(res);
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 1 110 000 ddd a aaa aaa aaa aaa aaa
 *  x x - -  AND ADDR, Rd
 ***************************************************/
static void cp1610_and(cp1610_state *cpustate, int d)
{
	UINT16 addr = cp1610_readop(cpustate->r[7]);
	UINT16 data = cp1610_readmem16(addr);
	cpustate->r[7]++;
	CLR_SZ;
	cpustate->r[d] &= data;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 10;
}

/***************************************************
 *  S Z C OV 1 110 mmm ddd  (mmm = 0xx)
 *  x x - -  AND@ Rm, Rd
 ***************************************************/
static void cp1610_andat(cp1610_state *cpustate, int m, int d)
{
	UINT16 data = cp1610_readmem16(cpustate->r[m]);
	CLR_SZ;
	cpustate->r[d] &= data;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 1 110 mmm ddd  (mmm = 10x)
 *  x x - -  AND@ Rm, Rd
 ***************************************************/
static void cp1610_andat_i(cp1610_state *cpustate, int m, int d)
{
	UINT16 data = cp1610_readmem16(cpustate->r[m]);
	cpustate->r[m]++;
	CLR_SZ;
	cpustate->r[d] &= data;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 1 110 mmm ddd  (mmm = 110)
 *  x x - -  AND@ Rm, Rd
 ***************************************************/
static void cp1610_andat_d(cp1610_state *cpustate, int m, int d)
{
	UINT16 data;
	cpustate->r[m]--;
	data = cp1610_readmem16(cpustate->r[m]);
	CLR_SZ;
	cpustate->r[d] &= data;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 11;
}

/***************************************************
 *  S Z C OV 1 110 111 ddd I III III III III III
 *  x x - -  AND II, Rd
 ***************************************************/
static void cp1610_andi(cp1610_state *cpustate, int d)
{
	UINT16 data;
	data = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	CLR_SZ;
	cpustate->r[d] &= data;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 1 111 000 ddd a aaa aaa aaa aaa aaa
 *  x x - -  XOR ADDR, Rd
 ***************************************************/
static void cp1610_xor(cp1610_state *cpustate, int d)
{
	UINT16 addr = cp1610_readop(cpustate->r[7]);
	UINT16 data = cp1610_readmem16(addr);
	cpustate->r[7]++;
	CLR_SZ;
	cpustate->r[d] ^= data;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 10;
}

/***************************************************
 *  S Z C OV 1 111 mmm ddd  (mmm = 0xx)
 *  x x - -  XOR@ Rm, Rd
 ***************************************************/
static void cp1610_xorat(cp1610_state *cpustate, int m, int d)
{
	UINT16 data = cp1610_readmem16(cpustate->r[m]);
	CLR_SZ;
	cpustate->r[d] ^= data;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 1 111 mmm ddd  (mmm = 10x)
 *  x x - -  XOR@ Rm, Rd
 ***************************************************/
static void cp1610_xorat_i(cp1610_state *cpustate, int m, int d)
{
	UINT16 data = cp1610_readmem16(cpustate->r[m]);
	cpustate->r[m]++;
	CLR_SZ;
	cpustate->r[d] ^= data;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 8;
}

/***************************************************
 *  S Z C OV 1 111 mmm ddd  (mmm = 110)
 *  x x - -  XOR@ Rm, Rd
 ***************************************************/
static void cp1610_xorat_d(cp1610_state *cpustate, int m, int d)
{
	UINT16 data;
	cpustate->r[m]--;
	data = cp1610_readmem16(cpustate->r[m]);
	CLR_SZ;
	cpustate->r[d] ^= data;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 11;
}

/***************************************************
 *  S Z C OV 1 111 111 ddd I III III III III III
 *  x x - -  XOR II, Rd
 ***************************************************/
static void cp1610_xori(cp1610_state *cpustate, int d)
{
	UINT16 data;
	data = cp1610_readop(cpustate->r[7]);
	cpustate->r[7]++;
	CLR_SZ;
	cpustate->r[d] ^= data;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 8;
}

static CPU_RESET( cp1610 )
{
	/* This is how we set the reset vector */
	cpu_set_input_line(device, CP1610_RESET, PULSE_LINE);
}

/***************************************************
 *  S Z C OV 0x001  1 010 mmm ddd   (mmm = 0xx)
 *  - - - -  SDBD, MVI@ Rm, Rd
 ***************************************************/
static void cp1610_sdbd_mviat(cp1610_state *cpustate, int r, int d)
{
	cpustate->r[d] = cp1610_readmem16(cpustate->r[r]) & 0xff;
	cpustate->r[d] |= (cp1610_readmem16(cpustate->r[r]) << 8);
	cpustate->icount -= 14;
}

/***************************************************
 *  S Z C OV 0x001  1 010 mmm ddd   (mmm = 10x)
 *  - - - -  SDBD, MVI@ Rm, Rd
 ***************************************************/
static void cp1610_sdbd_mviat_i(cp1610_state *cpustate, int r, int d)
{
	UINT16 temp;
	temp = cp1610_readmem16(cpustate->r[r]) & 0xff;
	cpustate->r[r]++;
	cpustate->r[d] = temp;
	temp = (cp1610_readmem16(cpustate->r[r]) << 8);
	cpustate->r[r]++;
	cpustate->r[d] |= temp;
	cpustate->icount -= 14;
}

/***************************************************
 *  S Z C OV 0x001  1 010 mmm ddd   (mmm = 101)
 *  - - - -  SDBD, MVI@ Rm, Rd
 ***************************************************/
static void cp1610_sdbd_mviat_d(cp1610_state *cpustate, int r, int d)
{
	cpustate->r[r]--;
	cpustate->r[d] = cp1610_readmem16(cpustate->r[r]) & 0xff;
	cpustate->r[r]--;
	cpustate->r[d] |= (cp1610_readmem16(cpustate->r[r]) << 8);
	cpustate->icount -= 17;
}

/************************************************************************
 *  S Z C OV 0x001  1 010 111 ddd  x xxx xLL LLL LLL  x xxx xUU UUU UUU
 *  - - - -  SDBD, MVII I-I, Rd
 ************************************************************************/
static void cp1610_sdbd_mvii(cp1610_state *cpustate, int d)
{
	UINT16 addr;
	addr = cp1610_readop(cpustate->r[7]) & 0xff;
	cpustate->r[7]++;
	addr |= (cp1610_readop(cpustate->r[7]) << 8);
	cpustate->r[7]++;
	cpustate->r[d] = addr;
	cpustate->icount -= 14;
}

/***************************************************
 *  S Z C OV 0x001  1 011 mmm ddd   (mmm = 0xx)
 *  x x x x  SDBD, ADD@ Rm, Rd
 ***************************************************/
static void cp1610_sdbd_addat(cp1610_state *cpustate, int r, int d)
{
	UINT16 temp;
	CLR_SZOC;
	temp = cp1610_readmem16(cpustate->r[r]) & 0xff;
	temp |= (cp1610_readmem16(cpustate->r[r]) << 8);
	SET_COV(cpustate->r[d],temp,0);
	cpustate->r[d] += temp;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 14;
}

/***************************************************
 *  S Z C OV 0x001  1 011 mmm ddd   (mmm = 10x)
 *  x x x x  SDBD, ADD@ Rm, Rd
 ***************************************************/
static void cp1610_sdbd_addat_i(cp1610_state *cpustate, int r, int d)
{
	UINT16 temp;
	CLR_SZOC;
	temp = cp1610_readmem16(cpustate->r[r]) & 0xff;
	cpustate->r[r]++;
	temp |= (cp1610_readmem16(cpustate->r[r]) << 8);
	cpustate->r[r]++;
	SET_COV(cpustate->r[d],temp,0);
	cpustate->r[d] += temp;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 14;
}

/***************************************************
 *  S Z C OV 0x001  1 011 mmm ddd   (mmm = 101)
 *  x x x x  SDBD, ADD@ Rm, Rd
 ***************************************************/
static void cp1610_sdbd_addat_d(cp1610_state *cpustate, int r, int d)
{
	UINT16 temp;
	CLR_SZOC;
	cpustate->r[r]--;
	temp = cp1610_readmem16(cpustate->r[r]) & 0xff;
	cpustate->r[r]--;
	temp |= (cp1610_readmem16(cpustate->r[r]) << 8);
	SET_COV(cpustate->r[d],temp,0);
	cpustate->r[d] += temp;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 17;
}

/************************************************************************
 *  S Z C OV 0x001  1 011 111 ddd  x xxx xLL LLL LLL  x xxx xUU UUU UUU
 *  x x x x  SDBD, ADDI I-I, Rd
 ************************************************************************/
static void cp1610_sdbd_addi(cp1610_state *cpustate, int d)
{
	UINT16 addr;
	UINT16 temp;
	CLR_SZOC;
	addr = cp1610_readop(cpustate->r[7]) & 0xff;
	cpustate->r[7]++;
	addr |= (cp1610_readop(cpustate->r[7]) << 8);
	cpustate->r[7]++;
	temp = addr;
	SET_COV(cpustate->r[d],temp,0);
	cpustate->r[d] += temp;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 14;
}

/***************************************************
 *  S Z C OV 0x001  1 100 mmm ddd   (mmm = 0xx)
 *  x x x x  SDBD, SUB@ Rm, Rd
 ***************************************************/
static void cp1610_sdbd_subat(cp1610_state *cpustate, int r, int d)
{
	UINT32 temp;
	CLR_SZOC;
	temp = cp1610_readmem16(cpustate->r[r]) & 0xff;
	temp |= (cp1610_readmem16(cpustate->r[r]) << 8);
	temp = (temp ^ 0xffff) + 1;
	SET_COV(cpustate->r[d],temp,1);
	temp &= 0xffff;
	cpustate->r[d] += temp;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 14;
}

/***************************************************
 *  S Z C OV 0x001  1 100 mmm ddd   (mmm = 10x)
 *  x x x x  SDBD, SUB@ Rm, Rd
 ***************************************************/
static void cp1610_sdbd_subat_i(cp1610_state *cpustate, int r, int d)
{
	UINT32 temp;
	CLR_SZOC;
	temp = cp1610_readmem16(cpustate->r[r]) & 0xff;
	cpustate->r[r]++;
	temp |= (cp1610_readmem16(cpustate->r[r]) << 8);
	cpustate->r[r]++;
	temp = (temp ^ 0xffff) + 1;
	SET_COV(cpustate->r[d],temp,1);
	temp &= 0xffff;
	cpustate->r[d] += temp;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 14;
}

/***************************************************
 *  S Z C OV 0x001  1 100 mmm ddd   (mmm = 101)
 *  x x x x  SDBD, SUB@ Rm, Rd
 ***************************************************/
static void cp1610_sdbd_subat_d(cp1610_state *cpustate, int r, int d)
{
	UINT32 temp;
	CLR_SZOC;
	cpustate->r[r]--;
	temp = cp1610_readmem16(cpustate->r[r]) & 0xff;
	cpustate->r[r]--;
	temp |= (cp1610_readmem16(cpustate->r[r]) << 8);
	temp = (temp ^ 0xffff) + 1;
	SET_COV(cpustate->r[d],temp,1);
	temp &= 0xffff;
	cpustate->r[d] += temp;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 17;
}

/************************************************************************
 *  S Z C OV 0x001  1 100 111 ddd  x xxx xLL LLL LLL  x xxx xUU UUU UUU
 *  x x x x  SDBD, SUBI I-I, Rd
 ************************************************************************/
static void cp1610_sdbd_subi(cp1610_state *cpustate, int d)
{
	UINT16 addr;
	UINT32 temp;
	CLR_SZOC;
	addr = cp1610_readop(cpustate->r[7]) & 0xff;
	cpustate->r[7]++;
	addr |= (cp1610_readop(cpustate->r[7]) << 8);
	cpustate->r[7]++;
	temp = addr;
	temp = (temp ^ 0xffff) + 1;
	SET_COV(cpustate->r[d],temp,1);
	temp &= 0xffff;
	cpustate->r[d] += temp;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 14;
}

/***************************************************
 *  S Z C OV 0x001  1 101 mmm ddd   (mmm = 0xx)
 *  x x x x  SDBD, CMP@ Rm, Rd
 ***************************************************/
static void cp1610_sdbd_cmpat(cp1610_state *cpustate, int r, int d)
{
	UINT32 temp;
	UINT16 temp2;
	CLR_SZOC;
	temp = cp1610_readmem16(cpustate->r[r]) & 0xff;
	temp |= (cp1610_readmem16(cpustate->r[r]) << 8);
	temp = (temp ^ 0xffff) + 1;
	SET_COV(cpustate->r[d],temp,1);
	temp &= 0xffff;
	temp2 = cpustate->r[d] + temp;
	SET_SZ(temp2);
	cpustate->icount -= 14;
}

/***************************************************
 *  S Z C OV 0x001  1 101 mmm ddd   (mmm = 10x)
 *  x x x x  SDBD, CMP@ Rm, Rd
 ***************************************************/
static void cp1610_sdbd_cmpat_i(cp1610_state *cpustate, int r, int d)
{
	UINT32 temp;
	UINT16 temp2;
	CLR_SZOC;
	temp = cp1610_readmem16(cpustate->r[r]) & 0xff;
	cpustate->r[r]++;
	temp |= (cp1610_readmem16(cpustate->r[r]) << 8);
	cpustate->r[r]++;
	temp = (temp ^ 0xffff) + 1;
	SET_COV(cpustate->r[d],temp,1);
	temp &= 0xffff;
	temp2 = cpustate->r[d] + temp;
	SET_SZ(temp2);
	cpustate->icount -= 14;
}

/***************************************************
 *  S Z C OV 0x001  1 101 mmm ddd   (mmm = 101)
 *  x x x x  SDBD, CMP@ Rm, Rd
 ***************************************************/
static void cp1610_sdbd_cmpat_d(cp1610_state *cpustate, int r, int d)
{
	UINT32 temp;
	UINT16 temp2;
	CLR_SZOC;
	cpustate->r[r]--;
	temp = cp1610_readmem16(cpustate->r[r]) & 0xff;
	cpustate->r[r]--;
	temp |= (cp1610_readmem16(cpustate->r[r]) << 8);
	temp = (temp ^ 0xffff) + 1;
	SET_COV(cpustate->r[d],temp,1);
	temp &= 0xffff;
	temp2 = cpustate->r[d] + temp;
	SET_SZ(temp2);
	cpustate->icount -= 17;
}

/************************************************************************
 *  S Z C OV 0x001  1 101 111 ddd  x xxx xLL LLL LLL  x xxx xUU UUU UUU
 *  x x x x  SDBD, CMPI I-I, Rd
 ************************************************************************/
static void cp1610_sdbd_cmpi(cp1610_state *cpustate, int d)
{
	UINT16 addr;
	UINT32 temp;
	UINT16 temp2;
	CLR_SZOC;
	addr = cp1610_readop(cpustate->r[7]) & 0xff;
	cpustate->r[7]++;
	addr |= (cp1610_readop(cpustate->r[7]) << 8);
	cpustate->r[7]++;
	temp = addr;
	temp = (temp ^ 0xffff) + 1;
	SET_COV(cpustate->r[d],temp,1);
	temp &= 0xffff;
	temp2 = cpustate->r[d] + temp;
	SET_SZ(temp2);
	cpustate->icount -= 14;
}

/***************************************************
 *  S Z C OV 0x001  1 110 mmm ddd   (mmm = 0xx)
 *  x x - -  SDBD, AND@ Rm, Rd
 ***************************************************/
static void cp1610_sdbd_andat(cp1610_state *cpustate, int r, int d)
{
	UINT16 temp;
	CLR_SZ;
	temp = cp1610_readmem16(cpustate->r[r]) & 0xff;
	temp |= (cp1610_readmem16(cpustate->r[r]) << 8);
	cpustate->r[d] &= temp;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 14;
}

/***************************************************
 *  S Z C OV 0x001  1 110 mmm ddd   (mmm = 10x)
 *  x x - -  SDBD, AND@ Rm, Rd
 ***************************************************/
static void cp1610_sdbd_andat_i(cp1610_state *cpustate, int r, int d)
{
	UINT16 temp;
	CLR_SZ;
	temp = cp1610_readmem16(cpustate->r[r]) & 0xff;
	cpustate->r[r]++;
	temp |= (cp1610_readmem16(cpustate->r[r]) << 8);
	cpustate->r[r]++;
	cpustate->r[d] &= temp;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 14;
}

/***************************************************
 *  S Z C OV 0x001  1 110 mmm ddd   (mmm = 101)
 *  x x - -  SDBD, AND@ Rm, Rd
 ***************************************************/
static void cp1610_sdbd_andat_d(cp1610_state *cpustate, int r, int d)
{
	UINT16 temp;
	CLR_SZ;
	cpustate->r[r]--;
	temp = cp1610_readmem16(cpustate->r[r]) & 0xff;
	cpustate->r[r]--;
	temp |= (cp1610_readmem16(cpustate->r[r]) << 8);
	cpustate->r[d] &= temp;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 17;
}

/************************************************************************
 *  S Z C OV 0x001  1 110 111 ddd  x xxx xLL LLL LLL  x xxx xUU UUU UUU
 *  x x - -  SDBD, ANDI I-I, Rd
 ************************************************************************/
static void cp1610_sdbd_andi(cp1610_state *cpustate, int d)
{
	UINT16 addr;
	CLR_SZ;
	addr = cp1610_readop(cpustate->r[7]) & 0xff;
	cpustate->r[7]++;
	addr |= (cp1610_readop(cpustate->r[7]) << 8);
	cpustate->r[7]++;
	cpustate->r[d] &= addr;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 14;
}

/***************************************************
 *  S Z C OV 0x001  1 111 mmm ddd   (mmm = 0xx)
 *  x x - -  SDBD, XOR@ Rm, Rd
 ***************************************************/
static void cp1610_sdbd_xorat(cp1610_state *cpustate, int r, int d)
{
	UINT16 temp;
	CLR_SZ;
	temp = cp1610_readmem16(cpustate->r[r]) & 0xff;
	temp |= (cp1610_readmem16(cpustate->r[r]) << 8);
	cpustate->r[d] ^= temp;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 14;
}

/***************************************************
 *  S Z C OV 0x001  1 111 mmm ddd   (mmm = 10x)
 *  x x - -  SDBD, XOR@ Rm, Rd
 ***************************************************/
static void cp1610_sdbd_xorat_i(cp1610_state *cpustate, int r, int d)
{
	UINT16 temp;
	CLR_SZ;
	temp = cp1610_readmem16(cpustate->r[r]) & 0xff;
	cpustate->r[r]++;
	temp |= (cp1610_readmem16(cpustate->r[r]) << 8);
	cpustate->r[r]++;
	cpustate->r[d] ^= temp;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 14;
}

/***************************************************
 *  S Z C OV 0x001  1 111 mmm ddd   (mmm = 101)
 *  x x - -  SDBD, XOR@ Rm, Rd
 ***************************************************/
static void cp1610_sdbd_xorat_d(cp1610_state *cpustate, int r, int d)
{
	UINT16 temp;
	CLR_SZ;
	cpustate->r[r]--;
	temp = cp1610_readmem16(cpustate->r[r]) & 0xff;
	cpustate->r[r]--;
	temp |= (cp1610_readmem16(cpustate->r[r]) << 8);
	cpustate->r[d] ^= temp;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 17;
}

/************************************************************************
 *  S Z C OV 0x001  1 111 111 ddd  x xxx xLL LLL LLL  x xxx xUU UUU UUU
 *  x x - -  SDBD, XORI I-I, Rd
 ************************************************************************/
static void cp1610_sdbd_xori(cp1610_state *cpustate, int d)
{
	UINT16 addr;
	CLR_SZ;
	addr = cp1610_readop(cpustate->r[7]) & 0xff;
	cpustate->r[7]++;
	addr |= (cp1610_readop(cpustate->r[7]) << 8);
	cpustate->r[7]++;
	cpustate->r[d] ^= addr;
	SET_SZ(cpustate->r[d]);
	cpustate->icount -= 14;
}

/***************************************************
 *  S Z C OV b baa aaa a00  x xxx xxa aaa aaa aaa
 *  - - - -  JSR R1bb, ADDR
 ***************************************************/
static void cp1610_jsr(cp1610_state *cpustate, int r, UINT16 addr)
{
	cpustate->r[r] = cpustate->r[7];
	cpustate->r[7] = addr;
}

/***************************************************
 *  S Z C OV b baa aaa a01  x xxx xxa aaa aaa aaa
 *  - - - -  JSRE R1bb, ADDR
 ***************************************************/
static void cp1610_jsre(cp1610_state *cpustate, int r, UINT16 addr)
{
	cpustate->r[r] = cpustate->r[7];
	cpustate->r[7] = addr;
	cpustate->intr_enabled = 1;
}

/***************************************************
 *  S Z C OV b baa aaa a10  x xxx xxa aaa aaa aaa
 *  - - - -  JSRD R1bb, ADDR
 ***************************************************/
static void cp1610_jsrd(cp1610_state *cpustate, int r, UINT16 addr)
{
	cpustate->r[r] = cpustate->r[7];
	cpustate->r[7] = addr;
	cpustate->intr_enabled = 0;
}

/***************************************************
 *  S Z C OV 1 1aa aaa a00  x xxx xxa aaa aaa aaa
 *  - - - -  J ADDR
 ***************************************************/
static void cp1610_j(cp1610_state *cpustate, UINT16 addr)
{
	cpustate->r[7] = addr;
}

/***************************************************
 *  S Z C OV 1 1aa aaa a01  x xxx xxa aaa aaa aaa
 *  - - - -  JE ADDR
 ***************************************************/
static void cp1610_je(cp1610_state *cpustate, UINT16 addr)
{
	cpustate->r[7] = addr;
	cpustate->intr_enabled = 1;
}

/***************************************************
 *  S Z C OV 1 1aa aaa a10  x xxx xxa aaa aaa aaa
 *  - - - -  JD ADDR
 ***************************************************/
static void cp1610_jd(cp1610_state *cpustate, UINT16 addr)
{
	cpustate->r[7] = addr;
	cpustate->intr_enabled = 0;
}

static void cp1610_do_sdbd(cp1610_state *cpustate)
{
	UINT16 sdbdtype, dest;

	/* Even though SDBD is uninterruptable, we don't need to set the mask bit,
     * because we already treat the SDBD prefixed instructions as uninterruptable
     */
	//cpustate->mask_interrupts = 1;

	sdbdtype = cp1610_readop(cpustate->r[7]);
	dest = sdbdtype & 0x07;
	cpustate->r[7]++;

	switch (sdbdtype & 0x3f8)
	{
	case 0x240: /* Not supporting SDBD MVO@ or SDBD MVOI for now */
	case 0x248:
	case 0x250:
	case 0x258:
	case 0x260:
	case 0x268:
	case 0x270:
	case 0x278: /* 1 001 xxx xxx */ cp1610_illegal(cpustate);				break;

	case 0x280: /* 1 010 000 xxx */ cp1610_sdbd_mviat(cpustate, 0,dest);		break;
	case 0x288: /* 1 010 001 xxx */ cp1610_sdbd_mviat(cpustate, 1,dest);		break;
	case 0x290: /* 1 010 010 xxx */ cp1610_sdbd_mviat(cpustate, 2,dest);		break;
	case 0x298: /* 1 010 011 xxx */ cp1610_sdbd_mviat(cpustate, 3,dest);		break;
	case 0x2a0: /* 1 010 100 xxx */ cp1610_sdbd_mviat_i(cpustate, 4,dest);	break;
	case 0x2a8: /* 1 010 101 xxx */ cp1610_sdbd_mviat_i(cpustate, 5,dest);	break;
	case 0x2b0: /* 1 010 110 xxx */ cp1610_sdbd_mviat_d(cpustate, 6,dest);	break; /* ??? */
	case 0x2b8: /* 1 010 111 xxx */ cp1610_sdbd_mvii(cpustate, dest);			break;

	case 0x2c0: /* 1 011 000 xxx */ cp1610_sdbd_addat(cpustate, 0,dest);		break;
	case 0x2c8: /* 1 011 001 xxx */ cp1610_sdbd_addat(cpustate, 1,dest);		break;
	case 0x2d0: /* 1 011 010 xxx */ cp1610_sdbd_addat(cpustate, 2,dest);		break;
	case 0x2d8: /* 1 011 011 xxx */ cp1610_sdbd_addat(cpustate, 3,dest);		break;
	case 0x2e0: /* 1 011 100 xxx */ cp1610_sdbd_addat_i(cpustate, 4,dest);	break;
	case 0x2e8: /* 1 011 101 xxx */ cp1610_sdbd_addat_i(cpustate, 5,dest);	break;
	case 0x2f0: /* 1 011 110 xxx */ cp1610_sdbd_addat_d(cpustate, 6,dest);	break; /* ??? */
	case 0x2f8: /* 1 011 111 xxx */ cp1610_sdbd_addi(cpustate, dest);			break;

	case 0x300: /* 1 100 000 xxx */ cp1610_sdbd_subat(cpustate, 0,dest);		break;
	case 0x308: /* 1 100 001 xxx */ cp1610_sdbd_subat(cpustate, 1,dest);		break;
	case 0x310: /* 1 100 010 xxx */ cp1610_sdbd_subat(cpustate, 2,dest);		break;
	case 0x318: /* 1 100 011 xxx */ cp1610_sdbd_subat(cpustate, 3,dest);		break;
	case 0x320: /* 1 100 100 xxx */ cp1610_sdbd_subat_i(cpustate, 4,dest);	break;
	case 0x328: /* 1 100 101 xxx */ cp1610_sdbd_subat_i(cpustate, 5,dest);	break;
	case 0x330: /* 1 100 110 xxx */ cp1610_sdbd_subat_d(cpustate, 6,dest);	break; /* ??? */
	case 0x338: /* 1 100 111 xxx */ cp1610_sdbd_subi(cpustate, dest);			break;

	case 0x340: /* 1 101 000 xxx */ cp1610_sdbd_cmpat(cpustate, 0,dest);		break;
	case 0x348: /* 1 101 001 xxx */ cp1610_sdbd_cmpat(cpustate, 1,dest);		break;
	case 0x350: /* 1 101 010 xxx */ cp1610_sdbd_cmpat(cpustate, 2,dest);		break;
	case 0x358: /* 1 101 011 xxx */ cp1610_sdbd_cmpat(cpustate, 3,dest);		break;
	case 0x360: /* 1 101 100 xxx */ cp1610_sdbd_cmpat_i(cpustate, 4,dest);	break;
	case 0x368: /* 1 101 101 xxx */ cp1610_sdbd_cmpat_i(cpustate, 5,dest);	break;
	case 0x370: /* 1 101 110 xxx */ cp1610_sdbd_cmpat_d(cpustate, 6,dest);	break; /* ??? */
	case 0x378: /* 1 101 111 xxx */ cp1610_sdbd_cmpi(cpustate, dest);			break;

	case 0x380: /* 1 110 000 xxx */ cp1610_sdbd_andat(cpustate, 0,dest);		break;
	case 0x388: /* 1 110 001 xxx */ cp1610_sdbd_andat(cpustate, 1,dest);		break;
	case 0x390: /* 1 110 010 xxx */ cp1610_sdbd_andat(cpustate, 2,dest);		break;
	case 0x398: /* 1 110 011 xxx */ cp1610_sdbd_andat(cpustate, 3,dest);		break;
	case 0x3a0: /* 1 110 100 xxx */ cp1610_sdbd_andat_i(cpustate, 4,dest);	break;
	case 0x3a8: /* 1 110 101 xxx */ cp1610_sdbd_andat_i(cpustate, 5,dest);	break;
	case 0x3b0: /* 1 110 110 xxx */ cp1610_sdbd_andat_d(cpustate, 6,dest);	break; /* ??? */
	case 0x3b8: /* 1 110 111 xxx */ cp1610_sdbd_andi(cpustate, dest);			break;

	case 0x3c0: /* 1 110 000 xxx */ cp1610_sdbd_xorat(cpustate, 0,dest);		break;
	case 0x3c8: /* 1 110 001 xxx */ cp1610_sdbd_xorat(cpustate, 1,dest);		break;
	case 0x3d0: /* 1 110 010 xxx */ cp1610_sdbd_xorat(cpustate, 2,dest);		break;
	case 0x3d8: /* 1 110 011 xxx */ cp1610_sdbd_xorat(cpustate, 3,dest);		break;
	case 0x3e0: /* 1 110 100 xxx */ cp1610_sdbd_xorat_i(cpustate, 4,dest);	break;
	case 0x3e8: /* 1 110 101 xxx */ cp1610_sdbd_xorat_i(cpustate, 5,dest);	break;
	case 0x3f0: /* 1 110 110 xxx */ cp1610_sdbd_xorat_d(cpustate, 6,dest);	break; /* ??? */
	case 0x3f8: /* 1 110 111 xxx */ cp1610_sdbd_xori(cpustate, dest);			break;
	default:						cp1610_illegal(cpustate); break;
	}
}

static void cp1610_do_jumps(cp1610_state *cpustate)
{
	UINT16 jumptype, arg1, arg2, addr;

	arg1 = cp1610_readop(cpustate->r[7]);
    cpustate->r[7]++;

	arg2 = cp1610_readop(cpustate->r[7]);
    cpustate->r[7]++;

    /*logerror("jumps: pc = 0x%04x, arg1 = 0x%04x, arg2 = 0x%04x\n",cpustate->r[7]-1,arg1,arg2);*/
	jumptype = arg1 & 0x303;
	addr = ((arg1 & 0x0fc) << 8) | (arg2 & 0x3ff);

    switch( jumptype )
    {
	case 0x000: /* 0 0xx xxx x00 */	cp1610_jsr(cpustate, 4,addr);		break;
	case 0x001: /* 0 0xx xxx x01 */	cp1610_jsre(cpustate, 4,addr);	break;
	case 0x002: /* 0 0xx xxx x10 */	cp1610_jsrd(cpustate, 4,addr);	break;
	case 0x003: /* 0 0xx xxx x11 */	cp1610_illegal(cpustate);		break;

	case 0x100: /* 0 1xx xxx x00 */	cp1610_jsr(cpustate, 5,addr);		break;
	case 0x101: /* 0 1xx xxx x01 */	cp1610_jsre(cpustate, 5,addr);	break;
	case 0x102: /* 0 1xx xxx x10 */	cp1610_jsrd(cpustate, 5,addr);	break;
	case 0x103: /* 0 1xx xxx x11 */	cp1610_illegal(cpustate);		break;

	case 0x200: /* 1 0xx xxx x00 */	cp1610_jsr(cpustate, 6,addr);		break;
	case 0x201: /* 1 0xx xxx x01 */	cp1610_jsre(cpustate, 6,addr);	break;
	case 0x202: /* 1 0xx xxx x10 */	cp1610_jsrd(cpustate, 6,addr);	break;
	case 0x203: /* 1 0xx xxx x11 */	cp1610_illegal(cpustate);		break;

	case 0x300: /* 1 1xx xxx x00 */	cp1610_j(cpustate, addr);			break;
	case 0x301: /* 1 1xx xxx x01 */	cp1610_je(cpustate, addr);		break;
	case 0x302: /* 1 1xx xxx x10 */	cp1610_jd(cpustate, addr);		break;
	case 0x303: /* 1 1xx xxx x11 */	cp1610_illegal(cpustate);		break;
	}

	cpustate->icount -= 12;
}

/* Execute cycles - returns number of cycles actually run */
static CPU_EXECUTE( cp1610 )
{
	cp1610_state *cpustate = get_safe_token(device);
	UINT16 opcode;

	cpustate->icount = cycles;

    do
    {
        debugger_instruction_hook(device, cpustate->r[7]);

		cpustate->mask_interrupts = 0;

        opcode = cp1610_readop(cpustate->r[7]);
        cpustate->r[7]++;
#if 0
		logerror("PC:0x%04x, opcode = 0x%03x, ",cpustate->r[7]-1,opcode);
		logerror("R0:0x%04x, ",cpustate->r[0]);
		logerror("R1:0x%04x, ",cpustate->r[1]);
		logerror("R2:0x%04x, ",cpustate->r[2]);
		logerror("R3:0x%04x, ",cpustate->r[3]);
		logerror("R4:0x%04x, ",cpustate->r[4]);
		logerror("R5:0x%04x, ",cpustate->r[5]);
		logerror("R6:0x%04x\n",cpustate->r[6]);
#endif

		switch( opcode )
        {
		/* opcode  bitmask */
		case 0x000: /* 0 000 000 000 */	cp1610_hlt(cpustate);		break; /* TBD */
		case 0x001: /* 0 000 000 001 */	cp1610_do_sdbd(cpustate);	break;
		case 0x002: /* 0 000 000 010 */	cp1610_eis(cpustate);		break; /* TBD */
		case 0x003: /* 0 000 000 011 */	cp1610_dis(cpustate);		break; /* TBD */
		case 0x004: /* 0 000 000 100 */	cp1610_do_jumps(cpustate);	break;
		case 0x005: /* 0 000 000 101 */	cp1610_tci(cpustate);		break; /* TBD */
		case 0x006: /* 0 000 000 110 */	cp1610_clrc(cpustate);		break;
		case 0x007: /* 0 000 000 111 */	cp1610_setc(cpustate);		break;

		case 0x008: /* 0 000 001 000 */	cp1610_incr(cpustate, 0);		break;
		case 0x009: /* 0 000 001 001 */	cp1610_incr(cpustate, 1);		break;
		case 0x00a: /* 0 000 001 010 */	cp1610_incr(cpustate, 2);		break;
		case 0x00b: /* 0 000 001 011 */	cp1610_incr(cpustate, 3);		break;
		case 0x00c: /* 0 000 001 100 */	cp1610_incr(cpustate, 4);		break;
		case 0x00d: /* 0 000 001 101 */	cp1610_incr(cpustate, 5);		break;
		case 0x00e: /* 0 000 001 110 */	cp1610_incr(cpustate, 6);		break;
		case 0x00f: /* 0 000 001 111 */	cp1610_incr(cpustate, 7);		break;

		case 0x010: /* 0 000 010 000 */	cp1610_decr(cpustate, 0);		break;
		case 0x011: /* 0 000 010 001 */	cp1610_decr(cpustate, 1);		break;
		case 0x012: /* 0 000 010 010 */	cp1610_decr(cpustate, 2);		break;
		case 0x013: /* 0 000 010 011 */	cp1610_decr(cpustate, 3);		break;
		case 0x014: /* 0 000 010 100 */	cp1610_decr(cpustate, 4);		break;
		case 0x015: /* 0 000 010 101 */	cp1610_decr(cpustate, 5);		break;
		case 0x016: /* 0 000 010 110 */	cp1610_decr(cpustate, 6);		break;
		case 0x017: /* 0 000 010 111 */	cp1610_decr(cpustate, 7);		break;

		case 0x018: /* 0 000 011 000 */	cp1610_comr(cpustate, 0);		break;
		case 0x019: /* 0 000 011 001 */	cp1610_comr(cpustate, 1);		break;
		case 0x01a: /* 0 000 011 010 */	cp1610_comr(cpustate, 2);		break;
		case 0x01b: /* 0 000 011 011 */	cp1610_comr(cpustate, 3);		break;
		case 0x01c: /* 0 000 011 100 */	cp1610_comr(cpustate, 4);		break;
		case 0x01d: /* 0 000 011 101 */	cp1610_comr(cpustate, 5);		break;
		case 0x01e: /* 0 000 011 110 */	cp1610_comr(cpustate, 6);		break;
		case 0x01f: /* 0 000 011 111 */	cp1610_comr(cpustate, 7);		break;

		case 0x020: /* 0 000 100 000 */	cp1610_negr(cpustate, 0);		break;
		case 0x021: /* 0 000 100 001 */	cp1610_negr(cpustate, 1);		break;
		case 0x022: /* 0 000 100 010 */	cp1610_negr(cpustate, 2);		break;
		case 0x023: /* 0 000 100 011 */	cp1610_negr(cpustate, 3);		break;
		case 0x024: /* 0 000 100 100 */	cp1610_negr(cpustate, 4);		break;
		case 0x025: /* 0 000 100 101 */	cp1610_negr(cpustate, 5);		break;
		case 0x026: /* 0 000 100 110 */	cp1610_negr(cpustate, 6);		break;
		case 0x027: /* 0 000 100 111 */	cp1610_negr(cpustate, 7);		break;

		case 0x028: /* 0 000 101 000 */	cp1610_adcr(cpustate, 0);		break;
		case 0x029: /* 0 000 101 001 */	cp1610_adcr(cpustate, 1);		break;
		case 0x02a: /* 0 000 101 010 */	cp1610_adcr(cpustate, 2);		break;
		case 0x02b: /* 0 000 101 011 */	cp1610_adcr(cpustate, 3);		break;
		case 0x02c: /* 0 000 101 100 */	cp1610_adcr(cpustate, 4);		break;
		case 0x02d: /* 0 000 101 101 */	cp1610_adcr(cpustate, 5);		break;
		case 0x02e: /* 0 000 101 110 */	cp1610_adcr(cpustate, 6);		break;
		case 0x02f: /* 0 000 101 111 */	cp1610_adcr(cpustate, 7);		break;

		case 0x030: /* 0 000 110 000 */ cp1610_gswd(cpustate, 0);		break;
		case 0x031: /* 0 000 110 001 */ cp1610_gswd(cpustate, 1);		break;
		case 0x032: /* 0 000 110 010 */ cp1610_gswd(cpustate, 2);		break;
		case 0x033: /* 0 000 110 011 */ cp1610_gswd(cpustate, 3);		break;
		case 0x034: /* 0 000 110 100 */ cp1610_nop(cpustate);		break;
		case 0x035: /* 0 000 110 101 */ cp1610_nop(cpustate);		break;
		case 0x036: /* 0 000 110 110 */ cp1610_sin(cpustate);		break; /* TBD */
		case 0x037: /* 0 000 110 111 */ cp1610_sin(cpustate);		break; /* TBD */

		case 0x038: /* 0 000 111 000 */	cp1610_rswd(cpustate, 0);		break;
		case 0x039: /* 0 000 111 001 */	cp1610_rswd(cpustate, 1);		break;
		case 0x03a: /* 0 000 111 010 */	cp1610_rswd(cpustate, 2);		break;
		case 0x03b: /* 0 000 111 011 */	cp1610_rswd(cpustate, 3);		break;
		case 0x03c: /* 0 000 111 100 */	cp1610_rswd(cpustate, 4);		break;
		case 0x03d: /* 0 000 111 101 */	cp1610_rswd(cpustate, 5);		break;
		case 0x03e: /* 0 000 111 110 */	cp1610_rswd(cpustate, 6);		break;
		case 0x03f: /* 0 000 111 111 */	cp1610_rswd(cpustate, 7);		break;

		case 0x040: /* 0 001 000 000 */ cp1610_swap(cpustate, 0);		break;
		case 0x041: /* 0 001 000 001 */ cp1610_swap(cpustate, 1);		break;
		case 0x042: /* 0 001 000 010 */ cp1610_swap(cpustate, 2);		break;
		case 0x043: /* 0 001 000 011 */ cp1610_swap(cpustate, 3);		break;
		case 0x044: /* 0 001 000 100 */ cp1610_dswap(cpustate, 0);	break;
		case 0x045: /* 0 001 000 101 */ cp1610_dswap(cpustate, 1);	break;
		case 0x046: /* 0 001 000 110 */ cp1610_dswap(cpustate, 2);	break;
		case 0x047: /* 0 001 000 111 */ cp1610_dswap(cpustate, 3);	break;

		case 0x048: /* 0 001 001 000 */ cp1610_sll_1(cpustate, 0);	break;
		case 0x049: /* 0 001 001 001 */ cp1610_sll_1(cpustate, 1);	break;
		case 0x04a: /* 0 001 001 010 */ cp1610_sll_1(cpustate, 2);	break;
		case 0x04b: /* 0 001 001 011 */ cp1610_sll_1(cpustate, 3);	break;
		case 0x04c: /* 0 001 001 100 */ cp1610_sll_2(cpustate, 0);	break;
		case 0x04d: /* 0 001 001 101 */ cp1610_sll_2(cpustate, 1);	break;
		case 0x04e: /* 0 001 001 110 */ cp1610_sll_2(cpustate, 2);	break;
		case 0x04f: /* 0 001 001 111 */ cp1610_sll_2(cpustate, 3);	break;

		case 0x050: /* 0 001 010 000 */ cp1610_rlc_1(cpustate, 0);	break;
		case 0x051: /* 0 001 010 001 */ cp1610_rlc_1(cpustate, 1);	break;
		case 0x052: /* 0 001 010 010 */ cp1610_rlc_1(cpustate, 2);	break;
		case 0x053: /* 0 001 010 011 */ cp1610_rlc_1(cpustate, 3);	break;
		case 0x054: /* 0 001 010 100 */ cp1610_rlc_2(cpustate, 0);	break;
		case 0x055: /* 0 001 010 101 */ cp1610_rlc_2(cpustate, 1);	break;
		case 0x056: /* 0 001 010 110 */ cp1610_rlc_2(cpustate, 2);	break;
		case 0x057: /* 0 001 010 111 */ cp1610_rlc_2(cpustate, 3);	break;

		case 0x058: /* 0 001 011 000 */ cp1610_sllc_1(cpustate, 0);	break;
		case 0x059: /* 0 001 011 001 */ cp1610_sllc_1(cpustate, 1);	break;
		case 0x05a: /* 0 001 011 010 */ cp1610_sllc_1(cpustate, 2);	break;
		case 0x05b: /* 0 001 011 011 */ cp1610_sllc_1(cpustate, 3);	break;
		case 0x05c: /* 0 001 011 100 */ cp1610_sllc_2(cpustate, 0);	break;
		case 0x05d: /* 0 001 011 101 */ cp1610_sllc_2(cpustate, 1);	break;
		case 0x05e: /* 0 001 011 110 */ cp1610_sllc_2(cpustate, 2);	break;
		case 0x05f: /* 0 001 011 111 */ cp1610_sllc_2(cpustate, 3);	break;

		case 0x060: /* 0 001 100 000 */ cp1610_slr_1(cpustate, 0);	break;
		case 0x061: /* 0 001 100 001 */ cp1610_slr_1(cpustate, 1);	break;
		case 0x062: /* 0 001 100 010 */ cp1610_slr_1(cpustate, 2);	break;
		case 0x063: /* 0 001 100 011 */ cp1610_slr_1(cpustate, 3);	break;
		case 0x064: /* 0 001 100 100 */ cp1610_slr_2(cpustate, 0);	break;
		case 0x065: /* 0 001 100 101 */ cp1610_slr_2(cpustate, 1);	break;
		case 0x066: /* 0 001 100 110 */ cp1610_slr_2(cpustate, 2);	break;
		case 0x067: /* 0 001 100 111 */ cp1610_slr_2(cpustate, 3);	break;

		case 0x068: /* 0 001 101 000 */ cp1610_sar_1(cpustate, 0);	break;
		case 0x069: /* 0 001 101 001 */ cp1610_sar_1(cpustate, 1);	break;
		case 0x06a: /* 0 001 101 010 */ cp1610_sar_1(cpustate, 2);	break;
		case 0x06b: /* 0 001 101 011 */ cp1610_sar_1(cpustate, 3);	break;
		case 0x06c: /* 0 001 101 100 */ cp1610_sar_2(cpustate, 0);	break;
		case 0x06d: /* 0 001 101 101 */ cp1610_sar_2(cpustate, 1);	break;
		case 0x06e: /* 0 001 101 110 */ cp1610_sar_2(cpustate, 2);	break;
		case 0x06f: /* 0 001 101 111 */ cp1610_sar_2(cpustate, 3);	break;

		case 0x070: /* 0 001 110 000 */ cp1610_rrc_1(cpustate, 0);	break;
		case 0x071: /* 0 001 110 001 */ cp1610_rrc_1(cpustate, 1);	break;
		case 0x072: /* 0 001 110 010 */ cp1610_rrc_1(cpustate, 2);	break;
		case 0x073: /* 0 001 110 011 */ cp1610_rrc_1(cpustate, 3);	break;
		case 0x074: /* 0 001 110 100 */ cp1610_rrc_2(cpustate, 0);	break;
		case 0x075: /* 0 001 110 101 */ cp1610_rrc_2(cpustate, 1);	break;
		case 0x076: /* 0 001 110 110 */ cp1610_rrc_2(cpustate, 2);	break;
		case 0x077: /* 0 001 110 111 */ cp1610_rrc_2(cpustate, 3);	break;

		case 0x078: /* 0 001 111 000 */ cp1610_sarc_1(cpustate, 0);	break;
		case 0x079: /* 0 001 111 001 */ cp1610_sarc_1(cpustate, 1);	break;
		case 0x07a: /* 0 001 111 010 */ cp1610_sarc_1(cpustate, 2);	break;
		case 0x07b: /* 0 001 111 011 */ cp1610_sarc_1(cpustate, 3);	break;
		case 0x07c: /* 0 001 111 100 */ cp1610_sarc_2(cpustate, 0);	break;
		case 0x07d: /* 0 001 111 101 */ cp1610_sarc_2(cpustate, 1);	break;
		case 0x07e: /* 0 001 111 110 */ cp1610_sarc_2(cpustate, 2);	break;
		case 0x07f: /* 0 001 111 111 */ cp1610_sarc_2(cpustate, 3);	break;

		case 0x080: /* 0 010 000 000 */	cp1610_tstr(cpustate, 0);		break;
		case 0x081: /* 0 010 000 001 */	cp1610_movr(cpustate, 0,1);	break;
		case 0x082: /* 0 010 000 010 */	cp1610_movr(cpustate, 0,2);	break;
		case 0x083: /* 0 010 000 011 */	cp1610_movr(cpustate, 0,3);	break;
		case 0x084: /* 0 010 000 100 */	cp1610_movr(cpustate, 0,4);	break;
		case 0x085: /* 0 010 000 101 */	cp1610_movr(cpustate, 0,5);	break;
		case 0x086: /* 0 010 000 110 */	cp1610_movr(cpustate, 0,6);	break;
		case 0x087: /* 0 010 000 111 */	cp1610_movr(cpustate, 0,7);	break; /* jr */

		case 0x088: /* 0 010 001 000 */	cp1610_movr(cpustate, 1,0);	break;
		case 0x089: /* 0 010 001 001 */	cp1610_tstr(cpustate, 1);		break;
		case 0x08a: /* 0 010 001 010 */	cp1610_movr(cpustate, 1,2);	break;
		case 0x08b: /* 0 010 001 011 */	cp1610_movr(cpustate, 1,3);	break;
		case 0x08c: /* 0 010 001 100 */	cp1610_movr(cpustate, 1,4);	break;
		case 0x08d: /* 0 010 001 101 */	cp1610_movr(cpustate, 1,5);	break;
		case 0x08e: /* 0 010 001 110 */	cp1610_movr(cpustate, 1,6);	break;
		case 0x08f: /* 0 010 001 111 */	cp1610_movr(cpustate, 1,7);	break; /* jr */

		case 0x090: /* 0 010 010 000 */	cp1610_movr(cpustate, 2,0);	break;
		case 0x091: /* 0 010 010 001 */	cp1610_movr(cpustate, 2,1);	break;
		case 0x092: /* 0 010 010 010 */	cp1610_tstr(cpustate, 2);		break;
		case 0x093: /* 0 010 010 011 */	cp1610_movr(cpustate, 2,3);	break;
		case 0x094: /* 0 010 010 100 */	cp1610_movr(cpustate, 2,4);	break;
		case 0x095: /* 0 010 010 101 */	cp1610_movr(cpustate, 2,5);	break;
		case 0x096: /* 0 010 010 110 */	cp1610_movr(cpustate, 2,6);	break;
		case 0x097: /* 0 010 010 111 */	cp1610_movr(cpustate, 2,7);	break; /* jr */

		case 0x098: /* 0 010 011 000 */	cp1610_movr(cpustate, 3,0);	break;
		case 0x099: /* 0 010 011 001 */	cp1610_movr(cpustate, 3,1);	break;
		case 0x09a: /* 0 010 011 010 */	cp1610_movr(cpustate, 3,2);	break;
		case 0x09b: /* 0 010 011 011 */	cp1610_tstr(cpustate, 3);		break;
		case 0x09c: /* 0 010 011 100 */	cp1610_movr(cpustate, 3,4);	break;
		case 0x09d: /* 0 010 011 101 */	cp1610_movr(cpustate, 3,5);	break;
		case 0x09e: /* 0 010 011 110 */	cp1610_movr(cpustate, 3,6);	break;
		case 0x09f: /* 0 010 011 111 */	cp1610_movr(cpustate, 3,7);	break; /* jr */

		case 0x0a0: /* 0 010 100 000 */	cp1610_movr(cpustate, 4,0);	break;
		case 0x0a1: /* 0 010 100 001 */	cp1610_movr(cpustate, 4,1);	break;
		case 0x0a2: /* 0 010 100 010 */	cp1610_movr(cpustate, 4,2);	break;
		case 0x0a3: /* 0 010 100 011 */	cp1610_movr(cpustate, 4,3);	break;
		case 0x0a4: /* 0 010 100 100 */	cp1610_tstr(cpustate, 4);		break;
		case 0x0a5: /* 0 010 100 101 */	cp1610_movr(cpustate, 4,5);	break;
		case 0x0a6: /* 0 010 100 110 */	cp1610_movr(cpustate, 4,6);	break;
		case 0x0a7: /* 0 010 100 111 */	cp1610_movr(cpustate, 4,7);	break; /* jr */

		case 0x0a8: /* 0 010 101 000 */	cp1610_movr(cpustate, 5,0);	break;
		case 0x0a9: /* 0 010 101 001 */	cp1610_movr(cpustate, 5,1);	break;
		case 0x0aa: /* 0 010 101 010 */	cp1610_movr(cpustate, 5,2);	break;
		case 0x0ab: /* 0 010 101 011 */	cp1610_movr(cpustate, 5,3);	break;
		case 0x0ac: /* 0 010 101 100 */	cp1610_movr(cpustate, 5,4);	break;
		case 0x0ad: /* 0 010 101 101 */	cp1610_tstr(cpustate, 5);		break;
		case 0x0ae: /* 0 010 101 110 */	cp1610_movr(cpustate, 5,6);	break;
		case 0x0af: /* 0 010 101 111 */	cp1610_movr(cpustate, 5,7);	break; /* jr */

		case 0x0b0: /* 0 010 110 000 */	cp1610_movr(cpustate, 6,0);	break;
		case 0x0b1: /* 0 010 110 001 */	cp1610_movr(cpustate, 6,1);	break;
		case 0x0b2: /* 0 010 110 010 */	cp1610_movr(cpustate, 6,2);	break;
		case 0x0b3: /* 0 010 110 011 */	cp1610_movr(cpustate, 6,3);	break;
		case 0x0b4: /* 0 010 110 100 */	cp1610_movr(cpustate, 6,4);	break;
		case 0x0b5: /* 0 010 110 101 */	cp1610_movr(cpustate, 6,5);	break;
		case 0x0b6: /* 0 010 110 110 */	cp1610_tstr(cpustate, 6);		break;
		case 0x0b7: /* 0 010 110 111 */	cp1610_movr(cpustate, 6,7);	break; /* jr */

		case 0x0b8: /* 0 010 111 000 */	cp1610_movr(cpustate, 7,0);	break;
		case 0x0b9: /* 0 010 111 001 */	cp1610_movr(cpustate, 7,1);	break;
		case 0x0ba: /* 0 010 111 010 */	cp1610_movr(cpustate, 7,2);	break;
		case 0x0bb: /* 0 010 111 011 */	cp1610_movr(cpustate, 7,3);	break;
		case 0x0bc: /* 0 010 111 100 */	cp1610_movr(cpustate, 7,4);	break;
		case 0x0bd: /* 0 010 111 101 */	cp1610_movr(cpustate, 7,5);	break;
		case 0x0be: /* 0 010 111 110 */	cp1610_movr(cpustate, 7,6);	break;
		case 0x0bf: /* 0 010 111 111 */	cp1610_tstr(cpustate, 7);		break;

		case 0x0c0: /* 0 011 000 000 */	cp1610_addr(cpustate, 0,0);	break;
		case 0x0c1: /* 0 011 000 001 */	cp1610_addr(cpustate, 0,1);	break;
		case 0x0c2: /* 0 011 000 010 */	cp1610_addr(cpustate, 0,2);	break;
		case 0x0c3: /* 0 011 000 011 */	cp1610_addr(cpustate, 0,3);	break;
		case 0x0c4: /* 0 011 000 100 */	cp1610_addr(cpustate, 0,4);	break;
		case 0x0c5: /* 0 011 000 101 */	cp1610_addr(cpustate, 0,5);	break;
		case 0x0c6: /* 0 011 000 110 */	cp1610_addr(cpustate, 0,6);	break;
		case 0x0c7: /* 0 011 000 111 */	cp1610_addr(cpustate, 0,7);	break;

		case 0x0c8: /* 0 011 001 000 */	cp1610_addr(cpustate, 1,0);	break;
		case 0x0c9: /* 0 011 001 001 */	cp1610_addr(cpustate, 1,1);	break;
		case 0x0ca: /* 0 011 001 010 */	cp1610_addr(cpustate, 1,2);	break;
		case 0x0cb: /* 0 011 001 011 */	cp1610_addr(cpustate, 1,3);	break;
		case 0x0cc: /* 0 011 001 100 */	cp1610_addr(cpustate, 1,4);	break;
		case 0x0cd: /* 0 011 001 101 */	cp1610_addr(cpustate, 1,5);	break;
		case 0x0ce: /* 0 011 001 110 */	cp1610_addr(cpustate, 1,6);	break;
		case 0x0cf: /* 0 011 001 111 */	cp1610_addr(cpustate, 1,7);	break;

		case 0x0d0: /* 0 011 010 000 */	cp1610_addr(cpustate, 2,0);	break;
		case 0x0d1: /* 0 011 010 001 */	cp1610_addr(cpustate, 2,1);	break;
		case 0x0d2: /* 0 011 010 010 */	cp1610_addr(cpustate, 2,2);	break;
		case 0x0d3: /* 0 011 010 011 */	cp1610_addr(cpustate, 2,3);	break;
		case 0x0d4: /* 0 011 010 100 */	cp1610_addr(cpustate, 2,4);	break;
		case 0x0d5: /* 0 011 010 101 */	cp1610_addr(cpustate, 2,5);	break;
		case 0x0d6: /* 0 011 010 110 */	cp1610_addr(cpustate, 2,6);	break;
		case 0x0d7: /* 0 011 010 111 */	cp1610_addr(cpustate, 2,7);	break;

		case 0x0d8: /* 0 011 011 000 */	cp1610_addr(cpustate, 3,0);	break;
		case 0x0d9: /* 0 011 011 001 */	cp1610_addr(cpustate, 3,1);	break;
		case 0x0da: /* 0 011 011 010 */	cp1610_addr(cpustate, 3,2);	break;
		case 0x0db: /* 0 011 011 011 */	cp1610_addr(cpustate, 3,3);	break;
		case 0x0dc: /* 0 011 011 100 */	cp1610_addr(cpustate, 3,4);	break;
		case 0x0dd: /* 0 011 011 101 */	cp1610_addr(cpustate, 3,5);	break;
		case 0x0de: /* 0 011 011 110 */	cp1610_addr(cpustate, 3,6);	break;
		case 0x0df: /* 0 011 011 111 */	cp1610_addr(cpustate, 3,7);	break;

		case 0x0e0: /* 0 011 100 000 */	cp1610_addr(cpustate, 4,0);	break;
		case 0x0e1: /* 0 011 100 001 */	cp1610_addr(cpustate, 4,1);	break;
		case 0x0e2: /* 0 011 100 010 */	cp1610_addr(cpustate, 4,2);	break;
		case 0x0e3: /* 0 011 100 011 */	cp1610_addr(cpustate, 4,3);	break;
		case 0x0e4: /* 0 011 100 100 */	cp1610_addr(cpustate, 4,4);	break;
		case 0x0e5: /* 0 011 100 101 */	cp1610_addr(cpustate, 4,5);	break;
		case 0x0e6: /* 0 011 100 110 */	cp1610_addr(cpustate, 4,6);	break;
		case 0x0e7: /* 0 011 100 111 */	cp1610_addr(cpustate, 4,7);	break;

		case 0x0e8: /* 0 011 101 000 */	cp1610_addr(cpustate, 5,0);	break;
		case 0x0e9: /* 0 011 101 001 */	cp1610_addr(cpustate, 5,1);	break;
		case 0x0ea: /* 0 011 101 010 */	cp1610_addr(cpustate, 5,2);	break;
		case 0x0eb: /* 0 011 101 011 */	cp1610_addr(cpustate, 5,3);	break;
		case 0x0ec: /* 0 011 101 100 */	cp1610_addr(cpustate, 5,4);	break;
		case 0x0ed: /* 0 011 101 101 */	cp1610_addr(cpustate, 5,5);	break;
		case 0x0ee: /* 0 011 101 110 */	cp1610_addr(cpustate, 5,6);	break;
		case 0x0ef: /* 0 011 101 111 */	cp1610_addr(cpustate, 5,7);	break;

		case 0x0f0: /* 0 011 110 000 */	cp1610_addr(cpustate, 6,0);	break;
		case 0x0f1: /* 0 011 110 001 */	cp1610_addr(cpustate, 6,1);	break;
		case 0x0f2: /* 0 011 110 010 */	cp1610_addr(cpustate, 6,2);	break;
		case 0x0f3: /* 0 011 110 011 */	cp1610_addr(cpustate, 6,3);	break;
		case 0x0f4: /* 0 011 110 100 */	cp1610_addr(cpustate, 6,4);	break;
		case 0x0f5: /* 0 011 110 101 */	cp1610_addr(cpustate, 6,5);	break;
		case 0x0f6: /* 0 011 110 110 */	cp1610_addr(cpustate, 6,6);	break;
		case 0x0f7: /* 0 011 110 111 */	cp1610_addr(cpustate, 6,7);	break;

		case 0x0f8: /* 0 011 111 000 */	cp1610_addr(cpustate, 7,0);	break;
		case 0x0f9: /* 0 011 111 001 */	cp1610_addr(cpustate, 7,1);	break;
		case 0x0fa: /* 0 011 111 010 */	cp1610_addr(cpustate, 7,2);	break;
		case 0x0fb: /* 0 011 111 011 */	cp1610_addr(cpustate, 7,3);	break;
		case 0x0fc: /* 0 011 111 100 */	cp1610_addr(cpustate, 7,4);	break;
		case 0x0fd: /* 0 011 111 101 */	cp1610_addr(cpustate, 7,5);	break;
		case 0x0fe: /* 0 011 111 110 */	cp1610_addr(cpustate, 7,6);	break;
		case 0x0ff: /* 0 011 111 111 */	cp1610_addr(cpustate, 7,7);	break;

		case 0x100: /* 0 100 000 000 */	cp1610_subr(cpustate, 0,0);	break;
		case 0x101: /* 0 100 000 001 */	cp1610_subr(cpustate, 0,1);	break;
		case 0x102: /* 0 100 000 010 */	cp1610_subr(cpustate, 0,2);	break;
		case 0x103: /* 0 100 000 011 */	cp1610_subr(cpustate, 0,3);	break;
		case 0x104: /* 0 100 000 100 */	cp1610_subr(cpustate, 0,4);	break;
		case 0x105: /* 0 100 000 101 */	cp1610_subr(cpustate, 0,5);	break;
		case 0x106: /* 0 100 000 110 */	cp1610_subr(cpustate, 0,6);	break;
		case 0x107: /* 0 100 000 111 */	cp1610_subr(cpustate, 0,7);	break;

		case 0x108: /* 0 100 001 000 */	cp1610_subr(cpustate, 1,0);	break;
		case 0x109: /* 0 100 001 001 */	cp1610_subr(cpustate, 1,1);	break;
		case 0x10a: /* 0 100 001 010 */	cp1610_subr(cpustate, 1,2);	break;
		case 0x10b: /* 0 100 001 011 */	cp1610_subr(cpustate, 1,3);	break;
		case 0x10c: /* 0 100 001 100 */	cp1610_subr(cpustate, 1,4);	break;
		case 0x10d: /* 0 100 001 101 */	cp1610_subr(cpustate, 1,5);	break;
		case 0x10e: /* 0 100 001 110 */	cp1610_subr(cpustate, 1,6);	break;
		case 0x10f: /* 0 100 001 111 */	cp1610_subr(cpustate, 1,7);	break;

		case 0x110: /* 0 100 010 000 */	cp1610_subr(cpustate, 2,0);	break;
		case 0x111: /* 0 100 010 001 */	cp1610_subr(cpustate, 2,1);	break;
		case 0x112: /* 0 100 010 010 */	cp1610_subr(cpustate, 2,2);	break;
		case 0x113: /* 0 100 010 011 */	cp1610_subr(cpustate, 2,3);	break;
		case 0x114: /* 0 100 010 100 */	cp1610_subr(cpustate, 2,4);	break;
		case 0x115: /* 0 100 010 101 */	cp1610_subr(cpustate, 2,5);	break;
		case 0x116: /* 0 100 010 110 */	cp1610_subr(cpustate, 2,6);	break;
		case 0x117: /* 0 100 010 111 */	cp1610_subr(cpustate, 2,7);	break;

		case 0x118: /* 0 100 011 000 */	cp1610_subr(cpustate, 3,0);	break;
		case 0x119: /* 0 100 011 001 */	cp1610_subr(cpustate, 3,1);	break;
		case 0x11a: /* 0 100 011 010 */	cp1610_subr(cpustate, 3,2);	break;
		case 0x11b: /* 0 100 011 011 */	cp1610_subr(cpustate, 3,3);	break;
		case 0x11c: /* 0 100 011 100 */	cp1610_subr(cpustate, 3,4);	break;
		case 0x11d: /* 0 100 011 101 */	cp1610_subr(cpustate, 3,5);	break;
		case 0x11e: /* 0 100 011 110 */	cp1610_subr(cpustate, 3,6);	break;
		case 0x11f: /* 0 100 011 111 */	cp1610_subr(cpustate, 3,7);	break;

		case 0x120: /* 0 100 100 000 */	cp1610_subr(cpustate, 4,0);	break;
		case 0x121: /* 0 100 100 001 */	cp1610_subr(cpustate, 4,1);	break;
		case 0x122: /* 0 100 100 010 */	cp1610_subr(cpustate, 4,2);	break;
		case 0x123: /* 0 100 100 011 */	cp1610_subr(cpustate, 4,3);	break;
		case 0x124: /* 0 100 100 100 */	cp1610_subr(cpustate, 4,4);	break;
		case 0x125: /* 0 100 100 101 */	cp1610_subr(cpustate, 4,5);	break;
		case 0x126: /* 0 100 100 110 */	cp1610_subr(cpustate, 4,6);	break;
		case 0x127: /* 0 100 100 111 */	cp1610_subr(cpustate, 4,7);	break;

		case 0x128: /* 0 100 101 000 */	cp1610_subr(cpustate, 5,0);	break;
		case 0x129: /* 0 100 101 001 */	cp1610_subr(cpustate, 5,1);	break;
		case 0x12a: /* 0 100 101 010 */	cp1610_subr(cpustate, 5,2);	break;
		case 0x12b: /* 0 100 101 011 */	cp1610_subr(cpustate, 5,3);	break;
		case 0x12c: /* 0 100 101 100 */	cp1610_subr(cpustate, 5,4);	break;
		case 0x12d: /* 0 100 101 101 */	cp1610_subr(cpustate, 5,5);	break;
		case 0x12e: /* 0 100 101 110 */	cp1610_subr(cpustate, 5,6);	break;
		case 0x12f: /* 0 100 101 111 */	cp1610_subr(cpustate, 5,7);	break;

		case 0x130: /* 0 100 110 000 */	cp1610_subr(cpustate, 6,0);	break;
		case 0x131: /* 0 100 110 001 */	cp1610_subr(cpustate, 6,1);	break;
		case 0x132: /* 0 100 110 010 */	cp1610_subr(cpustate, 6,2);	break;
		case 0x133: /* 0 100 110 011 */	cp1610_subr(cpustate, 6,3);	break;
		case 0x134: /* 0 100 110 100 */	cp1610_subr(cpustate, 6,4);	break;
		case 0x135: /* 0 100 110 101 */	cp1610_subr(cpustate, 6,5);	break;
		case 0x136: /* 0 100 110 110 */	cp1610_subr(cpustate, 6,6);	break;
		case 0x137: /* 0 100 110 111 */	cp1610_subr(cpustate, 6,7);	break;

		case 0x138: /* 0 100 111 000 */	cp1610_subr(cpustate, 7,0);	break;
		case 0x139: /* 0 100 111 001 */	cp1610_subr(cpustate, 7,1);	break;
		case 0x13a: /* 0 100 111 010 */	cp1610_subr(cpustate, 7,2);	break;
		case 0x13b: /* 0 100 111 011 */	cp1610_subr(cpustate, 7,3);	break;
		case 0x13c: /* 0 100 111 100 */	cp1610_subr(cpustate, 7,4);	break;
		case 0x13d: /* 0 100 111 101 */	cp1610_subr(cpustate, 7,5);	break;
		case 0x13e: /* 0 100 111 110 */	cp1610_subr(cpustate, 7,6);	break;
		case 0x13f: /* 0 100 111 111 */	cp1610_subr(cpustate, 7,7);	break;

		case 0x140: /* 0 101 000 000 */	cp1610_cmpr(cpustate, 0,0);	break;
		case 0x141: /* 0 101 000 001 */	cp1610_cmpr(cpustate, 0,1);	break;
		case 0x142: /* 0 101 000 010 */	cp1610_cmpr(cpustate, 0,2);	break;
		case 0x143: /* 0 101 000 011 */	cp1610_cmpr(cpustate, 0,3);	break;
		case 0x144: /* 0 101 000 100 */	cp1610_cmpr(cpustate, 0,4);	break;
		case 0x145: /* 0 101 000 101 */	cp1610_cmpr(cpustate, 0,5);	break;
		case 0x146: /* 0 101 000 110 */	cp1610_cmpr(cpustate, 0,6);	break;
		case 0x147: /* 0 101 000 111 */	cp1610_cmpr(cpustate, 0,7);	break;

		case 0x148: /* 0 101 001 000 */	cp1610_cmpr(cpustate, 1,0);	break;
		case 0x149: /* 0 101 001 001 */	cp1610_cmpr(cpustate, 1,1);	break;
		case 0x14a: /* 0 101 001 010 */	cp1610_cmpr(cpustate, 1,2);	break;
		case 0x14b: /* 0 101 001 011 */	cp1610_cmpr(cpustate, 1,3);	break;
		case 0x14c: /* 0 101 001 100 */	cp1610_cmpr(cpustate, 1,4);	break;
		case 0x14d: /* 0 101 001 101 */	cp1610_cmpr(cpustate, 1,5);	break;
		case 0x14e: /* 0 101 001 110 */	cp1610_cmpr(cpustate, 1,6);	break;
		case 0x14f: /* 0 101 001 111 */	cp1610_cmpr(cpustate, 1,7);	break;

		case 0x150: /* 0 101 010 000 */	cp1610_cmpr(cpustate, 2,0);	break;
		case 0x151: /* 0 101 010 001 */	cp1610_cmpr(cpustate, 2,1);	break;
		case 0x152: /* 0 101 010 010 */	cp1610_cmpr(cpustate, 2,2);	break;
		case 0x153: /* 0 101 010 011 */	cp1610_cmpr(cpustate, 2,3);	break;
		case 0x154: /* 0 101 010 100 */	cp1610_cmpr(cpustate, 2,4);	break;
		case 0x155: /* 0 101 010 101 */	cp1610_cmpr(cpustate, 2,5);	break;
		case 0x156: /* 0 101 010 110 */	cp1610_cmpr(cpustate, 2,6);	break;
		case 0x157: /* 0 101 010 111 */	cp1610_cmpr(cpustate, 2,7);	break;

		case 0x158: /* 0 101 011 000 */	cp1610_cmpr(cpustate, 3,0);	break;
		case 0x159: /* 0 101 011 001 */	cp1610_cmpr(cpustate, 3,1);	break;
		case 0x15a: /* 0 101 011 010 */	cp1610_cmpr(cpustate, 3,2);	break;
		case 0x15b: /* 0 101 011 011 */	cp1610_cmpr(cpustate, 3,3);	break;
		case 0x15c: /* 0 101 011 100 */	cp1610_cmpr(cpustate, 3,4);	break;
		case 0x15d: /* 0 101 011 101 */	cp1610_cmpr(cpustate, 3,5);	break;
		case 0x15e: /* 0 101 011 110 */	cp1610_cmpr(cpustate, 3,6);	break;
		case 0x15f: /* 0 101 011 111 */	cp1610_cmpr(cpustate, 3,7);	break;

		case 0x160: /* 0 101 100 000 */	cp1610_cmpr(cpustate, 4,0);	break;
		case 0x161: /* 0 101 100 001 */	cp1610_cmpr(cpustate, 4,1);	break;
		case 0x162: /* 0 101 100 010 */	cp1610_cmpr(cpustate, 4,2);	break;
		case 0x163: /* 0 101 100 011 */	cp1610_cmpr(cpustate, 4,3);	break;
		case 0x164: /* 0 101 100 100 */	cp1610_cmpr(cpustate, 4,4);	break;
		case 0x165: /* 0 101 100 101 */	cp1610_cmpr(cpustate, 4,5);	break;
		case 0x166: /* 0 101 100 110 */	cp1610_cmpr(cpustate, 4,6);	break;
		case 0x167: /* 0 101 100 111 */	cp1610_cmpr(cpustate, 4,7);	break;

		case 0x168: /* 0 101 101 000 */	cp1610_cmpr(cpustate, 5,0);	break;
		case 0x169: /* 0 101 101 001 */	cp1610_cmpr(cpustate, 5,1);	break;
		case 0x16a: /* 0 101 101 010 */	cp1610_cmpr(cpustate, 5,2);	break;
		case 0x16b: /* 0 101 101 011 */	cp1610_cmpr(cpustate, 5,3);	break;
		case 0x16c: /* 0 101 101 100 */	cp1610_cmpr(cpustate, 5,4);	break;
		case 0x16d: /* 0 101 101 101 */	cp1610_cmpr(cpustate, 5,5);	break;
		case 0x16e: /* 0 101 101 110 */	cp1610_cmpr(cpustate, 5,6);	break;
		case 0x16f: /* 0 101 101 111 */	cp1610_cmpr(cpustate, 5,7);	break;

		case 0x170: /* 0 101 110 000 */	cp1610_cmpr(cpustate, 6,0);	break;
		case 0x171: /* 0 101 110 001 */	cp1610_cmpr(cpustate, 6,1);	break;
		case 0x172: /* 0 101 110 010 */	cp1610_cmpr(cpustate, 6,2);	break;
		case 0x173: /* 0 101 110 011 */	cp1610_cmpr(cpustate, 6,3);	break;
		case 0x174: /* 0 101 110 100 */	cp1610_cmpr(cpustate, 6,4);	break;
		case 0x175: /* 0 101 110 101 */	cp1610_cmpr(cpustate, 6,5);	break;
		case 0x176: /* 0 101 110 110 */	cp1610_cmpr(cpustate, 6,6);	break;
		case 0x177: /* 0 101 110 111 */	cp1610_cmpr(cpustate, 6,7);	break;

		case 0x178: /* 0 101 111 000 */	cp1610_cmpr(cpustate, 7,0);	break;
		case 0x179: /* 0 101 111 001 */	cp1610_cmpr(cpustate, 7,1);	break;
		case 0x17a: /* 0 101 111 010 */	cp1610_cmpr(cpustate, 7,2);	break;
		case 0x17b: /* 0 101 111 011 */	cp1610_cmpr(cpustate, 7,3);	break;
		case 0x17c: /* 0 101 111 100 */	cp1610_cmpr(cpustate, 7,4);	break;
		case 0x17d: /* 0 101 111 101 */	cp1610_cmpr(cpustate, 7,5);	break;
		case 0x17e: /* 0 101 111 110 */	cp1610_cmpr(cpustate, 7,6);	break;
		case 0x17f: /* 0 101 111 111 */	cp1610_cmpr(cpustate, 7,7);	break;

		case 0x180: /* 0 110 000 000 */	cp1610_andr(cpustate, 0,0);	break;
		case 0x181: /* 0 110 000 001 */	cp1610_andr(cpustate, 0,1);	break;
		case 0x182: /* 0 110 000 010 */	cp1610_andr(cpustate, 0,2);	break;
		case 0x183: /* 0 110 000 011 */	cp1610_andr(cpustate, 0,3);	break;
		case 0x184: /* 0 110 000 100 */	cp1610_andr(cpustate, 0,4);	break;
		case 0x185: /* 0 110 000 101 */	cp1610_andr(cpustate, 0,5);	break;
		case 0x186: /* 0 110 000 110 */	cp1610_andr(cpustate, 0,6);	break;
		case 0x187: /* 0 110 000 111 */	cp1610_andr(cpustate, 0,7);	break;

		case 0x188: /* 0 110 001 000 */	cp1610_andr(cpustate, 1,0);	break;
		case 0x189: /* 0 110 001 001 */	cp1610_andr(cpustate, 1,1);	break;
		case 0x18a: /* 0 110 001 010 */	cp1610_andr(cpustate, 1,2);	break;
		case 0x18b: /* 0 110 001 011 */	cp1610_andr(cpustate, 1,3);	break;
		case 0x18c: /* 0 110 001 100 */	cp1610_andr(cpustate, 1,4);	break;
		case 0x18d: /* 0 110 001 101 */	cp1610_andr(cpustate, 1,5);	break;
		case 0x18e: /* 0 110 001 110 */	cp1610_andr(cpustate, 1,6);	break;
		case 0x18f: /* 0 110 001 111 */	cp1610_andr(cpustate, 1,7);	break;

		case 0x190: /* 0 110 010 000 */	cp1610_andr(cpustate, 2,0);	break;
		case 0x191: /* 0 110 010 001 */	cp1610_andr(cpustate, 2,1);	break;
		case 0x192: /* 0 110 010 010 */	cp1610_andr(cpustate, 2,2);	break;
		case 0x193: /* 0 110 010 011 */	cp1610_andr(cpustate, 2,3);	break;
		case 0x194: /* 0 110 010 100 */	cp1610_andr(cpustate, 2,4);	break;
		case 0x195: /* 0 110 010 101 */	cp1610_andr(cpustate, 2,5);	break;
		case 0x196: /* 0 110 010 110 */	cp1610_andr(cpustate, 2,6);	break;
		case 0x197: /* 0 110 010 111 */	cp1610_andr(cpustate, 2,7);	break;

		case 0x198: /* 0 110 011 000 */	cp1610_andr(cpustate, 3,0);	break;
		case 0x199: /* 0 110 011 001 */	cp1610_andr(cpustate, 3,1);	break;
		case 0x19a: /* 0 110 011 010 */	cp1610_andr(cpustate, 3,2);	break;
		case 0x19b: /* 0 110 011 011 */	cp1610_andr(cpustate, 3,3);	break;
		case 0x19c: /* 0 110 011 100 */	cp1610_andr(cpustate, 3,4);	break;
		case 0x19d: /* 0 110 011 101 */	cp1610_andr(cpustate, 3,5);	break;
		case 0x19e: /* 0 110 011 110 */	cp1610_andr(cpustate, 3,6);	break;
		case 0x19f: /* 0 110 011 111 */	cp1610_andr(cpustate, 3,7);	break;

		case 0x1a0: /* 0 110 100 000 */	cp1610_andr(cpustate, 4,0);	break;
		case 0x1a1: /* 0 110 100 001 */	cp1610_andr(cpustate, 4,1);	break;
		case 0x1a2: /* 0 110 100 010 */	cp1610_andr(cpustate, 4,2);	break;
		case 0x1a3: /* 0 110 100 011 */	cp1610_andr(cpustate, 4,3);	break;
		case 0x1a4: /* 0 110 100 100 */	cp1610_andr(cpustate, 4,4);	break;
		case 0x1a5: /* 0 110 100 101 */	cp1610_andr(cpustate, 4,5);	break;
		case 0x1a6: /* 0 110 100 110 */	cp1610_andr(cpustate, 4,6);	break;
		case 0x1a7: /* 0 110 100 111 */	cp1610_andr(cpustate, 4,7);	break;

		case 0x1a8: /* 0 110 101 000 */	cp1610_andr(cpustate, 5,0);	break;
		case 0x1a9: /* 0 110 101 001 */	cp1610_andr(cpustate, 5,1);	break;
		case 0x1aa: /* 0 110 101 010 */	cp1610_andr(cpustate, 5,2);	break;
		case 0x1ab: /* 0 110 101 011 */	cp1610_andr(cpustate, 5,3);	break;
		case 0x1ac: /* 0 110 101 100 */	cp1610_andr(cpustate, 5,4);	break;
		case 0x1ad: /* 0 110 101 101 */	cp1610_andr(cpustate, 5,5);	break;
		case 0x1ae: /* 0 110 101 110 */	cp1610_andr(cpustate, 5,6);	break;
		case 0x1af: /* 0 110 101 111 */	cp1610_andr(cpustate, 5,7);	break;

		case 0x1b0: /* 0 110 110 000 */	cp1610_andr(cpustate, 6,0);	break;
		case 0x1b1: /* 0 110 110 001 */	cp1610_andr(cpustate, 6,1);	break;
		case 0x1b2: /* 0 110 110 010 */	cp1610_andr(cpustate, 6,2);	break;
		case 0x1b3: /* 0 110 110 011 */	cp1610_andr(cpustate, 6,3);	break;
		case 0x1b4: /* 0 110 110 100 */	cp1610_andr(cpustate, 6,4);	break;
		case 0x1b5: /* 0 110 110 101 */	cp1610_andr(cpustate, 6,5);	break;
		case 0x1b6: /* 0 110 110 110 */	cp1610_andr(cpustate, 6,6);	break;
		case 0x1b7: /* 0 110 110 111 */	cp1610_andr(cpustate, 6,7);	break;

		case 0x1b8: /* 0 110 111 000 */	cp1610_andr(cpustate, 7,0);	break;
		case 0x1b9: /* 0 110 111 001 */	cp1610_andr(cpustate, 7,1);	break;
		case 0x1ba: /* 0 110 111 010 */	cp1610_andr(cpustate, 7,2);	break;
		case 0x1bb: /* 0 110 111 011 */	cp1610_andr(cpustate, 7,3);	break;
		case 0x1bc: /* 0 110 111 100 */	cp1610_andr(cpustate, 7,4);	break;
		case 0x1bd: /* 0 110 111 101 */	cp1610_andr(cpustate, 7,5);	break;
		case 0x1be: /* 0 110 111 110 */	cp1610_andr(cpustate, 7,6);	break;
		case 0x1bf: /* 0 110 111 111 */	cp1610_andr(cpustate, 7,7);	break;

		case 0x1c0: /* 0 111 000 000 */	cp1610_clrr(cpustate, 0);		break;
		case 0x1c1: /* 0 111 000 001 */	cp1610_xorr(cpustate, 0,1);	break;
		case 0x1c2: /* 0 111 000 010 */	cp1610_xorr(cpustate, 0,2);	break;
		case 0x1c3: /* 0 111 000 011 */	cp1610_xorr(cpustate, 0,3);	break;
		case 0x1c4: /* 0 111 000 100 */	cp1610_xorr(cpustate, 0,4);	break;
		case 0x1c5: /* 0 111 000 101 */	cp1610_xorr(cpustate, 0,5);	break;
		case 0x1c6: /* 0 111 000 110 */	cp1610_xorr(cpustate, 0,6);	break;
		case 0x1c7: /* 0 111 000 111 */	cp1610_xorr(cpustate, 0,7);	break;

		case 0x1c8: /* 0 111 001 000 */	cp1610_xorr(cpustate, 1,0);	break;
		case 0x1c9: /* 0 111 001 001 */	cp1610_clrr(cpustate, 1);		break;
		case 0x1ca: /* 0 111 001 010 */	cp1610_xorr(cpustate, 1,2);	break;
		case 0x1cb: /* 0 111 001 011 */	cp1610_xorr(cpustate, 1,3);	break;
		case 0x1cc: /* 0 111 001 100 */	cp1610_xorr(cpustate, 1,4);	break;
		case 0x1cd: /* 0 111 001 101 */	cp1610_xorr(cpustate, 1,5);	break;
		case 0x1ce: /* 0 111 001 110 */	cp1610_xorr(cpustate, 1,6);	break;
		case 0x1cf: /* 0 111 001 111 */	cp1610_xorr(cpustate, 1,7);	break;

		case 0x1d0: /* 0 111 010 000 */	cp1610_xorr(cpustate, 2,0);	break;
		case 0x1d1: /* 0 111 010 001 */	cp1610_xorr(cpustate, 2,1);	break;
		case 0x1d2: /* 0 111 010 010 */	cp1610_clrr(cpustate, 2);		break;
		case 0x1d3: /* 0 111 010 011 */	cp1610_xorr(cpustate, 2,3);	break;
		case 0x1d4: /* 0 111 010 100 */	cp1610_xorr(cpustate, 2,4);	break;
		case 0x1d5: /* 0 111 010 101 */	cp1610_xorr(cpustate, 2,5);	break;
		case 0x1d6: /* 0 111 010 110 */	cp1610_xorr(cpustate, 2,6);	break;
		case 0x1d7: /* 0 111 010 111 */	cp1610_xorr(cpustate, 2,7);	break;

		case 0x1d8: /* 0 111 011 000 */	cp1610_xorr(cpustate, 3,0);	break;
		case 0x1d9: /* 0 111 011 001 */	cp1610_xorr(cpustate, 3,1);	break;
		case 0x1da: /* 0 111 011 010 */	cp1610_xorr(cpustate, 3,2);	break;
		case 0x1db: /* 0 111 011 011 */	cp1610_clrr(cpustate, 3);		break;
		case 0x1dc: /* 0 111 011 100 */	cp1610_xorr(cpustate, 3,4);	break;
		case 0x1dd: /* 0 111 011 101 */	cp1610_xorr(cpustate, 3,5);	break;
		case 0x1de: /* 0 111 011 110 */	cp1610_xorr(cpustate, 3,6);	break;
		case 0x1df: /* 0 111 011 111 */	cp1610_xorr(cpustate, 3,7);	break;

		case 0x1e0: /* 0 111 100 000 */	cp1610_xorr(cpustate, 4,0);	break;
		case 0x1e1: /* 0 111 100 001 */	cp1610_xorr(cpustate, 4,1);	break;
		case 0x1e2: /* 0 111 100 010 */	cp1610_xorr(cpustate, 4,2);	break;
		case 0x1e3: /* 0 111 100 011 */	cp1610_xorr(cpustate, 4,3);	break;
		case 0x1e4: /* 0 111 100 100 */	cp1610_clrr(cpustate, 4);		break;
		case 0x1e5: /* 0 111 100 101 */	cp1610_xorr(cpustate, 4,5);	break;
		case 0x1e6: /* 0 111 100 110 */	cp1610_xorr(cpustate, 4,6);	break;
		case 0x1e7: /* 0 111 100 111 */	cp1610_xorr(cpustate, 4,7);	break;

		case 0x1e8: /* 0 111 101 000 */	cp1610_xorr(cpustate, 5,0);	break;
		case 0x1e9: /* 0 111 101 001 */	cp1610_xorr(cpustate, 5,1);	break;
		case 0x1ea: /* 0 111 101 010 */	cp1610_xorr(cpustate, 5,2);	break;
		case 0x1eb: /* 0 111 101 011 */	cp1610_xorr(cpustate, 5,3);	break;
		case 0x1ec: /* 0 111 101 100 */	cp1610_xorr(cpustate, 5,4);	break;
		case 0x1ed: /* 0 111 101 101 */	cp1610_clrr(cpustate, 5);		break;
		case 0x1ee: /* 0 111 101 110 */	cp1610_xorr(cpustate, 5,6);	break;
		case 0x1ef: /* 0 111 101 111 */	cp1610_xorr(cpustate, 5,7);	break;

		case 0x1f0: /* 0 111 110 000 */	cp1610_xorr(cpustate, 6,0);	break;
		case 0x1f1: /* 0 111 110 001 */	cp1610_xorr(cpustate, 6,1);	break;
		case 0x1f2: /* 0 111 110 010 */	cp1610_xorr(cpustate, 6,2);	break;
		case 0x1f3: /* 0 111 110 011 */	cp1610_xorr(cpustate, 6,3);	break;
		case 0x1f4: /* 0 111 110 100 */	cp1610_xorr(cpustate, 6,4);	break;
		case 0x1f5: /* 0 111 110 101 */	cp1610_xorr(cpustate, 6,5);	break;
		case 0x1f6: /* 0 111 110 110 */	cp1610_clrr(cpustate, 6);		break;
		case 0x1f7: /* 0 111 110 111 */	cp1610_xorr(cpustate, 6,7);	break;

		case 0x1f8: /* 0 111 111 000 */	cp1610_xorr(cpustate, 7,0);	break;
		case 0x1f9: /* 0 111 111 001 */	cp1610_xorr(cpustate, 7,1);	break;
		case 0x1fa: /* 0 111 111 010 */	cp1610_xorr(cpustate, 7,2);	break;
		case 0x1fb: /* 0 111 111 011 */	cp1610_xorr(cpustate, 7,3);	break;
		case 0x1fc: /* 0 111 111 100 */	cp1610_xorr(cpustate, 7,4);	break;
		case 0x1fd: /* 0 111 111 101 */	cp1610_xorr(cpustate, 7,5);	break;
		case 0x1fe: /* 0 111 111 110 */	cp1610_xorr(cpustate, 7,6);	break;
		case 0x1ff: /* 0 110 111 111 */	cp1610_clrr(cpustate, 7);		break;

		case 0x200: /* 1 000 000 000 */ cp1610_b(cpustate, 0);		break;
		case 0x201: /* 1 000 000 001 */ cp1610_bc(cpustate, 0);		break; /* aka BLGE */
		case 0x202: /* 1 000 000 010 */ cp1610_bov(cpustate, 0);		break;
		case 0x203:	/* 1 000 000 011 */ cp1610_bpl(cpustate, 0);		break;
		case 0x204:	/* 1 000 000 100 */ cp1610_bze(cpustate, 0);		break; /* aka BEQ */
		case 0x205:	/* 1 000 000 101 */ cp1610_blt(cpustate, 0);		break;
		case 0x206:	/* 1 000 000 110 */ cp1610_ble(cpustate, 0);		break;
		case 0x207:	/* 1 000 000 111 */ cp1610_busc(cpustate, 0);		break;

		case 0x208:	/* 1 000 001 000 */ cp1610_nopp(cpustate, 0);		break;
		case 0x209:	/* 1 000 001 001 */ cp1610_bnc(cpustate, 0);		break; /* aka BLLT */
		case 0x20a:	/* 1 000 001 010 */ cp1610_bnov(cpustate, 0);		break;
		case 0x20b:	/* 1 000 001 011 */ cp1610_bmi(cpustate, 0);		break;
		case 0x20c:	/* 1 000 001 100 */ cp1610_bnze(cpustate, 0);		break; /* aka BNEQ */
		case 0x20d:	/* 1 000 001 101 */ cp1610_bge(cpustate, 0);		break;
		case 0x20e:	/* 1 000 001 110 */ cp1610_bgt(cpustate, 0);		break;
		case 0x20f:	/* 1 000 001 111 */ cp1610_besc(cpustate, 0);		break;

		case 0x210: /* 1 000 010 000 */ cp1610_bext(cpustate, 0,0);	break;
		case 0x211: /* 1 000 010 001 */ cp1610_bext(cpustate, 1,0);	break;
		case 0x212: /* 1 000 010 010 */ cp1610_bext(cpustate, 2,0);	break;
		case 0x213:	/* 1 000 010 011 */ cp1610_bext(cpustate, 3,0);	break;
		case 0x214:	/* 1 000 010 100 */ cp1610_bext(cpustate, 4,0);	break;
		case 0x215:	/* 1 000 010 101 */ cp1610_bext(cpustate, 5,0);	break;
		case 0x216:	/* 1 000 010 110 */ cp1610_bext(cpustate, 6,0);	break;
		case 0x217:	/* 1 000 010 111 */ cp1610_bext(cpustate, 7,0);	break;

		case 0x218:	/* 1 000 011 000 */ cp1610_bext(cpustate, 8,0);	break;
		case 0x219:	/* 1 000 011 001 */ cp1610_bext(cpustate, 9,0);	break;
		case 0x21a:	/* 1 000 011 010 */ cp1610_bext(cpustate, 10,0);	break;
		case 0x21b:	/* 1 000 011 011 */ cp1610_bext(cpustate, 11,0);	break;
		case 0x21c:	/* 1 000 011 100 */ cp1610_bext(cpustate, 12,0);	break;
		case 0x21d:	/* 1 000 011 101 */ cp1610_bext(cpustate, 13,0);	break;
		case 0x21e:	/* 1 000 011 110 */ cp1610_bext(cpustate, 14,0);	break;
		case 0x21f:	/* 1 000 011 111 */ cp1610_bext(cpustate, 15,0);	break;

		case 0x220:	/* 1 000 100 000 */ cp1610_b(cpustate, 0xffff);		break;
		case 0x221:	/* 1 000 100 001 */ cp1610_bc(cpustate, 0xffff);		break; /* aka BLGE */
		case 0x222:	/* 1 000 100 010 */ cp1610_bov(cpustate, 0xffff);		break;
		case 0x223:	/* 1 000 100 011 */ cp1610_bpl(cpustate, 0xffff);		break;
		case 0x224:	/* 1 000 100 100 */ cp1610_bze(cpustate, 0xffff);		break; /* aka BEQ */
		case 0x225:	/* 1 000 100 101 */ cp1610_blt(cpustate, 0xffff);		break;
		case 0x226:	/* 1 000 100 110 */ cp1610_ble(cpustate, 0xffff);		break;
		case 0x227:	/* 1 000 100 111 */ cp1610_busc(cpustate, 0xffff);	break;

		case 0x228:	/* 1 000 101 000 */ cp1610_nopp(cpustate, 0xffff);	break;
		case 0x229:	/* 1 000 101 001 */ cp1610_bnc(cpustate, 0xffff);		break; /* aka BLLT */
		case 0x22a:	/* 1 000 101 010 */ cp1610_bnov(cpustate, 0xffff);	break;
		case 0x22b:	/* 1 000 101 011 */ cp1610_bmi(cpustate, 0xffff);		break;
		case 0x22c:	/* 1 000 101 100 */ cp1610_bnze(cpustate, 0xffff);	break; /* aka BNEQ */
		case 0x22d:	/* 1 000 101 101 */ cp1610_bge(cpustate, 0xffff);		break;
		case 0x22e:	/* 1 000 101 110 */ cp1610_bgt(cpustate, 0xffff);		break;
		case 0x22f:	/* 1 000 101 111 */ cp1610_besc(cpustate, 0xffff);	break;

		case 0x230:	/* 1 000 110 000 */ cp1610_bext(cpustate, 0,0xffff);	break;
		case 0x231:	/* 1 000 110 001 */ cp1610_bext(cpustate, 1,0xffff);	break;
		case 0x232:	/* 1 000 110 010 */ cp1610_bext(cpustate, 2,0xffff);	break;
		case 0x233:	/* 1 000 110 011 */ cp1610_bext(cpustate, 3,0xffff);	break;
		case 0x234:	/* 1 000 110 100 */ cp1610_bext(cpustate, 4,0xffff);	break;
		case 0x235:	/* 1 000 110 101 */ cp1610_bext(cpustate, 5,0xffff);	break;
		case 0x236:	/* 1 000 110 110 */ cp1610_bext(cpustate, 6,0xffff);	break;
		case 0x237:	/* 1 000 110 111 */ cp1610_bext(cpustate, 7,0xffff);	break;

		case 0x238:	/* 1 000 111 000 */ cp1610_bext(cpustate, 8,0xffff);	break;
		case 0x239:	/* 1 000 111 001 */ cp1610_bext(cpustate, 9,0xffff);	break;
		case 0x23a:	/* 1 000 111 010 */ cp1610_bext(cpustate, 10,0xffff);	break;
		case 0x23b:	/* 1 000 111 011 */ cp1610_bext(cpustate, 11,0xffff);	break;
		case 0x23c:	/* 1 000 111 100 */ cp1610_bext(cpustate, 12,0xffff);	break;
		case 0x23d:	/* 1 000 111 101 */ cp1610_bext(cpustate, 13,0xffff);	break;
		case 0x23e:	/* 1 000 111 110 */ cp1610_bext(cpustate, 14,0xffff);	break;
		case 0x23f:	/* 1 000 111 111 */ cp1610_bext(cpustate, 15,0xffff);	break;

		case 0x240: /* 1 001 000 000 */ cp1610_mvo(cpustate, 0);			break;
		case 0x241: /* 1 001 000 001 */ cp1610_mvo(cpustate, 1);			break;
		case 0x242: /* 1 001 000 010 */ cp1610_mvo(cpustate, 2);			break;
		case 0x243: /* 1 001 000 011 */ cp1610_mvo(cpustate, 3);			break;
		case 0x244: /* 1 001 000 100 */ cp1610_mvo(cpustate, 4);			break;
		case 0x245: /* 1 001 000 101 */ cp1610_mvo(cpustate, 5);			break;
		case 0x246: /* 1 001 000 110 */ cp1610_mvo(cpustate, 6);			break;
		case 0x247: /* 1 001 000 111 */ cp1610_mvo(cpustate, 7);			break;

		case 0x248: /* 1 001 001 000 */ cp1610_mvoat(cpustate, 0,1);		break;
		case 0x249: /* 1 001 001 001 */ cp1610_mvoat(cpustate, 1,1);		break;
		case 0x24a: /* 1 001 001 010 */ cp1610_mvoat(cpustate, 2,1);		break;
		case 0x24b: /* 1 001 001 011 */ cp1610_mvoat(cpustate, 3,1);		break;
		case 0x24c: /* 1 001 001 100 */ cp1610_mvoat(cpustate, 4,1);		break;
		case 0x24d: /* 1 001 001 101 */ cp1610_mvoat(cpustate, 5,1);		break;
		case 0x24e: /* 1 001 001 110 */ cp1610_mvoat(cpustate, 6,1);		break;
		case 0x24f: /* 1 001 001 111 */ cp1610_mvoat(cpustate, 7,1);		break;

		case 0x250: /* 1 001 010 000 */ cp1610_mvoat(cpustate, 0,2);		break;
		case 0x251: /* 1 001 010 001 */ cp1610_mvoat(cpustate, 1,2);		break;
		case 0x252: /* 1 001 010 010 */ cp1610_mvoat(cpustate, 2,2);		break;
		case 0x253: /* 1 001 010 011 */ cp1610_mvoat(cpustate, 3,2);		break;
		case 0x254: /* 1 001 010 100 */ cp1610_mvoat(cpustate, 4,2);		break;
		case 0x255: /* 1 001 010 101 */ cp1610_mvoat(cpustate, 5,2);		break;
		case 0x256: /* 1 001 010 110 */ cp1610_mvoat(cpustate, 6,2);		break;
		case 0x257: /* 1 001 010 111 */ cp1610_mvoat(cpustate, 7,2);		break;

		case 0x258: /* 1 001 011 000 */ cp1610_mvoat(cpustate, 0,3);		break;
		case 0x259: /* 1 001 011 001 */ cp1610_mvoat(cpustate, 1,3);		break;
		case 0x25a: /* 1 001 011 010 */ cp1610_mvoat(cpustate, 2,3);		break;
		case 0x25b: /* 1 001 011 011 */ cp1610_mvoat(cpustate, 3,3);		break;
		case 0x25c: /* 1 001 011 100 */ cp1610_mvoat(cpustate, 4,3);		break;
		case 0x25d: /* 1 001 011 101 */ cp1610_mvoat(cpustate, 5,3);		break;
		case 0x25e: /* 1 001 011 110 */ cp1610_mvoat(cpustate, 6,3);		break;
		case 0x25f: /* 1 001 011 111 */ cp1610_mvoat(cpustate, 7,3);		break;

		case 0x260: /* 1 001 100 000 */ cp1610_mvoat_i(cpustate, 0,4);	break;
		case 0x261: /* 1 001 100 001 */ cp1610_mvoat_i(cpustate, 1,4);	break;
		case 0x262: /* 1 001 100 010 */ cp1610_mvoat_i(cpustate, 2,4);	break;
		case 0x263: /* 1 001 100 011 */ cp1610_mvoat_i(cpustate, 3,4);	break;
		case 0x264: /* 1 001 100 100 */ cp1610_mvoat_i(cpustate, 4,4);	break;
		case 0x265: /* 1 001 100 101 */ cp1610_mvoat_i(cpustate, 5,4);	break;
		case 0x266: /* 1 001 100 110 */ cp1610_mvoat_i(cpustate, 6,4);	break;
		case 0x267: /* 1 001 100 111 */ cp1610_mvoat_i(cpustate, 7,4);	break;

		case 0x268: /* 1 001 101 000 */ cp1610_mvoat_i(cpustate, 0,5);	break;
		case 0x269: /* 1 001 101 001 */ cp1610_mvoat_i(cpustate, 1,5);	break;
		case 0x26a: /* 1 001 101 010 */ cp1610_mvoat_i(cpustate, 2,5);	break;
		case 0x26b: /* 1 001 101 011 */ cp1610_mvoat_i(cpustate, 3,5);	break;
		case 0x26c: /* 1 001 101 100 */ cp1610_mvoat_i(cpustate, 4,5);	break;
		case 0x26d: /* 1 001 101 101 */ cp1610_mvoat_i(cpustate, 5,5);	break;
		case 0x26e: /* 1 001 101 110 */ cp1610_mvoat_i(cpustate, 6,5);	break;
		case 0x26f: /* 1 001 101 111 */ cp1610_mvoat_i(cpustate, 7,5);	break;

		case 0x270: /* 1 001 110 000 */ cp1610_mvoat_i(cpustate, 0,6);	break; /* pshr */
		case 0x271: /* 1 001 110 001 */ cp1610_mvoat_i(cpustate, 1,6);	break; /* pshr */
		case 0x272: /* 1 001 110 010 */ cp1610_mvoat_i(cpustate, 2,6);	break; /* pshr */
		case 0x273: /* 1 001 110 011 */ cp1610_mvoat_i(cpustate, 3,6);	break; /* pshr */
		case 0x274: /* 1 001 110 100 */ cp1610_mvoat_i(cpustate, 4,6);	break; /* pshr */
		case 0x275: /* 1 001 110 101 */ cp1610_mvoat_i(cpustate, 5,6);	break; /* pshr */
		case 0x276: /* 1 001 110 110 */ cp1610_mvoat_i(cpustate, 6,6);	break; /* pshr */
		case 0x277: /* 1 001 110 111 */ cp1610_mvoat_i(cpustate, 7,6);	break; /* pshr */

		case 0x278: /* 1 001 111 000 */ cp1610_mvoi(cpustate, 0);			break;
		case 0x279: /* 1 001 111 001 */ cp1610_mvoi(cpustate, 1);			break;
		case 0x27a: /* 1 001 111 010 */ cp1610_mvoi(cpustate, 2);			break;
		case 0x27b: /* 1 001 111 011 */ cp1610_mvoi(cpustate, 3);			break;
		case 0x27c: /* 1 001 111 100 */ cp1610_mvoi(cpustate, 4);			break;
		case 0x27d: /* 1 001 111 101 */ cp1610_mvoi(cpustate, 5);			break;
		case 0x27e: /* 1 001 111 110 */ cp1610_mvoi(cpustate, 6);			break;
		case 0x27f: /* 1 001 111 111 */ cp1610_mvoi(cpustate, 7);			break;

		case 0x280: /* 1 010 000 000 */ cp1610_mvi(cpustate, 0);			break;
		case 0x281: /* 1 010 000 001 */ cp1610_mvi(cpustate, 1);			break;
		case 0x282: /* 1 010 000 010 */ cp1610_mvi(cpustate, 2);			break;
		case 0x283: /* 1 010 000 011 */ cp1610_mvi(cpustate, 3);			break;
		case 0x284: /* 1 010 000 100 */ cp1610_mvi(cpustate, 4);			break;
		case 0x285: /* 1 010 000 101 */ cp1610_mvi(cpustate, 5);			break;
		case 0x286: /* 1 010 000 110 */ cp1610_mvi(cpustate, 6);			break;
		case 0x287: /* 1 010 000 111 */ cp1610_mvi(cpustate, 7);			break;

		case 0x288: /* 1 010 001 000 */ cp1610_mviat(cpustate, 1,0);		break;
		case 0x289: /* 1 010 001 001 */ cp1610_mviat(cpustate, 1,1);		break;
		case 0x28a: /* 1 010 001 010 */ cp1610_mviat(cpustate, 1,2);		break;
		case 0x28b: /* 1 010 001 011 */ cp1610_mviat(cpustate, 1,3);		break;
		case 0x28c: /* 1 010 001 100 */ cp1610_mviat(cpustate, 1,4);		break;
		case 0x28d: /* 1 010 001 101 */ cp1610_mviat(cpustate, 1,5);		break;
		case 0x28e: /* 1 010 001 110 */ cp1610_mviat(cpustate, 1,6);		break;
		case 0x28f: /* 1 010 001 111 */ cp1610_mviat(cpustate, 1,7);		break;

		case 0x290: /* 1 010 010 000 */ cp1610_mviat(cpustate, 2,0);		break;
		case 0x291: /* 1 010 010 001 */ cp1610_mviat(cpustate, 2,1);		break;
		case 0x292: /* 1 010 010 010 */ cp1610_mviat(cpustate, 2,2);		break;
		case 0x293: /* 1 010 010 011 */ cp1610_mviat(cpustate, 2,3);		break;
		case 0x294: /* 1 010 010 100 */ cp1610_mviat(cpustate, 2,4);		break;
		case 0x295: /* 1 010 010 101 */ cp1610_mviat(cpustate, 2,5);		break;
		case 0x296: /* 1 010 010 110 */ cp1610_mviat(cpustate, 2,6);		break;
		case 0x297: /* 1 010 010 111 */ cp1610_mviat(cpustate, 2,7);		break;

		case 0x298: /* 1 010 011 000 */ cp1610_mviat(cpustate, 3,0);		break;
		case 0x299: /* 1 010 011 001 */ cp1610_mviat(cpustate, 3,1);		break;
		case 0x29a: /* 1 010 011 010 */ cp1610_mviat(cpustate, 3,2);		break;
		case 0x29b: /* 1 010 011 011 */ cp1610_mviat(cpustate, 3,3);		break;
		case 0x29c: /* 1 010 011 100 */ cp1610_mviat(cpustate, 3,4);		break;
		case 0x29d: /* 1 010 011 101 */ cp1610_mviat(cpustate, 3,5);		break;
		case 0x29e: /* 1 010 011 110 */ cp1610_mviat(cpustate, 3,6);		break;
		case 0x29f: /* 1 010 011 111 */ cp1610_mviat(cpustate, 3,7);		break;

		case 0x2a0: /* 1 010 100 000 */ cp1610_mviat_i(cpustate, 4,0);	break;
		case 0x2a1: /* 1 010 100 001 */ cp1610_mviat_i(cpustate, 4,1);	break;
		case 0x2a2: /* 1 010 100 010 */ cp1610_mviat_i(cpustate, 4,2);	break;
		case 0x2a3: /* 1 010 100 011 */ cp1610_mviat_i(cpustate, 4,3);	break;
		case 0x2a4: /* 1 010 100 100 */ cp1610_mviat_i(cpustate, 4,4);	break;
		case 0x2a5: /* 1 010 100 101 */ cp1610_mviat_i(cpustate, 4,5);	break;
		case 0x2a6: /* 1 010 100 110 */ cp1610_mviat_i(cpustate, 4,6);	break;
		case 0x2a7: /* 1 010 100 111 */ cp1610_mviat_i(cpustate, 4,7);	break;

		case 0x2a8: /* 1 010 101 000 */ cp1610_mviat_i(cpustate, 5,0);	break;
		case 0x2a9: /* 1 010 101 001 */ cp1610_mviat_i(cpustate, 5,1);	break;
		case 0x2aa: /* 1 010 101 010 */ cp1610_mviat_i(cpustate, 5,2);	break;
		case 0x2ab: /* 1 010 101 011 */ cp1610_mviat_i(cpustate, 5,3);	break;
		case 0x2ac: /* 1 010 101 100 */ cp1610_mviat_i(cpustate, 5,4);	break;
		case 0x2ad: /* 1 010 101 101 */ cp1610_mviat_i(cpustate, 5,5);	break;
		case 0x2ae: /* 1 010 101 110 */ cp1610_mviat_i(cpustate, 5,6);	break;
		case 0x2af: /* 1 010 101 111 */ cp1610_mviat_i(cpustate, 5,7);	break;

		case 0x2b0: /* 1 010 110 000 */ cp1610_pulr(cpustate, 0);			break;
		case 0x2b1: /* 1 010 110 001 */ cp1610_pulr(cpustate, 1);			break;
		case 0x2b2: /* 1 010 110 010 */ cp1610_pulr(cpustate, 2);			break;
		case 0x2b3: /* 1 010 110 011 */ cp1610_pulr(cpustate, 3);			break;
		case 0x2b4: /* 1 010 110 100 */ cp1610_pulr(cpustate, 4);			break;
		case 0x2b5: /* 1 010 110 101 */ cp1610_pulr(cpustate, 5);			break;
		case 0x2b6: /* 1 010 110 110 */ cp1610_pulr(cpustate, 6);			break;
		case 0x2b7: /* 1 010 110 111 */ cp1610_pulr(cpustate, 7);			break;

		case 0x2b8: /* 1 010 111 000 */ cp1610_mvii(cpustate, 0);			break;
		case 0x2b9: /* 1 010 111 001 */ cp1610_mvii(cpustate, 1);			break;
		case 0x2ba: /* 1 010 111 010 */ cp1610_mvii(cpustate, 2);			break;
		case 0x2bb: /* 1 010 111 011 */ cp1610_mvii(cpustate, 3);			break;
		case 0x2bc: /* 1 010 111 100 */ cp1610_mvii(cpustate, 4);			break;
		case 0x2bd: /* 1 010 111 101 */ cp1610_mvii(cpustate, 5);			break;
		case 0x2be: /* 1 010 111 110 */ cp1610_mvii(cpustate, 6);			break;
		case 0x2bf: /* 1 010 111 111 */ cp1610_mvii(cpustate, 7);			break;

		case 0x2c0: /* 1 011 000 000 */ cp1610_add(cpustate, 0);			break;
		case 0x2c1: /* 1 011 000 001 */ cp1610_add(cpustate, 1);			break;
		case 0x2c2: /* 1 011 000 010 */ cp1610_add(cpustate, 2);			break;
		case 0x2c3: /* 1 011 000 011 */ cp1610_add(cpustate, 3);			break;
		case 0x2c4: /* 1 011 000 100 */ cp1610_add(cpustate, 4);			break;
		case 0x2c5: /* 1 011 000 101 */ cp1610_add(cpustate, 5);			break;
		case 0x2c6: /* 1 011 000 110 */ cp1610_add(cpustate, 6);			break;
		case 0x2c7: /* 1 011 000 111 */ cp1610_add(cpustate, 7);			break;

		case 0x2c8: /* 1 011 001 000 */ cp1610_addat(cpustate, 1,0);		break;
		case 0x2c9: /* 1 011 001 001 */ cp1610_addat(cpustate, 1,1);		break;
		case 0x2ca: /* 1 011 001 010 */ cp1610_addat(cpustate, 1,2);		break;
		case 0x2cb: /* 1 011 001 011 */ cp1610_addat(cpustate, 1,3);		break;
		case 0x2cc: /* 1 011 001 100 */ cp1610_addat(cpustate, 1,4);		break;
		case 0x2cd: /* 1 011 001 101 */ cp1610_addat(cpustate, 1,5);		break;
		case 0x2ce: /* 1 011 001 110 */ cp1610_addat(cpustate, 1,6);		break;
		case 0x2cf: /* 1 011 001 111 */ cp1610_addat(cpustate, 1,7);		break;

		case 0x2d0: /* 1 011 010 000 */ cp1610_addat(cpustate, 2,0);		break;
		case 0x2d1: /* 1 011 010 001 */ cp1610_addat(cpustate, 2,1);		break;
		case 0x2d2: /* 1 011 010 010 */ cp1610_addat(cpustate, 2,2);		break;
		case 0x2d3: /* 1 011 010 011 */ cp1610_addat(cpustate, 2,3);		break;
		case 0x2d4: /* 1 011 010 100 */ cp1610_addat(cpustate, 2,4);		break;
		case 0x2d5: /* 1 011 010 101 */ cp1610_addat(cpustate, 2,5);		break;
		case 0x2d6: /* 1 011 010 110 */ cp1610_addat(cpustate, 2,6);		break;
		case 0x2d7: /* 1 011 010 111 */ cp1610_addat(cpustate, 2,7);		break;

		case 0x2d8: /* 1 011 011 000 */ cp1610_addat(cpustate, 3,0);		break;
		case 0x2d9: /* 1 011 011 001 */ cp1610_addat(cpustate, 3,1);		break;
		case 0x2da: /* 1 011 011 010 */ cp1610_addat(cpustate, 3,2);		break;
		case 0x2db: /* 1 011 011 011 */ cp1610_addat(cpustate, 3,3);		break;
		case 0x2dc: /* 1 011 011 100 */ cp1610_addat(cpustate, 3,4);		break;
		case 0x2dd: /* 1 011 011 101 */ cp1610_addat(cpustate, 3,5);		break;
		case 0x2de: /* 1 011 011 110 */ cp1610_addat(cpustate, 3,6);		break;
		case 0x2df: /* 1 011 011 111 */ cp1610_addat(cpustate, 3,7);		break;

		case 0x2e0: /* 1 011 100 000 */ cp1610_addat_i(cpustate, 4,0);	break;
		case 0x2e1: /* 1 011 100 001 */ cp1610_addat_i(cpustate, 4,1);	break;
		case 0x2e2: /* 1 011 100 010 */ cp1610_addat_i(cpustate, 4,2);	break;
		case 0x2e3: /* 1 011 100 011 */ cp1610_addat_i(cpustate, 4,3);	break;
		case 0x2e4: /* 1 011 100 100 */ cp1610_addat_i(cpustate, 4,4);	break;
		case 0x2e5: /* 1 011 100 101 */ cp1610_addat_i(cpustate, 4,5);	break;
		case 0x2e6: /* 1 011 100 110 */ cp1610_addat_i(cpustate, 4,6);	break;
		case 0x2e7: /* 1 011 100 111 */ cp1610_addat_i(cpustate, 4,7);	break;

		case 0x2e8: /* 1 011 101 000 */ cp1610_addat_i(cpustate, 5,0);	break;
		case 0x2e9: /* 1 011 101 001 */ cp1610_addat_i(cpustate, 5,1);	break;
		case 0x2ea: /* 1 011 101 010 */ cp1610_addat_i(cpustate, 5,2);	break;
		case 0x2eb: /* 1 011 101 011 */ cp1610_addat_i(cpustate, 5,3);	break;
		case 0x2ec: /* 1 011 101 100 */ cp1610_addat_i(cpustate, 5,4);	break;
		case 0x2ed: /* 1 011 101 101 */ cp1610_addat_i(cpustate, 5,5);	break;
		case 0x2ee: /* 1 011 101 110 */ cp1610_addat_i(cpustate, 5,6);	break;
		case 0x2ef: /* 1 011 101 111 */ cp1610_addat_i(cpustate, 5,7);	break;

		case 0x2f0: /* 1 011 110 000 */ cp1610_addat_d(cpustate, 6,0);	break;
		case 0x2f1: /* 1 011 110 001 */ cp1610_addat_d(cpustate, 6,1);	break;
		case 0x2f2: /* 1 011 110 010 */ cp1610_addat_d(cpustate, 6,2);	break;
		case 0x2f3: /* 1 011 110 011 */ cp1610_addat_d(cpustate, 6,3);	break;
		case 0x2f4: /* 1 011 110 100 */ cp1610_addat_d(cpustate, 6,4);	break;
		case 0x2f5: /* 1 011 110 101 */ cp1610_addat_d(cpustate, 6,5);	break;
		case 0x2f6: /* 1 011 110 110 */ cp1610_addat_d(cpustate, 6,6);	break;
		case 0x2f7: /* 1 011 110 111 */ cp1610_addat_d(cpustate, 6,7);	break;

		case 0x2f8: /* 1 011 111 000 */ cp1610_addi(cpustate, 0);			break;
		case 0x2f9: /* 1 011 111 001 */ cp1610_addi(cpustate, 1);			break;
		case 0x2fa: /* 1 011 111 010 */ cp1610_addi(cpustate, 2);			break;
		case 0x2fb: /* 1 011 111 011 */ cp1610_addi(cpustate, 3);			break;
		case 0x2fc: /* 1 011 111 100 */ cp1610_addi(cpustate, 4);			break;
		case 0x2fd: /* 1 011 111 101 */ cp1610_addi(cpustate, 5);			break;
		case 0x2fe: /* 1 011 111 110 */ cp1610_addi(cpustate, 6);			break;
		case 0x2ff: /* 1 011 111 111 */ cp1610_addi(cpustate, 7);			break;

		case 0x300: /* 1 100 000 000 */ cp1610_sub(cpustate, 0);			break;
		case 0x301: /* 1 100 000 001 */ cp1610_sub(cpustate, 1);			break;
		case 0x302: /* 1 100 000 010 */ cp1610_sub(cpustate, 2);			break;
		case 0x303: /* 1 100 000 011 */ cp1610_sub(cpustate, 3);			break;
		case 0x304: /* 1 100 000 100 */ cp1610_sub(cpustate, 4);			break;
		case 0x305: /* 1 100 000 101 */ cp1610_sub(cpustate, 5);			break;
		case 0x306: /* 1 100 000 110 */ cp1610_sub(cpustate, 6);			break;
		case 0x307: /* 1 100 000 111 */ cp1610_sub(cpustate, 7);			break;

		case 0x308: /* 1 100 001 000 */ cp1610_subat(cpustate, 1,0);		break;
		case 0x309: /* 1 100 001 001 */ cp1610_subat(cpustate, 1,1);		break;
		case 0x30a: /* 1 100 001 010 */ cp1610_subat(cpustate, 1,2);		break;
		case 0x30b: /* 1 100 001 011 */ cp1610_subat(cpustate, 1,3);		break;
		case 0x30c: /* 1 100 001 100 */ cp1610_subat(cpustate, 1,4);		break;
		case 0x30d: /* 1 100 001 101 */ cp1610_subat(cpustate, 1,5);		break;
		case 0x30e: /* 1 100 001 110 */ cp1610_subat(cpustate, 1,6);		break;
		case 0x30f: /* 1 100 001 111 */ cp1610_subat(cpustate, 1,7);		break;

		case 0x310: /* 1 100 010 000 */ cp1610_subat(cpustate, 2,0);		break;
		case 0x311: /* 1 100 010 001 */ cp1610_subat(cpustate, 2,1);		break;
		case 0x312: /* 1 100 010 010 */ cp1610_subat(cpustate, 2,2);		break;
		case 0x313: /* 1 100 010 011 */ cp1610_subat(cpustate, 2,3);		break;
		case 0x314: /* 1 100 010 100 */ cp1610_subat(cpustate, 2,4);		break;
		case 0x315: /* 1 100 010 101 */ cp1610_subat(cpustate, 2,5);		break;
		case 0x316: /* 1 100 010 110 */ cp1610_subat(cpustate, 2,6);		break;
		case 0x317: /* 1 100 010 111 */ cp1610_subat(cpustate, 2,7);		break;

		case 0x318: /* 1 100 011 000 */ cp1610_subat(cpustate, 3,0);		break;
		case 0x319: /* 1 100 011 001 */ cp1610_subat(cpustate, 3,1);		break;
		case 0x31a: /* 1 100 011 010 */ cp1610_subat(cpustate, 3,2);		break;
		case 0x31b: /* 1 100 011 011 */ cp1610_subat(cpustate, 3,3);		break;
		case 0x31c: /* 1 100 011 100 */ cp1610_subat(cpustate, 3,4);		break;
		case 0x31d: /* 1 100 011 101 */ cp1610_subat(cpustate, 3,5);		break;
		case 0x31e: /* 1 100 011 110 */ cp1610_subat(cpustate, 3,6);		break;
		case 0x31f: /* 1 100 011 111 */ cp1610_subat(cpustate, 3,7);		break;

		case 0x320: /* 1 100 100 000 */ cp1610_subat_i(cpustate, 4,0);	break;
		case 0x321: /* 1 100 100 001 */ cp1610_subat_i(cpustate, 4,1);	break;
		case 0x322: /* 1 100 100 010 */ cp1610_subat_i(cpustate, 4,2);	break;
		case 0x323: /* 1 100 100 011 */ cp1610_subat_i(cpustate, 4,3);	break;
		case 0x324: /* 1 100 100 100 */ cp1610_subat_i(cpustate, 4,4);	break;
		case 0x325: /* 1 100 100 101 */ cp1610_subat_i(cpustate, 4,5);	break;
		case 0x326: /* 1 100 100 110 */ cp1610_subat_i(cpustate, 4,6);	break;
		case 0x327: /* 1 100 100 111 */ cp1610_subat_i(cpustate, 4,7);	break;

		case 0x328: /* 1 100 101 000 */ cp1610_subat_i(cpustate, 5,0);	break;
		case 0x329: /* 1 100 101 001 */ cp1610_subat_i(cpustate, 5,1);	break;
		case 0x32a: /* 1 100 101 010 */ cp1610_subat_i(cpustate, 5,2);	break;
		case 0x32b: /* 1 100 101 011 */ cp1610_subat_i(cpustate, 5,3);	break;
		case 0x32c: /* 1 100 101 100 */ cp1610_subat_i(cpustate, 5,4);	break;
		case 0x32d: /* 1 100 101 101 */ cp1610_subat_i(cpustate, 5,5);	break;
		case 0x32e: /* 1 100 101 110 */ cp1610_subat_i(cpustate, 5,6);	break;
		case 0x32f: /* 1 100 101 111 */ cp1610_subat_i(cpustate, 5,7);	break;

		case 0x330: /* 1 100 110 000 */ cp1610_subat_d(cpustate, 6,0);	break;
		case 0x331: /* 1 100 110 001 */ cp1610_subat_d(cpustate, 6,1);	break;
		case 0x332: /* 1 100 110 010 */ cp1610_subat_d(cpustate, 6,2);	break;
		case 0x333: /* 1 100 110 011 */ cp1610_subat_d(cpustate, 6,3);	break;
		case 0x334: /* 1 100 110 100 */ cp1610_subat_d(cpustate, 6,4);	break;
		case 0x335: /* 1 100 110 101 */ cp1610_subat_d(cpustate, 6,5);	break;
		case 0x336: /* 1 100 110 110 */ cp1610_subat_d(cpustate, 6,6);	break;
		case 0x337: /* 1 100 110 111 */ cp1610_subat_d(cpustate, 6,7);	break;

		case 0x338: /* 1 100 111 000 */ cp1610_subi(cpustate, 0);			break;
		case 0x339: /* 1 100 111 001 */ cp1610_subi(cpustate, 1);			break;
		case 0x33a: /* 1 100 111 010 */ cp1610_subi(cpustate, 2);			break;
		case 0x33b: /* 1 100 111 011 */ cp1610_subi(cpustate, 3);			break;
		case 0x33c: /* 1 100 111 100 */ cp1610_subi(cpustate, 4);			break;
		case 0x33d: /* 1 100 111 101 */ cp1610_subi(cpustate, 5);			break;
		case 0x33e: /* 1 100 111 110 */ cp1610_subi(cpustate, 6);			break;
		case 0x33f: /* 1 100 111 111 */ cp1610_subi(cpustate, 7);			break;

		case 0x340: /* 1 101 000 000 */ cp1610_cmp(cpustate, 0);			break;
		case 0x341: /* 1 101 000 001 */ cp1610_cmp(cpustate, 1);			break;
		case 0x342: /* 1 101 000 010 */ cp1610_cmp(cpustate, 2);			break;
		case 0x343: /* 1 101 000 011 */ cp1610_cmp(cpustate, 3);			break;
		case 0x344: /* 1 101 000 100 */ cp1610_cmp(cpustate, 4);			break;
		case 0x345: /* 1 101 000 101 */ cp1610_cmp(cpustate, 5);			break;
		case 0x346: /* 1 101 000 110 */ cp1610_cmp(cpustate, 6);			break;
		case 0x347: /* 1 101 000 111 */ cp1610_cmp(cpustate, 7);			break;

		case 0x348: /* 1 101 001 000 */ cp1610_cmpat(cpustate, 1,0);		break;
		case 0x349: /* 1 101 001 001 */ cp1610_cmpat(cpustate, 1,1);		break;
		case 0x34a: /* 1 101 001 010 */ cp1610_cmpat(cpustate, 1,2);		break;
		case 0x34b: /* 1 101 001 011 */ cp1610_cmpat(cpustate, 1,3);		break;
		case 0x34c: /* 1 101 001 100 */ cp1610_cmpat(cpustate, 1,4);		break;
		case 0x34d: /* 1 101 001 101 */ cp1610_cmpat(cpustate, 1,5);		break;
		case 0x34e: /* 1 101 001 110 */ cp1610_cmpat(cpustate, 1,6);		break;
		case 0x34f: /* 1 101 001 111 */ cp1610_cmpat(cpustate, 1,7);		break;

		case 0x350: /* 1 101 010 000 */ cp1610_cmpat(cpustate, 2,0);		break;
		case 0x351: /* 1 101 010 001 */ cp1610_cmpat(cpustate, 2,1);		break;
		case 0x352: /* 1 101 010 010 */ cp1610_cmpat(cpustate, 2,2);		break;
		case 0x353: /* 1 101 010 011 */ cp1610_cmpat(cpustate, 2,3);		break;
		case 0x354: /* 1 101 010 100 */ cp1610_cmpat(cpustate, 2,4);		break;
		case 0x355: /* 1 101 010 101 */ cp1610_cmpat(cpustate, 2,5);		break;
		case 0x356: /* 1 101 010 110 */ cp1610_cmpat(cpustate, 2,6);		break;
		case 0x357: /* 1 101 010 111 */ cp1610_cmpat(cpustate, 2,7);		break;

		case 0x358: /* 1 101 011 000 */ cp1610_cmpat(cpustate, 3,0);		break;
		case 0x359: /* 1 101 011 001 */ cp1610_cmpat(cpustate, 3,1);		break;
		case 0x35a: /* 1 101 011 010 */ cp1610_cmpat(cpustate, 3,2);		break;
		case 0x35b: /* 1 101 011 011 */ cp1610_cmpat(cpustate, 3,3);		break;
		case 0x35c: /* 1 101 011 100 */ cp1610_cmpat(cpustate, 3,4);		break;
		case 0x35d: /* 1 101 011 101 */ cp1610_cmpat(cpustate, 3,5);		break;
		case 0x35e: /* 1 101 011 110 */ cp1610_cmpat(cpustate, 3,6);		break;
		case 0x35f: /* 1 101 011 111 */ cp1610_cmpat(cpustate, 3,7);		break;

		case 0x360: /* 1 101 100 000 */ cp1610_cmpat_i(cpustate, 4,0);	break;
		case 0x361: /* 1 101 100 001 */ cp1610_cmpat_i(cpustate, 4,1);	break;
		case 0x362: /* 1 101 100 010 */ cp1610_cmpat_i(cpustate, 4,2);	break;
		case 0x363: /* 1 101 100 011 */ cp1610_cmpat_i(cpustate, 4,3);	break;
		case 0x364: /* 1 101 100 100 */ cp1610_cmpat_i(cpustate, 4,4);	break;
		case 0x365: /* 1 101 100 101 */ cp1610_cmpat_i(cpustate, 4,5);	break;
		case 0x366: /* 1 101 100 110 */ cp1610_cmpat_i(cpustate, 4,6);	break;
		case 0x367: /* 1 101 100 111 */ cp1610_cmpat_i(cpustate, 4,7);	break;

		case 0x368: /* 1 101 101 000 */ cp1610_cmpat_i(cpustate, 5,0);	break;
		case 0x369: /* 1 101 101 001 */ cp1610_cmpat_i(cpustate, 5,1);	break;
		case 0x36a: /* 1 101 101 010 */ cp1610_cmpat_i(cpustate, 5,2);	break;
		case 0x36b: /* 1 101 101 011 */ cp1610_cmpat_i(cpustate, 5,3);	break;
		case 0x36c: /* 1 101 101 100 */ cp1610_cmpat_i(cpustate, 5,4);	break;
		case 0x36d: /* 1 101 101 101 */ cp1610_cmpat_i(cpustate, 5,5);	break;
		case 0x36e: /* 1 101 101 110 */ cp1610_cmpat_i(cpustate, 5,6);	break;
		case 0x36f: /* 1 101 101 111 */ cp1610_cmpat_i(cpustate, 5,7);	break;

		case 0x370: /* 1 101 110 000 */ cp1610_cmpat_d(cpustate, 6,0);	break;
		case 0x371: /* 1 101 110 001 */ cp1610_cmpat_d(cpustate, 6,1);	break;
		case 0x372: /* 1 101 110 010 */ cp1610_cmpat_d(cpustate, 6,2);	break;
		case 0x373: /* 1 101 110 011 */ cp1610_cmpat_d(cpustate, 6,3);	break;
		case 0x374: /* 1 101 110 100 */ cp1610_cmpat_d(cpustate, 6,4);	break;
		case 0x375: /* 1 101 110 101 */ cp1610_cmpat_d(cpustate, 6,5);	break;
		case 0x376: /* 1 101 110 110 */ cp1610_cmpat_d(cpustate, 6,6);	break;
		case 0x377: /* 1 101 110 111 */ cp1610_cmpat_d(cpustate, 6,7);	break;

		case 0x378: /* 1 101 111 000 */ cp1610_cmpi(cpustate, 0);			break;
		case 0x379: /* 1 101 111 001 */ cp1610_cmpi(cpustate, 1);			break;
		case 0x37a: /* 1 101 111 010 */ cp1610_cmpi(cpustate, 2);			break;
		case 0x37b: /* 1 101 111 011 */ cp1610_cmpi(cpustate, 3);			break;
		case 0x37c: /* 1 101 111 100 */ cp1610_cmpi(cpustate, 4);			break;
		case 0x37d: /* 1 101 111 101 */ cp1610_cmpi(cpustate, 5);			break;
		case 0x37e: /* 1 101 111 110 */ cp1610_cmpi(cpustate, 6);			break;
		case 0x37f: /* 1 101 111 111 */ cp1610_cmpi(cpustate, 7);			break;

		case 0x380: /* 1 110 000 000 */ cp1610_and(cpustate, 0);			break;
		case 0x381: /* 1 110 000 001 */ cp1610_and(cpustate, 1);			break;
		case 0x382: /* 1 110 000 010 */ cp1610_and(cpustate, 2);			break;
		case 0x383: /* 1 110 000 011 */ cp1610_and(cpustate, 3);			break;
		case 0x384: /* 1 110 000 100 */ cp1610_and(cpustate, 4);			break;
		case 0x385: /* 1 110 000 101 */ cp1610_and(cpustate, 5);			break;
		case 0x386: /* 1 110 000 110 */ cp1610_and(cpustate, 6);			break;
		case 0x387: /* 1 110 000 111 */ cp1610_and(cpustate, 7);			break;

		case 0x388: /* 1 110 001 000 */ cp1610_andat(cpustate, 1,0);		break;
		case 0x389: /* 1 110 001 001 */ cp1610_andat(cpustate, 1,1);		break;
		case 0x38a: /* 1 110 001 010 */ cp1610_andat(cpustate, 1,2);		break;
		case 0x38b: /* 1 110 001 011 */ cp1610_andat(cpustate, 1,3);		break;
		case 0x38c: /* 1 110 001 100 */ cp1610_andat(cpustate, 1,4);		break;
		case 0x38d: /* 1 110 001 101 */ cp1610_andat(cpustate, 1,5);		break;
		case 0x38e: /* 1 110 001 110 */ cp1610_andat(cpustate, 1,6);		break;
		case 0x38f: /* 1 110 001 111 */ cp1610_andat(cpustate, 1,7);		break;

		case 0x390: /* 1 110 010 000 */ cp1610_andat(cpustate, 2,0);		break;
		case 0x391: /* 1 110 010 001 */ cp1610_andat(cpustate, 2,1);		break;
		case 0x392: /* 1 110 010 010 */ cp1610_andat(cpustate, 2,2);		break;
		case 0x393: /* 1 110 010 011 */ cp1610_andat(cpustate, 2,3);		break;
		case 0x394: /* 1 110 010 100 */ cp1610_andat(cpustate, 2,4);		break;
		case 0x395: /* 1 110 010 101 */ cp1610_andat(cpustate, 2,5);		break;
		case 0x396: /* 1 110 010 110 */ cp1610_andat(cpustate, 2,6);		break;
		case 0x397: /* 1 110 010 111 */ cp1610_andat(cpustate, 2,7);		break;

		case 0x398: /* 1 110 011 000 */ cp1610_andat(cpustate, 3,0);		break;
		case 0x399: /* 1 110 011 001 */ cp1610_andat(cpustate, 3,1);		break;
		case 0x39a: /* 1 110 011 010 */ cp1610_andat(cpustate, 3,2);		break;
		case 0x39b: /* 1 110 011 011 */ cp1610_andat(cpustate, 3,3);		break;
		case 0x39c: /* 1 110 011 100 */ cp1610_andat(cpustate, 3,4);		break;
		case 0x39d: /* 1 110 011 101 */ cp1610_andat(cpustate, 3,5);		break;
		case 0x39e: /* 1 110 011 110 */ cp1610_andat(cpustate, 3,6);		break;
		case 0x39f: /* 1 110 011 111 */ cp1610_andat(cpustate, 3,7);		break;

		case 0x3a0: /* 1 110 100 000 */ cp1610_andat_i(cpustate, 4,0);	break;
		case 0x3a1: /* 1 110 100 001 */ cp1610_andat_i(cpustate, 4,1);	break;
		case 0x3a2: /* 1 110 100 010 */ cp1610_andat_i(cpustate, 4,2);	break;
		case 0x3a3: /* 1 110 100 011 */ cp1610_andat_i(cpustate, 4,3);	break;
		case 0x3a4: /* 1 110 100 100 */ cp1610_andat_i(cpustate, 4,4);	break;
		case 0x3a5: /* 1 110 100 101 */ cp1610_andat_i(cpustate, 4,5);	break;
		case 0x3a6: /* 1 110 100 110 */ cp1610_andat_i(cpustate, 4,6);	break;
		case 0x3a7: /* 1 110 100 111 */ cp1610_andat_i(cpustate, 4,7);	break;

		case 0x3a8: /* 1 110 101 000 */ cp1610_andat_i(cpustate, 5,0);	break;
		case 0x3a9: /* 1 110 101 001 */ cp1610_andat_i(cpustate, 5,1);	break;
		case 0x3aa: /* 1 110 101 010 */ cp1610_andat_i(cpustate, 5,2);	break;
		case 0x3ab: /* 1 110 101 011 */ cp1610_andat_i(cpustate, 5,3);	break;
		case 0x3ac: /* 1 110 101 100 */ cp1610_andat_i(cpustate, 5,4);	break;
		case 0x3ad: /* 1 110 101 101 */ cp1610_andat_i(cpustate, 5,5);	break;
		case 0x3ae: /* 1 110 101 110 */ cp1610_andat_i(cpustate, 5,6);	break;
		case 0x3af: /* 1 110 101 111 */ cp1610_andat_i(cpustate, 5,7);	break;

		case 0x3b0: /* 1 110 110 000 */ cp1610_andat_d(cpustate, 6,0);	break;
		case 0x3b1: /* 1 110 110 001 */ cp1610_andat_d(cpustate, 6,1);	break;
		case 0x3b2: /* 1 110 110 010 */ cp1610_andat_d(cpustate, 6,2);	break;
		case 0x3b3: /* 1 110 110 011 */ cp1610_andat_d(cpustate, 6,3);	break;
		case 0x3b4: /* 1 110 110 100 */ cp1610_andat_d(cpustate, 6,4);	break;
		case 0x3b5: /* 1 110 110 101 */ cp1610_andat_d(cpustate, 6,5);	break;
		case 0x3b6: /* 1 110 110 110 */ cp1610_andat_d(cpustate, 6,6);	break;
		case 0x3b7: /* 1 110 110 111 */ cp1610_andat_d(cpustate, 6,7);	break;

		case 0x3b8: /* 1 110 111 000 */ cp1610_andi(cpustate, 0);			break;
		case 0x3b9: /* 1 110 111 001 */ cp1610_andi(cpustate, 1);			break;
		case 0x3ba: /* 1 110 111 010 */ cp1610_andi(cpustate, 2);			break;
		case 0x3bb: /* 1 110 111 011 */ cp1610_andi(cpustate, 3);			break;
		case 0x3bc: /* 1 110 111 100 */ cp1610_andi(cpustate, 4);			break;
		case 0x3bd: /* 1 110 111 101 */ cp1610_andi(cpustate, 5);			break;
		case 0x3be: /* 1 110 111 110 */ cp1610_andi(cpustate, 6);			break;
		case 0x3bf: /* 1 110 111 111 */ cp1610_andi(cpustate, 7);			break;

		case 0x3c0: /* 1 111 000 000 */ cp1610_xor(cpustate, 0);			break;
		case 0x3c1: /* 1 111 000 001 */ cp1610_xor(cpustate, 1);			break;
		case 0x3c2: /* 1 111 000 010 */ cp1610_xor(cpustate, 2);			break;
		case 0x3c3: /* 1 111 000 011 */ cp1610_xor(cpustate, 3);			break;
		case 0x3c4: /* 1 111 000 100 */ cp1610_xor(cpustate, 4);			break;
		case 0x3c5: /* 1 111 000 101 */ cp1610_xor(cpustate, 5);			break;
		case 0x3c6: /* 1 111 000 110 */ cp1610_xor(cpustate, 6);			break;
		case 0x3c7: /* 1 111 000 111 */ cp1610_xor(cpustate, 7);			break;

		case 0x3c8: /* 1 111 001 000 */ cp1610_xorat(cpustate, 1,0);		break;
		case 0x3c9: /* 1 111 001 001 */ cp1610_xorat(cpustate, 1,1);		break;
		case 0x3ca: /* 1 111 001 010 */ cp1610_xorat(cpustate, 1,2);		break;
		case 0x3cb: /* 1 111 001 011 */ cp1610_xorat(cpustate, 1,3);		break;
		case 0x3cc: /* 1 111 001 100 */ cp1610_xorat(cpustate, 1,4);		break;
		case 0x3cd: /* 1 111 001 101 */ cp1610_xorat(cpustate, 1,5);		break;
		case 0x3ce: /* 1 111 001 110 */ cp1610_xorat(cpustate, 1,6);		break;
		case 0x3cf: /* 1 111 001 111 */ cp1610_xorat(cpustate, 1,7);		break;

		case 0x3d0: /* 1 111 010 000 */ cp1610_xorat(cpustate, 2,0);		break;
		case 0x3d1: /* 1 111 010 001 */ cp1610_xorat(cpustate, 2,1);		break;
		case 0x3d2: /* 1 111 010 010 */ cp1610_xorat(cpustate, 2,2);		break;
		case 0x3d3: /* 1 111 010 011 */ cp1610_xorat(cpustate, 2,3);		break;
		case 0x3d4: /* 1 111 010 100 */ cp1610_xorat(cpustate, 2,4);		break;
		case 0x3d5: /* 1 111 010 101 */ cp1610_xorat(cpustate, 2,5);		break;
		case 0x3d6: /* 1 111 010 110 */ cp1610_xorat(cpustate, 2,6);		break;
		case 0x3d7: /* 1 111 010 111 */ cp1610_xorat(cpustate, 2,7);		break;

		case 0x3d8: /* 1 111 011 000 */ cp1610_xorat(cpustate, 3,0);		break;
		case 0x3d9: /* 1 111 011 001 */ cp1610_xorat(cpustate, 3,1);		break;
		case 0x3da: /* 1 111 011 010 */ cp1610_xorat(cpustate, 3,2);		break;
		case 0x3db: /* 1 111 011 011 */ cp1610_xorat(cpustate, 3,3);		break;
		case 0x3dc: /* 1 111 011 100 */ cp1610_xorat(cpustate, 3,4);		break;
		case 0x3dd: /* 1 111 011 101 */ cp1610_xorat(cpustate, 3,5);		break;
		case 0x3de: /* 1 111 011 110 */ cp1610_xorat(cpustate, 3,6);		break;
		case 0x3df: /* 1 111 011 111 */ cp1610_xorat(cpustate, 3,7);		break;

		case 0x3e0: /* 1 111 100 000 */ cp1610_xorat_i(cpustate, 4,0);	break;
		case 0x3e1: /* 1 111 100 001 */ cp1610_xorat_i(cpustate, 4,1);	break;
		case 0x3e2: /* 1 111 100 010 */ cp1610_xorat_i(cpustate, 4,2);	break;
		case 0x3e3: /* 1 111 100 011 */ cp1610_xorat_i(cpustate, 4,3);	break;
		case 0x3e4: /* 1 111 100 100 */ cp1610_xorat_i(cpustate, 4,4);	break;
		case 0x3e5: /* 1 111 100 101 */ cp1610_xorat_i(cpustate, 4,5);	break;
		case 0x3e6: /* 1 111 100 110 */ cp1610_xorat_i(cpustate, 4,6);	break;
		case 0x3e7: /* 1 111 100 111 */ cp1610_xorat_i(cpustate, 4,7);	break;

		case 0x3e8: /* 1 111 101 000 */ cp1610_xorat_i(cpustate, 5,0);	break;
		case 0x3e9: /* 1 111 101 001 */ cp1610_xorat_i(cpustate, 5,1);	break;
		case 0x3ea: /* 1 111 101 010 */ cp1610_xorat_i(cpustate, 5,2);	break;
		case 0x3eb: /* 1 111 101 011 */ cp1610_xorat_i(cpustate, 5,3);	break;
		case 0x3ec: /* 1 111 101 100 */ cp1610_xorat_i(cpustate, 5,4);	break;
		case 0x3ed: /* 1 111 101 101 */ cp1610_xorat_i(cpustate, 5,5);	break;
		case 0x3ee: /* 1 111 101 110 */ cp1610_xorat_i(cpustate, 5,6);	break;
		case 0x3ef: /* 1 111 101 111 */ cp1610_xorat_i(cpustate, 5,7);	break;

		case 0x3f0: /* 1 111 110 000 */ cp1610_xorat_d(cpustate, 6,0);	break;
		case 0x3f1: /* 1 111 110 001 */ cp1610_xorat_d(cpustate, 6,1);	break;
		case 0x3f2: /* 1 111 110 010 */ cp1610_xorat_d(cpustate, 6,2);	break;
		case 0x3f3: /* 1 111 110 011 */ cp1610_xorat_d(cpustate, 6,3);	break;
		case 0x3f4: /* 1 111 110 100 */ cp1610_xorat_d(cpustate, 6,4);	break;
		case 0x3f5: /* 1 111 110 101 */ cp1610_xorat_d(cpustate, 6,5);	break;
		case 0x3f6: /* 1 111 110 110 */ cp1610_xorat_d(cpustate, 6,6);	break;
		case 0x3f7: /* 1 111 110 111 */ cp1610_xorat_d(cpustate, 6,7);	break;

		case 0x3f8: /* 1 111 111 000 */ cp1610_xori(cpustate, 0);			break;
		case 0x3f9: /* 1 111 111 001 */ cp1610_xori(cpustate, 1);			break;
		case 0x3fa: /* 1 111 111 010 */ cp1610_xori(cpustate, 2);			break;
		case 0x3fb: /* 1 111 111 011 */ cp1610_xori(cpustate, 3);			break;
		case 0x3fc: /* 1 111 111 100 */ cp1610_xori(cpustate, 4);			break;
		case 0x3fd: /* 1 111 111 101 */ cp1610_xori(cpustate, 5);			break;
		case 0x3fe: /* 1 111 111 110 */ cp1610_xori(cpustate, 6);			break;
		case 0x3ff: /* 1 111 111 111 */ cp1610_xori(cpustate, 7);			break;
        }

        if (cpustate->mask_interrupts == 0)
        {
			if (cpustate->intr_pending == 1)
			{
				/* PSHR R7 */
				cp1610_writemem16(cpustate->r[6],cpustate->r[7]);
				cpustate->r[6]++;
				cpustate->icount -= 9;
				cpustate->intr_pending = 0;
				cpustate->r[7] = cpustate->irq_callback(cpustate->device, CP1610_INT_INTR);
			}
			if ((cpustate->intrm_pending == 1) && (cpustate->intr_enabled))
			{
				/* PSHR R7 */
				cp1610_writemem16(cpustate->r[6],cpustate->r[7]);
				cpustate->r[6]++;
				cpustate->icount -= 9;
				cpustate->intrm_pending = 0;
				cpustate->r[7] = cpustate->irq_callback(cpustate->device, CP1610_INT_INTRM);
			}
			if (cpustate->reset_pending == 1)
			{
				cpustate->reset_pending = 0;
				cpustate->r[7] = cpustate->irq_callback(cpustate->device, CP1610_RESET);
			}
		}

	} while( cpustate->icount > 0 );

	return cycles - cpustate->icount;
}

static CPU_INIT( cp1610 )
{
	cp1610_state *cpustate = get_safe_token(device);
	cpustate->intr_enabled = 0;
	cpustate->reset_pending = 0;
	cpustate->intr_pending = 0;
	cpustate->intrm_pending = 0;
	cpustate->irq_callback = irqcallback;
	cpustate->device = device;
	cpustate->program = device->space(AS_PROGRAM);

	state_save_register_device_item_array(device, 0, cpustate->r);
	state_save_register_device_item(device, 0, cpustate->flags);
	state_save_register_device_item(device, 0, cpustate->intr_enabled);
	state_save_register_device_item(device, 0, cpustate->intr_vector);
	state_save_register_device_item(device, 0, cpustate->reset_state);
	state_save_register_device_item(device, 0, cpustate->intr_state);
	state_save_register_device_item(device, 0, cpustate->intrm_state);
	state_save_register_device_item(device, 0, cpustate->reset_pending);
	state_save_register_device_item(device, 0, cpustate->intr_pending);
	state_save_register_device_item(device, 0, cpustate->intrm_pending);
	state_save_register_device_item(device, 0, cpustate->mask_interrupts);
}

static void cp1610_set_irq_line(cp1610_state *cpustate, UINT32 irqline, int state)
{
	switch(irqline)
	{
		case CP1610_INT_INTRM:
			if (state == ASSERT_LINE)
				cpustate->intrm_pending = 1;
			cpustate->intrm_state = state;
			break;
		case CP1610_RESET:
			if (state == ASSERT_LINE)
				cpustate->reset_pending = 1;
			cpustate->reset_state = state;
			break;
		case CP1610_INT_INTR:
			if (state == ASSERT_LINE)
				cpustate->intr_pending = 1;
			cpustate->intr_state = state;
			break;
	}
}

static CPU_SET_INFO( cp1610 )
{
	cp1610_state *cpustate = get_safe_token(device);
	switch (state)
	{
	/* --- the following bits of info are returned as 64-bit signed integers --- */
	case CPUINFO_INT_PREVIOUSPC:	break;	/* TODO? */
	case CPUINFO_INT_INPUT_STATE + CP1610_INT_INTRM:
	case CPUINFO_INT_INPUT_STATE + CP1610_RESET:
	case CPUINFO_INT_INPUT_STATE + CP1610_INT_INTR:
			cp1610_set_irq_line(cpustate, state-CPUINFO_INT_INPUT_STATE, info->i);		break;

	case CPUINFO_INT_REGISTER + CP1610_R0: cpustate->r[0] = info->i;			break;
	case CPUINFO_INT_REGISTER + CP1610_R1: cpustate->r[1] = info->i;			break;
	case CPUINFO_INT_REGISTER + CP1610_R2: cpustate->r[2] = info->i;			break;
	case CPUINFO_INT_REGISTER + CP1610_R3: cpustate->r[3] = info->i;			break;
	case CPUINFO_INT_REGISTER + CP1610_R4: cpustate->r[4] = info->i;			break;
	case CPUINFO_INT_REGISTER + CP1610_R5: cpustate->r[5] = info->i;			break;
	case CPUINFO_INT_SP:
	case CPUINFO_INT_REGISTER + CP1610_R6: cpustate->r[6] = info->i;			break;
	case CPUINFO_INT_PC:
	case CPUINFO_INT_REGISTER + CP1610_R7: cpustate->r[7] = info->i;			break;
	}
	return;
}

CPU_GET_INFO( cp1610 )
{
	cp1610_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL;
	switch (state)
	{
	/* --- the following bits of info are returned as 64-bit signed integers --- */
	case CPUINFO_INT_CONTEXT_SIZE:					info->i = sizeof(cp1610_state);	break;
	case CPUINFO_INT_INPUT_LINES:						info->i = 2;			break;
	case CPUINFO_INT_DEFAULT_IRQ_VECTOR:			info->i = 0;			break;
	case DEVINFO_INT_ENDIANNESS:					info->i = ENDIANNESS_BIG;	break;
	case CPUINFO_INT_CLOCK_MULTIPLIER:				info->i = 1;			break;
	case CPUINFO_INT_CLOCK_DIVIDER:					info->i = 1;			break;
	case CPUINFO_INT_MIN_INSTRUCTION_BYTES:			info->i = 2;			break;
	case CPUINFO_INT_MAX_INSTRUCTION_BYTES:			info->i = 8;			break;
	case CPUINFO_INT_MIN_CYCLES:					info->i = 1;			break;
	case CPUINFO_INT_MAX_CYCLES:					info->i = 7;			break;

	case DEVINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_PROGRAM:	info->i = 16;	break;
	case DEVINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 16;	break;
	case DEVINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_PROGRAM: info->i = -1;	break;
	case DEVINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_DATA:	info->i = 0;	break;
	case DEVINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_DATA:	info->i = 0;	break;
	case DEVINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_DATA:	info->i = 0;	break;
	case DEVINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_IO:		info->i = 0;	break;
	case DEVINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_IO:		info->i = 0;	break;
	case DEVINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_IO:		info->i = 0;	break;

	case CPUINFO_INT_PREVIOUSPC:		info->i = 0;	/* TODO??? */		break;

	case CPUINFO_INT_INPUT_STATE + CP1610_INT_INTRM:	info->i = cpustate->intrm_state;	break;
	case CPUINFO_INT_INPUT_STATE + CP1610_RESET:		info->i = cpustate->reset_state;	break;
	case CPUINFO_INT_INPUT_STATE + CP1610_INT_INTR:	info->i = cpustate->intr_state;	break;

	case CPUINFO_INT_REGISTER + CP1610_R0: info->i = cpustate->r[0];			break;
	case CPUINFO_INT_REGISTER + CP1610_R1: info->i = cpustate->r[1];			break;
	case CPUINFO_INT_REGISTER + CP1610_R2: info->i = cpustate->r[2];			break;
	case CPUINFO_INT_REGISTER + CP1610_R3: info->i = cpustate->r[3];			break;
	case CPUINFO_INT_REGISTER + CP1610_R4: info->i = cpustate->r[4];			break;
	case CPUINFO_INT_REGISTER + CP1610_R5: info->i = cpustate->r[5];			break;
	case CPUINFO_INT_SP:
	case CPUINFO_INT_REGISTER + CP1610_R6: info->i = cpustate->r[6];			break;
	case CPUINFO_INT_PC:
	case CPUINFO_INT_REGISTER + CP1610_R7: info->i = cpustate->r[7];			break;

	/* --- the following bits of info are returned as pointers to data or functions --- */
	case CPUINFO_FCT_SET_INFO:						info->setinfo = CPU_SET_INFO_NAME(cp1610);		break;
	case CPUINFO_FCT_INIT:							info->init = CPU_INIT_NAME(cp1610);				break;
	case CPUINFO_FCT_RESET:							info->reset = CPU_RESET_NAME(cp1610);				break;
	case CPUINFO_FCT_EXECUTE:						info->execute = CPU_EXECUTE_NAME(cp1610);			break;
	case CPUINFO_FCT_BURN:							info->burn = NULL;						break;

	case CPUINFO_FCT_DISASSEMBLE:					info->disassemble = CPU_DISASSEMBLE_NAME(cp1610);		break;
	case CPUINFO_PTR_INSTRUCTION_COUNTER:			info->icount = &cpustate->icount;			break;

	/* --- the following bits of info are returned as NULL-terminated strings --- */
	case DEVINFO_STR_NAME:			strcpy(info->s, "CP1610");		break;
	case DEVINFO_STR_FAMILY:	strcpy(info->s, "");				break;
	case DEVINFO_STR_VERSION:	strcpy(info->s, "1.0");			break;
	case DEVINFO_STR_SOURCE_FILE:		strcpy(info->s, __FILE__);		break;
	case DEVINFO_STR_CREDITS:	strcpy(info->s,
									"Copyright Frank Palazzolo, all rights reserved.");
									break;
    case CPUINFO_STR_FLAGS:
			sprintf(info->s, "%c%c%c%c",
				cpustate->flags & 0x80 ? 'S':'.',
				cpustate->flags & 0x40 ? 'Z':'.',
				cpustate->flags & 0x20 ? 'V':'.',
				cpustate->flags & 0x10 ? 'C':'.');
			break;
	case CPUINFO_STR_REGISTER+CP1610_R0: sprintf(info->s, "R0:%04X", cpustate->r[0]); break;
	case CPUINFO_STR_REGISTER+CP1610_R1: sprintf(info->s, "R1:%04X", cpustate->r[1]); break;
	case CPUINFO_STR_REGISTER+CP1610_R2: sprintf(info->s, "R2:%04X", cpustate->r[2]); break;
	case CPUINFO_STR_REGISTER+CP1610_R3: sprintf(info->s, "R3:%04X", cpustate->r[3]); break;
	case CPUINFO_STR_REGISTER+CP1610_R4: sprintf(info->s, "R4:%04X", cpustate->r[4]); break;
	case CPUINFO_STR_REGISTER+CP1610_R5: sprintf(info->s, "R5:%04X", cpustate->r[5]); break;
	case CPUINFO_STR_REGISTER+CP1610_R6: sprintf(info->s, "R6:%04X", cpustate->r[6]); break;
	case CPUINFO_STR_REGISTER+CP1610_R7: sprintf(info->s, "R7:%04X", cpustate->r[7]); break;
	}

	return;
}