summaryrefslogtreecommitdiff
path: root/z180/ddtz.180
blob: d18330c2c10c0c354d90e374b3a3bd207975d6a4 (plain)
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
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
	page	255
	.z80

	extrn	?const,?conin,?cono
	extrn	getiff
	extrn	selbnk,@cbnk

	global	ddtz,bpent
	global	$stack


	include config.inc
	if CPU_Z180
	include	z180reg.inc
	include z180.lib
	endif

BS	equ	08h
TAB	equ	09h
CR	equ	0dh
LF	equ	0ah
DEL	equ	7fh
CNTRX	equ	'X'-'@'

TPA	equ	100h
TOPRAM	equ	0f000h


MEMDUMP_CNT	equ	16		;mem dump bytes per line
BP_CNT 		equ	12		;number of breakbpoints


;--------------------------------------------------
;

; copy code to common memory and execute it there
comst	macro
	call	?excom
	ds	1
?lcs	defl	$
	endm

; mark end of common code snippet
comend	macro
?lce	defl	$
?lclen	defl	?lce-?lcs
	org	?lcs-1
	db	?lclen
	org	?lce
	ifndef	?lcmax
?lcmax	defl	0
	endif
	if	?lclen gt ?lcmax
?lcmax	defl	?lclen
	endif
	endm




	cseg

;----------------------------------------------------------

MSG:
	DB	'DDT/Z - HD64180  (ROM)'
	DB	CR,LF,0

HLPMSG:
	DB 'DDT/Z180 (ROM) Commands:',CR,LF
	DB '> @                             examine/substitute the displacement register @',CR,LF
	DB '> A [address]                   Assemble',CR,LF
	DB '> B[X]                          display [or clear] all Breakpoints',CR,LF
	DB '  B breakp [:count] [breakp..]  set Breakpoints',CR,LF
	DB '  BX address [address..]        clear Breakpoints',CR,LF
	DB '>>C[N][J] [count]               trace over Calls [No list] [Jumps only]',CR,LF
	DB '  C[N][J] W|U expression        trace over Calls While|Until ...',CR,LF
	DB '>>D [startadr] [endadr]         Display memory in hex and ascii',CR,LF
	DB '> G [startadr] [;breakp..]      Go [to start] [temporary breakpoints]',CR,LF
	DB '> H [expression [expression]]   compute expressions / show High/max load adr.',CR,LF
	DB '>>I [port]                      Input a byte from port',CR,LF
	DB '>>L [startadr] [endadr]         List disassembled code',CR,LF
	DB '> M[V] startadr endadr destadr  Move memory [and verify]',CR,LF
	DB '>>O [byte] [port]               Output a byte to port',CR,LF
	DB '> Q[J] startadr endadr bytes    Qery memory for byte string [Justified]',CR,LF
	DB '> R [displacement]              Read intel hex from console [add displacemt]',CR,LF
	DB '> S address                     Substitute memory',CR,LF
	DB '>>T[N][J] [count]               Trace [No list] [Jumps only] [count steps]',CR,LF
	DB '  T[N][J] W|U expression        Trace While|Until expression',CR,LF
	DB '> V startadr endadr destadr     Verify (compare) two memory areas',CR,LF
	DB '> X[register]                   eXamine [and substitute] registers',CR,LF
	DB '> Y[0..9]                       eXamine [and substitute] Y variables',CR,LF
	DB '> Z startadr endadr bytes       Zap (fill) memory with a byte string',CR,LF
	DB 0

ddtz:
	ld	sp,$stack
	ld	a,(wstrtflg)		;check warm start flag
	or	a
;;;	jr	nz,ddtz_w

	exx
	ld	hl,sysramc
	ld	de,topcodbeg
	ld	bc,topcodend-topcodbeg
	ldir

	exx

	if CPU_Z180
	ld	a,e
	ld	(ubbr),a
	endif

ddtz_w:
	ld hl,MSG
	call PSTR
	call ddtei

; DDTZ main loop

DDTZML:
	ld sp,$stack
	ld hl,l07eah
	ld (CMD_ERR),hl
	ld hl,(REG.PC)
	ld (OFFS.pc),hl
	call sub_0e68h
	ld hl,(CMD_RPT)
	ld de,DDTZML
	call CP.HL.DE
	ld a,'>'
	call OUTCHAR
	call nz,OUTCHAR
	call z,OUTBL
	call INLINE
	call SKIPBL
	jr z,exe_hl
	ld hl,DDTZML
	ld (CMD_RPT),hl
	inc de
	sub '?'
	jr c,ERROR
	cp 'Z'+1-'?'
	jr nc,ERROR
	add a,a
	ld hl,CMDTAB
	call ADD_HL_A
	ld a,(hl)
	inc hl
	ld h,(hl)
	ld l,a
	jr exe_hl
ERROR:
	ld hl,(CMD_ERR)
exe_hl:
	call CALL.HL
	jr DDTZML

CALL.HL:
	jp (hl)


CMDTAB:
	defw CMD.?		;Help
	defw CMD.@		;Offset
	defw CMD.A		;Assemble
	defw CMD.B		;Breakpoint
	defw CMD.C		;Call
	defw CMD.D		;Display
	defw ERROR		;
	defw ERROR		;
	defw CMD.G		;Go
	defw CMD.H		;Hex Math
	defw CMD.I		;In Port
	defw ERROR		;
	defw ERROR		;
	defw CMD.L		;List
	defw CMD.M		;Move
	defw ERROR		;
	defw CMD.O		;Out Port
	defw ERROR		;
	defw CMD.Q		;Query
	defw CMD.R		;Read Intel Hex
	defw CMD.S		;Substitute
	defw CMD.T		;Trace
	defw ERROR		;
	defw CMD.V		;Verify
	defw ERROR		;
	defw CMD.X		;eXamine
	defw CMD.Y		;eXamine Y Registers
	defw CMD.Z		;Zap (fill) memory
l07eah:
	ld a,'?'
	call OUTCHAR
	jp CRLF

CMD.?:
	call	assert_eol
	ld	hl,HLPMSG
	call	PSTR
	ret

$ci:
	push	hl
	push	de
	push	bc
	call	?conin
	pop	bc
	pop	de
	pop	hl
	ret

$co:
	push	hl
	push	de
	push	bc
	ld	c,a
	call	?cono
	pop	bc
	pop	de
	pop	hl
	ret

DELC:
	ld	a,b
	or	a
	ret	z
	call	DELC1
	dec	hl
	dec	b
	inc	c
	ld	a,(hl)
	cp	' '
	ret	nc
DELC1:
	push	de
	push	hl
	push	bc
	ld	c,BS
	call	?cono
	ld	c,' '
	call	?cono
	ld	c,BS
	call	?cono
	pop	bc
	pop	hl
	pop	de
	ret

DELL:
	ld a,b			;
	or a			;
	ret z			;
	call DELC		;
	jr DELL			;

INLINE:
	push hl			;
	ld hl,CI.BUF		;
	ld c,(hl)		;
	inc hl			;
	ld b,000h		;
	inc hl			;
inlnxtch:
	ld a,c			;
	or a			;
	jr z,inl_e		;
	call $ci		;
	cp CR			;
	jr z,inl_e		;Accept line
	cp LF			;
	jr z,inl_e		;Accept line
	cp BS			;
	jr nz,l0844h		;
	call DELC		;Delete Char
	jr inlnxtch		;
l0844h:
	cp DEL			;
	jr nz,l084dh		;
	call DELC		;Delete Char
	jr inlnxtch		;
l084dh:
	cp CNTRX		;
	jr nz,l0856h		;
	call DELL		;Delete Line
	jr inlnxtch		;
l0856h:
	cp TAB			;
	jr nz,l085ch		;
	ld a,' '		;
l085ch:
	ld (hl),a		;
	cp ' '			;
	jr nc,l0869h		;
	ld a,'^'		;Controll characters
	call $co		;
	ld a,(hl)		;
	add a,'@'		;
l0869h:
	call $co		;
	inc hl			;
	inc b			;
	dec c			;
	jr inlnxtch		;

inl_e:
	ld hl,ci.buf+1		;
	ld (hl),b		;
	call CRLF		;
	ld de,ci.buf+1		;
	ld a,(de)		;
	ld b,a			;
	ld c,000h		;
	inc b			;
l0880h:
	inc de			;
	dec b			;
	jr z,l08b2h		;
	ld a,(de)		;
	bit 0,c			;
	call z,UPCASE		;
	ld (de),a		;
	cp ''''			;
	jr nz,l0880h		;
	push de			;
	dec de			;
	ld a,(de)		;
	cp ''''			;
	jr z,l08aeh		;
	dec de			;
	ld a,(de)		;
	cp '^'			;
	jr z,l08a2h		;
	dec de			;
	ld a,(de)		;
	cp '^'			;
	jr nz,l08aeh		;
l08a2h:
	inc de			;
	push bc			;
	call sub_0a0eh		;
	pop bc			;
	dec de			;
	ld a,(de)		;
	cp ''''			;
	jr z,l08afh		;
l08aeh:
	inc c			;
l08afh:
	pop de			;
	jr l0880h		;
l08b2h:
	xor a			;
	ld (de),a		;
	ld de,ci.buf+2		;
	pop hl			;
	ret			;

UPCASE:
	cp 'a'			;
	ret c			;
	cp 'z'+1		;
	ret nc			;
	and 05fh		;
	ret			;

out.hl.@:
	call out.hl		;
	push de			;
	push hl			;
	ld de,(offs.@)		;
	ld a,d			;
	or e			;
	jr z,l08ddh		;
	call OUTBL		;
	ld a,'@'		;
	call OUTCHAR		;
	and a			;
	sbc hl,de		;
	call out.hl		;
l08ddh:
	pop hl			;
	pop de			;
	ret			;

out.bin.w:
	ld a,h			;
	call out.bin.b		;
	ld a,l			;
out.bin.b:
	ld b,008h		;
l08e7h:
	add a,a			;
	push af			;
	ld a,0			;
	adc a,a			;
	call out.digit		;
	pop af			;
	djnz l08e7h		;
	ld a,'"'		;
	jp OUTCHAR		;

sub_08f7h:
	ld a,'-'		;
	call OUTCHAR		;
	dec hl			;
	jp cpl.hl		;

out.hl.decm:
	push hl			;
	call sub_08f7h		;
	db	3eh		;  ld a,0E5h
out.hl.dec:
	push	hl
	ld b,6			;
	call sub_0917h		;
	pop hl			;
	ld a,'.'		;
	call OUTCHAR		;
l0911h:
	call OUTBL		;
	djnz l0911h		;
	ret			;


sub_0917h:
	dec b
	push de
	ld de,10
	call DIV_HL_DE
	ld a,h
	or l
	call nz,sub_0917h
	ld a,e
	pop de
	jr out.digit

sub_0928h:
	push hl
	call sub_08f7h
	call out.hl
	pop hl
	ret
out.hl:
	ld a,h
	call out.hex
	ld a,l
out.hex:
	push af
	rra
	rra
	rra
	rra
	call out.digit
	pop af
out.digit:
	and 00fh
	cp 10
	jr c,l0947h
	add a,007h
l0947h:
	add a,'0'
	jr OUTCHAR
l094bh:
	ld a,'-'
	call OUTCHAR
	ld a,040h
out.ascii:
	ex af,af'
	call outquote
	ex af,af'
	push af
	res 7,a
	cp ' '
	jr nc,l0960h
	sub 0c0h
l0960h:
	call OUTCHAR
	push af
	cp ''''
	call z,OUTCHAR
	pop af
	ex af,af'
	call outquote
	pop af
	or a
	ld a,'.'
	call m,OUTCHAR
	ex af,af'
	jr c,l094bh
	ret

outquote:
	ld a,''''
OUTCHAR:
	push	hl
	push	de
	push	bc
	push	af
	and	07fh
	ld	c,a
	call	?cono
	ld	hl,CON.COL
	inc	(hl)
	pop	af
	pop	bc
	pop	de
	pop	hl
	ret

inchar:
	push	hl
	push	de
	push	bc
	call	?const
	and	a
	jr	z,inch1
	call	?conin
	scf
inch1:
	pop	bc
	pop	de
	pop	hl
	ret

PSTR:
	ld c,000h
l0995h:
	ld a,(hl)
	and a
	ret z
	call OUTCHAR
	inc c
	inc hl
	and a
	ret m
	jr l0995h

outbl6:
	call outbl2
outbl4:
	call outbl2
outbl2:
	call OUTBL
OUTBL:
	ld a,' '
	jr OUTCHAR
CRLF:
	call inchar
	ld a,CR
	call OUTCHAR
	ld a,LF
	call OUTCHAR
	ld a,000h
	ld (CON.COL),a
	jp c,DDTZML
	ret

ADD_HL_A:
	add a,l
	ld l,a
	ret nc
	inc h
	ret

SKIPBL0:
	inc de
SKIPBL:
	ld a,(de)
	cp ' '
	jr z,SKIPBL0
	cp 009h
	jr z,SKIPBL0
	or a
	ret

skip_to_nextarg:
	call SKIPBL
	cp ','
	ret nz
	inc de
	call SKIPBL
	cp a
	ret

assert_eol:
	call SKIPBL
	ret z
l09e5h:
	jp ERROR

chk.sp:
	push hl
	push de
	ld hl,0
	add hl,sp
	ld de,$stack-50
	call CP.HL.DE
	pop de
	pop hl
	jr c,l09e5h
	ret

CP.HL.DE:
	and a
	sbc hl,de
	add hl,de
	ret

lookupch:
	ld b,000h
l0a00h:
	ld a,(hl)
	and a
	ret z
	ld a,(de)
	cp (hl)
	jr z,l0a0bh
	inc hl
	inc b
	jr l0a00h
l0a0bh:
	scf
	inc de
	ret

sub_0a0eh:
	ld hl,b_0x132A_start
	ld b,07fh
	jr l0a17h

sub_0a15h:
	ld b,0ffh
l0a17h:
	inc b
	ld a,(hl)
	and a
	ret z
	call l0a27
	jr nc,l0a17h
	res 7,b
	ret

sub_0a23h:
	push bc
	res 7,b
	db	3eh		;0a26  ld a,0c5h
l0a27:
	push bc
	push de
l0a29h:
	ld a,(de)
	xor (hl)
	and 07fh
	jr nz,l0a41h
	bit 7,(hl)
	inc hl
	inc de
	jr z,l0a29h
	scf
	bit 7,b
	call z,sub_0d20h
	jr nc,l0a44h
	pop af
	scf
	pop bc
	ret

l0a41h:
	call sub_0a50h
l0a44h:
	pop de
	and a
	pop bc
	ret

sub_0a48h:
	inc b
l0a49h:
	dec b
	ret z
	call sub_0a50h
	jr l0a49h
sub_0a50h:
	ld a,(hl)
	and a
	ret z
l0a53h:
	ld a,(hl)
	inc hl
	and a
	ret m
	jr l0a53h

get_arg3:
	call get_arg_range
	push hl
	push bc
	call skip_to_nextarg
	call get_arg
	ex de,hl
	pop bc
	pop hl
	ret

sub_0a68h:
	call EXPR
	jr c,error0
	ret

get_arg:
	call sub_0a68h
l0a71h:
	jp assert_eol

get_lastarg_def:
	call get_arg_def
	jr l0a71h

get_arg_def:
	push hl
	call EXPR
	jr c,l0a80h
	ex (sp),hl
l0a80h:
	pop hl
	ret

sub_0a82h:
	call sub_0a87h
	jr l0a71h

sub_0a87h:
	db	0e6h		;0a87  and 037h (clear carry)
get_arg_range:
	scf
	ex af,af'
	push bc
	push hl
	call EXPR
	jr nc,l0a97h
	ex af,af'
	jr c,error0
	ex af,af'
	pop hl

	defb 03eh
l0a97h:
	pop af
	call sub_0aa5h
	jr nc,l0aa3h
	ex af,af'
	pop bc
	ret nc
error0:
	jp ERROR

l0aa3h:
	pop af
	ret

sub_0aa5h:
	call skip_to_nextarg
	cp 'S'
	jr nz,l0aadh
	inc de
l0aadh:
	push hl
	push af
	call EXPR
	jr c,l0ac3h
	ld b,h
	ld c,l
	pop af
	pop hl
	jr z,l0ac1h
	ld a,c
	sub l
	ld c,a
	ld a,b
	sbc a,h
	ld b,a
	inc bc
l0ac1h:
	and a
	ret

l0ac3h:
	pop af
	pop hl
	jr z,error0
	scf
	ret

EXPR:
	call SKIPBL
EXPR1:
	call do_subexpr
	ret c
	call do_rel_op
	ret nc
	push bc
	push hl
	call do_subexpr
	jr c,error0
	ex de,hl
	ex (sp),hl
	and a
	sbc hl,de
	ld hl,0ffffh
	pop de
	ret

do_op_eq:
	jr z,l0af8h
	jr l0af7h
do_op_ne:
	jr nz,l0af8h
	jr l0af7h
do_op_le:
	jr z,l0af8h
do_op_lt:
	jr c,l0af8h
	jr l0af7h
do_op_gt:
	jr z,l0af7h
do_op_ge:
	jr nc,l0af8h
l0af7h:
	inc hl
l0af8h:
	and a
	ret

do_rel_op:
	push hl
	ld hl,tab_eq_le_ge
	call lookupch
	jr nc,l0b28h
	ld a,b
	or a
	jr z,l0b1ch
	ld a,(de)
	cp '='
	jr nz,l0b11h
	inc de
	inc b
	inc b
	jr l0b1ch

l0b11h:
	bit 0,b
	jr z,l0b1ch
	cp '>'
	jr nz,l0b1ch
	inc de
	ld b,005h
l0b1ch:
	ld hl,tab_func_eqlege
	ld a,b
	add a,a
	call ADD_HL_A
	ld c,(hl)
	inc hl
	ld b,(hl)
	scf
l0b28h:
	pop hl
	ret

tab_eq_le_ge:
	db	'=<>',0

tab_func_eqlege:
	defw do_op_eq
	defw do_op_lt
	defw do_op_gt
	defw do_op_le
	defw do_op_ge
	defw do_op_ne

do_subexpr:
	call do_factor
	ret c
l0b3eh:
	call do_binary_op
	push hl
	push bc
	call do_factor
	pop bc
	ex de,hl
	ex (sp),hl
	jr nc,l0b52h
	pop de
	ld a,b
	or c
	ret z
	jp ERROR

l0b52h:
	ld a,b
	or c
	push bc
	ret nz
	pop bc
do_op_add:
	add hl,de
l0b58h:
	pop de
	jr l0b3eh

do_op_sub:
	and a
	sbc hl,de
	jr l0b58h

do_op_mlt:
	push	bc
	if CPU_Z180
	ld	b,h
	ld	c,e
	ld	h,e
	ld	e,l
	mlt	bc
	mlt	de
	mlt	hl
	ld	a,h
	add	a,c
	add	a,e
	ld	h,a
	else
	 ld	b,h
	 ld	c,l
	 ld	hl,0
	 ld	a,16
mlt_1:
	 add	hl,hl
	 ex	de,hl
	 add	hl,hl
	 ex	de,hl
	 jr	nc,mlt_2
	 add	hl,bc
mlt_2:
	 dec	a
	 jr	nz,mlt_1
	endif
	pop	bc
	jr	l0b58h

do_op_div:
	call DIV_HL_DE
	jr l0b58h

do_op_mod:
	call DIV_HL_DE
	ex de,hl
	jr l0b58h

; divide x/y
;     hl: x
;     de: y
;   return:
;     hl: q  (x/y)
;     de: r  (x%y)

DIV_HL_DE:
	push	bc
	ex	de,hl		;de = x, hl = y
	ld	b,h		;bc = y
	ld	c,l
	ld	hl,0		;r = 0
	ld	a,16		;count

;  de: x   (x shifted out, q shifted in)
;  bc: y
;  hl: r   (initially 0)

l0b89h:
	ex	de,hl		;x
	add	hl,hl		;x <<= 1
	ex	de,hl		;r
	adc	hl,hl		;r <<= 1

	or	a
	sbc	hl,bc
	inc	de
	jr	nc,div_no_restore
	add	hl,bc
	dec	de
div_no_restore:
	dec	a
	jr	nz,l0b89h
	ex	de,hl		;hl: q   de: r
	pop	bc
	ret

do_op_and:
	ld	a,h
	and	d
	ld	h,a
	ld	a,l
	and	e
	ld	l,a
	jr	l0b58h

do_op_or:
	ld	a,h
	or	d
	ld	h,a
	ld	a,l
	or	e
	ld	l,a
	jr	l0b58h

do_op_xor:
	ld	a,h
	xor	d
	ld	h,a
	ld	a,l
	xor	e
	ld	l,a
	jr	l0b58h

do_binary_op:
	push	hl
	ld	hl,tab_op_a
	call	lookupch
	ld	a,b
	ld	hl,tab_func_opa
	add	a,a
	call	ADD_HL_A
	ld	c,(hl)
	inc	hl
	ld	b,(hl)
	pop	hl
	ret

tab_op_a:
	DB	'+-*/%&!#',0
tab_func_opa:
	defw	do_op_add
	defw	do_op_sub
	defw	do_op_mlt
	defw	do_op_div
	defw	do_op_mod
	defw	do_op_and
	defw	do_op_or
	defw	do_op_xor
	defw	0

fact_factor:
	call	do_factor
	ret	nc
	jp	ERROR

do_factor:
	call	chk.sp
	call	get.number
	ret	nc
	inc	de
	ld	hl,TOPRAM
	cp	'T'
	ret	z
	ld	hl,(HILOD)
	cp	'H'
	ret	z
	ld	hl,(MAXLOD)
	cp	'M'
	ret	z
	ld	hl,TPA
	cp	'L'
	ret	z
	ld	hl,(offs.@)
	cp	'@'
	ret	z
	ld	hl,(OFFS.pc)
	cp	'$'
	ret	z
	cp	'-'
	jr	z,fact_factneg
	cp	'~'
	jr	z,fact_factinv
	cp	'+'
	jr	z,fact_factor
	cp	'^'
	jr	z,fact_reg.CPU
	cp	'Y'
	jr	z,fact_reg.Y
	cp	'('
	jr	z,fact_mem
	cp	'['
	jp	z,EXPR_BRCKT		;0c35	[ expression ]
	cp	''''
	jr	z,fact_factstring
	dec	de
	scf
	ret

fact_reg.Y:
	call	get.decdigit
	jp	c,ERROR
	inc	de
	add	a,a
	ld	hl,reg.Y
	call	ADD_HL_A
	ld	a,(hl)
	inc	hl
	ld	h,(hl)
	ld	l,a
	and	a
	ret
fact_factstring:
	ld	hl,0
l0c56h:
	ld	a,(de)
	cp	''''
	jr	z,l0c62h
	and	a
	ret	z
l0c5dh:
	ld	h,l
	ld	l,a
	inc	de
	jr	l0c56h

l0c62h:
	inc	de
	ld	a,(de)
	cp	''''
	jr	z,l0c5dh
	sub	'.'
	or	a
	ret	nz
	inc	de
	set	7,l
	ret

fact_reg.CPU:
	call	sub_1315h
	jr	nc,l0cbbh
	ld	a,(hl)
	inc	hl
	ld	h,(hl)
	ld	l,a
	and	a
	bit	0,c
	ret	nz
	ld	h,000h
	ret

fact_factneg:
	call	fact_factor
	dec	hl
cpl.hl:
	ld	a,h
	cpl
	ld	h,a
	ld	a,l
	cpl
	ld	l,a
	ret
fact_factinv:
	call	fact_factor
	jr	cpl.hl

fact_mem:
	call	EXPR1
	jr	c,l0cbbh
	ld	a,(de)
	cp	')'
	jr	nz,l0cbbh
	inc	de
	comst
	 ld	a,(hl)
	 inc	hl			;
	 ld	h,(hl)		;
	comend
	ld	l,a
	ld	a,(de)
	inc	de
	cp	'.'
	ret	z
	dec	de
	xor	a
	ld	h,a
	ret

EXPR_BRCKT:
	call	EXPR1
	jr	c,l0cbbh
	ld	a,(de)
	cp	']'
	inc	de
	ret	z
l0cbbh:
	jp	ERROR

get.number:
	call	get.hexdigit
	ret	c
	push	de
l0cc3h:
	inc	de
	call	get.hexdigit
	jr	nc,l0cc3h
	pop	de
	cp	'.'
	jr	z,l0d04h
	cp	'"'
	jr	z,l0ce9h
	ld	hl,0
l0cd5h:
	call	get.hexdigit
	jr	c,l0ce4h
	add	hl,hl
	add	hl,hl
	add	hl,hl
	add	hl,hl
	call	ADD_HL_A
	inc	de
	jr	l0cd5h
l0ce4h:
	xor	'H'
	ret	nz
	inc	de
	ret

l0ce9h:
	ld	hl,0
l0cech:
	call	get.bindigit
l0cefh:
	inc	de
	jr	c,l0cf8h
	add	hl,hl
	call	ADD_HL_A
	jr	l0cech
l0cf8h:
	cp	'"'
	jp	nz,ERROR
	call	get.bindigit
	jr	nc,l0cefh
	or	a
	ret
l0d04h:
	ld	hl,0
l0d07h:
	call	get.decdigit
	inc	de
	jr	c,l0d1ah
	push	bc
	add	hl,hl		;0d0e	hl *= 10
	ld	b,h
	ld	c,l
	add	hl,hl
	add	hl,hl
	add	hl,bc
	pop	bc
	call	ADD_HL_A
	jr	l0d07h
l0d1ah:
	cp	'.'
	ret	z
	jp	ERROR

sub_0d20h:
	ld	a,(de)
	cp	05bh
	jr	l0d28h

get.hexdigit:
	ld	a,(de)
sub_0d26h:
	cp	'F'+1
l0d28h:
	ccf
	ret	c
	cp	'A'
	jr	c,l0d32h
	sub	'A'-10
	ret

get.decdigit:
	ld	a,(de)
l0d32h:
	cp	'9'+1
	jr	l0d39h
get.bindigit:
	ld	a,(de)
	cp	'1'+1
l0d39h:
	ccf
	ret	c
	cp	'0'
	ret	c
	sub	'0'
	ret

l0d41h:
	call	assert_eol

prnt_cpustat:
	call	prnt_f
	call	outbl2
	ld	hl,b_0x0DFD_start
	ld	de,b_0x0E1D_start
	ld	b,006h
l0d52h:
	call	prnt_regs
	djnz	l0d52h
	push	hl
	push	de
	ld	iy,(REG.PC)
	call	sub_1f77h
	exx
	ex	af,af'
	call	CRLF
	call	prnt_f2
	call	outbl2
	pop	de
	pop	hl
	ld	b,007h
l0d6fh:
	call	prnt_regs
	djnz	l0d6fh
	exx
	ex	af,af'
	and	a
	jr	z,l0d7fh
	call	outbl6
	call	sub_1f5bh
l0d7fh:
	jp	crlf

prnt_f:
	ld	a,(reg.f)
	call	prnt_flags
	ld	a,(reg.iff)
	cp	0f3h
	jp	z,outbl
	ld	a,'E'
	jp	outchar

prnt_f2:
	ld	a,(reg.f2)
	call	prnt_flags
	jp	outbl

prnt_flags:
	ld	b,a
	ld	a,'S'
	call	sub_0dbeh
	ld	a,'Z'
	call	sub_0dbeh
	rl	b
	ld	a,'H'
	call	sub_0dbeh
	rl	b
	ld	a,'V'
	call	sub_0dbeh
	ld	a,'N'
	call	sub_0dbeh
	ld	a,'C'
sub_0dbeh:
	rl	b
	jp	c,OUTCHAR
	jp	OUTBL

prnt_regs:
	push	bc
	push	de
	call	PSTR
	ld	a,'='
	call	OUTCHAR
	ex	(sp),hl
	ld	e,(hl)
	inc	hl
	ld	d,(hl)
	inc	hl
	ld	a,(hl)
	inc	hl
	push	hl
	and	a
	jr	z,l0df2h
	push	af
	ld	a,(de)
	ld	l,a
	inc	de
	ld	a,(de)
	ld	h,a
	pop	af
	dec	a
	jr	z,l0dedh
	call	out.hl.@
	call	z,outbl6
	jr	l0df6h
l0dedh:
	call	out.hl
	jr	l0df6h
l0df2h:
	ld	a,(de)
	call	out.hex
l0df6h:
	call	OUTBL
	pop	de
	pop	hl
	pop	bc
	ret

b_0x0DFD_start:
	DC	'A '
	DC	'BC '
	DC	'DE '
	DC	'HL '
	DC	'SP'
	DC	'PC'
	DC	'A'''
	DC	'BC'''
	DC	'DE'''
	DC	'HL'''
	DC	'IX'
	DC	'IY'
	DC	'I'
	DB	0

b_0x0E1D_start:
	defw	reg.a
	defb	000h
	defw	reg.c
	defb	001h
	defw	reg.e
	defb	001h
	defw	reg.l
	defb	001h
	defw	reg.sp
	defb	001h
	defw	reg.pc
	defb	002h
	defw	reg.a2
	defb	000h
	defw	reg.c2
	defb	001h
	defw	reg.e2
	defb	001h
	defw	reg.l2
	defb	001h
	defw	reg.ix
	defb	001h
	defw	reg.iy
	defb	001h
	defw	reg.i
	dw	0

CMD.G:
	sub	a
	ld	(TCFLG),a
	ld	(XA747),a
	call	EXPR
	jr	c,l0e54h
	ld	(REG.PC),hl
l0e54h:
	call	SKIPBL
	jp	z,l1183h
	cp	';'
	jp	nz,ERROR
	inc	de
	ld	a,002h
	call	sub_0f24h
	jp	l1183h

sub_0e68h:
	ld	b,BP_CNT
	ld	ix,bp_tab
l0e6eh:
	ld	a,(ix+000h)
	and	0f1h
	ld	(ix+000h),a
	call	sub_11c5h
	ld	de,BP_SIZE
	add	ix,de
	djnz	l0e6eh
	ret

CMD.B:
	call	SKIPBL
	jr	z,l0ecbh
	inc	de
	cp	'X'
	jr	z,l0e91h
	dec	de
	ld	a,001h
	jp	sub_0f24h
l0e91h:
	call	SKIPBL
	jr	z,l0ea6h
l0e96h:
	call	EXPR
	jp	c,assert_eol
	push	de
	call	sub_0ea7h
	pop	de
	call	skip_to_nextarg
	jr	l0e96h
l0ea6h:
	scf
sub_0ea7h:
	ld	b,BP_CNT
	ld	ix,bp_tab
l0eadh:
	push	af
	jr	c,l0ebbh
	ld	e,(ix+002h)
	ld	d,(ix+003h)
	call	CP.HL.DE
	jr	nz,l0ec2h
l0ebbh:
	ld	(ix+000h),000h
	call	sub_11c5h
l0ec2h:
	ld	de,BP_SIZE
	add	ix,de
	pop	af
	djnz	l0eadh
	ret
l0ecbh:
	ld	b,BP_CNT
	ld	ix,bp_tab
l0ed1h:
	bit	0,(ix+000h)
	jr	z,l0f1ch
	ld	a,'R'
	bit	4,(ix+000h)
	jr	nz,l0ee1h
	ld	a,' '
l0ee1h:
	call	OUTCHAR
	call	OUTBL
	ld	l,(ix+002h)
	ld	h,(ix+003h)
	call	out.hl.@
	call	outbl2
	ld	a,':'
	call	OUTCHAR
	ld	l,(ix+004h)
	ld	h,(ix+005h)
	call	out.hl
	ld	l,(ix+006h)
	ld	h,(ix+007h)
	ld	a,h
	or	l
	jr	z,l0f19h
	call	outbl4
	ld	a,'I'
	call	OUTCHAR
	call	outbl2
	call	PSTR
l0f19h:
	call	CRLF
l0f1ch:
	ld	de,BP_SIZE
	add	ix,de
	djnz	l0ed1h
	ret

sub_0f24h:
	ld	b,a
	call	SKIPBL
	ret	z
	cp	'R'
	jr	nz,l0f30h
	inc	de
	set	4,b
l0f30h:
	push	bc
	call	EXPR
	jp	c,ERROR
	pop	bc
	bit	0,b
	push	bc
	push	de
	push	hl
	call	nz,sub_0ea7h
	pop	hl
	call	sub_0f68h
	pop	de
	ld	(ix+002h),l
	ld	(ix+003h),h
	call	sub_0f80h
	ld	(ix+004h),l
	ld	(ix+005h),h
	call	sub_0f91h
	ld	(ix+006h),l
	ld	(ix+007h),h
	call	skip_to_nextarg
	pop	af
	ld	(ix+000h),a
	and	00fh
	jr	sub_0f24h
sub_0f68h:
	ld	b,BP_CNT
	ld	ix,bp_tab
l0f6eh:
	ld	a,(ix+000h)
	and	00fh
	ret	z
	push	bc
	ld	bc,BP_SIZE
	add	ix,bc
	pop	bc
	djnz	l0f6eh
	jp	ERROR

sub_0f80h:
	call	SKIPBL
	ld	hl,1
	cp	03ah
	ret	nz
	inc	de
	call	EXPR
	jp	c,ERROR
	ret
sub_0f91h:
	call	SKIPBL
	cp	049h
	ld	hl,0
	ret	nz
	inc	de
	call	SKIPBL
	push	de
	call	EXPR
	jp	c,ERROR
	ex	de,hl
	pop	de
	push	de
	sbc	hl,de
	ld	b,h
	ld	c,l
	ld	hl,(sexp1)
	push	hl
	add	hl,bc
	ld	de,sexpbufe
	call	CP.HL.DE
	jp	nc,ERROR
	pop	hl
	ld	(sexp2),hl
	pop	de
	ex	de,hl
	ldir
	xor	a
	ld	(de),a
	inc	de
	ex	de,hl
	ld	(sexp1),hl
	ld	hl,(sexp2)
	ret

bpddtz:
	if ROMSYS
	 ld	h,ROMEN
	 jr	z,l0fd2h
	 inc	h
l0fd2h:
	 push	hl		;save rom enable stat
	endif
	push	bc
	push	de
	push	ix
	push	iy
	ld	a,i
	ld	h,a
	ld	l,000h
	push	hl		;save I register

	if CPU_Z180
	 ld	a,0f3h		;DI
	 jp	po,l0fe6h
	 ld	a,0fbh		;EI
	else			;NMOS Z80 design flaw
	 call	getiff		;return Carry set, if INTs are disabled.
	 ld	a,0f3h		;DI
	 jr	c,l0fe6h
	 ld	a,0fbh		;EI
	endif
l0fe6h:
	ld	(reg.iff),a
	ld	hl,ivtab
	ld	a,h
	ld	i,a
	call	ddtei
	ex	af,af'
	push	af
	exx
	push	bc
	push	de
	push	hl
	call	bp.unset
	if CPU_Z180
	 in0	a,(itc)
	 jp	p,l1017h
	 res	TRAP,a
	 out0	(itc),a
	 bit	UFO,a
	 jr	z,l1011h
	 ld	hl,(REG.PC)
	 dec	hl
	 ld	(REG.PC),hl
l1011h:
	 ld	hl,MSG_trap
	 call	PSTR
l1017h:
	endif

	ld	a,(XBFE8)
	dec	a
	jr	z,l1051h
	call	inchar
	jr	c,l102eh
	call	sub_1059h
	and	a
	jp	z,l1183h
	and	083h
	jp	z,l284ah
l102eh:
	call	sub_0e68h
	call prnt_cpustat
	jp	DDTZML

	if CPU_Z180
MSG_trap:
	DB	CR,LF,'Undefined opcode trap'
	DB	CR,LF,0
	endif

l1051h:
	ld (XBFE8),a
	ld c,007h
	jp l119fh
sub_1059h:
	ld a,080h
	ex af,af'
	sub a
	ld (XA747),a
	ld b,BP_CNT
	ld ix,bp_tab
l1066h:
	ld a,(ix+000h)
	and 007h
	jr z,l107eh
	ld e,(ix+002h)
	ld d,(ix+003h)
	ld hl,(REG.PC)
	call CP.HL.DE
	push bc
	call z,sub_1087h
	pop bc
l107eh:
	ld de,BP_SIZE
	add ix,de
	djnz l1066h
	ex af,af'
	ret
sub_1087h:
	ex af,af'
	res 7,a
	ex af,af'
	ld e,(ix+006h)
	ld d,(ix+007h)
	ld a,d
	or e
	ld hl,0ffffh
	call nz,EXPR
	ld a,h
	or l
	jr z,l10aeh
	ld e,(ix+004h)
	ld d,(ix+005h)
	dec de
	ld a,d
	or e
	jr z,l10b9h
	ld (ix+004h),e
	ld (ix+005h),d
l10aeh:
	bit 4,(ix+000h)
	ret z
	ld a,001h
	ld (XA747),a
	ret
l10b9h:
	ex af,af'
	or (ix+000h)
	ex af,af'
	ret

bp.unset:
	ld b,BP_CNT
	ld ix,bp_tab
l10c5h:
	bit 5,(ix+000h)
	res 5,(ix+000h)
	jr z,l10e7h
	ld l,(ix+002h)
	ld h,(ix+003h)
	ld a,(ddtzrst)
	comst
	cp (hl)
	comend
	jr nz,l10e7h
	ld a,(ix+001h)
	comst
	 ld (hl),a
	comend
l10e7h:
	res 3,(ix+000h)
	ld de,BP_SIZE
	add ix,de
	djnz l10c5h
	ret
sub_10f3h:
	ld b,BP_CNT
	ld ix,bp_tab
l10f9h:
	ld a,(ix+000h)
	and 003h
	jr z,l110dh
	ld e,(ix+002h)
	ld d,(ix+003h)
	ld hl,(REG.PC)
	call CP.HL.DE
	ret z
l110dh:
	ld de,BP_SIZE
	add ix,de
	djnz l10f9h
	sub a
	inc a
	ret
sub_1117h:
	call sub_0f68h
	ld (ix+004h),001h
	ld (ix+005h),000h
	ld (ix+002h),l
	ld (ix+003h),h
	ld (ix+006h),000h
	ld (ix+007h),000h
	ld a,(XBFE8)
	and a
	ld a,008h
	jr nz,l113ah
	ld a,004h
l113ah:
	ld (ix+000h),a
	ret

bp.set:
	ld b,BP_CNT
	ld ix,bp_tab
l1144h:
	ld a,(ix+000h)
	and c
	jr z,l117bh
	set 5,(ix+000h)
	ld l,(ix+002h)
	ld h,(ix+003h)


	ld a,(ddtzrst)
	comst
	ld e,(hl)
	ld (hl),a
	comend
	ld (ix+001h),e
	and 038h
	ld h,0
	ld l,a
	ld de,bpent
	comst			;
	ld (hl),0c3h
	inc hl
	ld (hl),e
	inc hl
	ld (hl),d
	comend


l117bh:
	ld de,BP_SIZE
	add ix,de
	djnz l1144h
	ret

l1183h:
	sub a
	ld (XBFE8),a
	ld a,(XA747)
	and a
	call nz,prnt_cpustat
	call sub_10f3h
	ld c,007h
	jr nz,l119fh
	ld a,001h
	ld (XBFE8),a
	call sub_26e7h
	ld c,008h
l119fh:
	call bp.set
	ld sp,$stack		;11a2	set/restore user cpu state
	pop hl
	pop de
	pop bc
	pop af
	exx
	ex af,af'
	pop af
	ld i,a
	pop iy
	pop ix
	pop de
	pop bc
	if ROMSYS
	 pop hl
	 ld a,l
	 and M_MWI
	 ld l,a
	 di
	 in0 a,(dcntl)
	 and ~M_MWI
	 or l
	 ld l,a
	 ld a,h
	else
	 pop hl
	 di
	endif
	jp $go			;11c2	common ram, switch banks and go to user prog

sub_11c5h:
	ld a,(ix+000h)
	and 003h
	ret nz
	ld e,(ix+006h)
	ld d,(ix+007h)
	ld a,d
	or e
	ret z
	push bc
	ld h,d
	ld l,e
	sub a
	ld (ix+006h),a
	ld (ix+007h),a
	ld bc,0ffffh
	cpir
l11e3h:
	push de
	ld de,(sexp1)
	call CP.HL.DE
	pop de
	jr nc,l11f9h
	call sub_11ffh
l11f1h:
	ld a,(hl)
	ldi
	and a
	jr nz,l11f1h
	jr l11e3h
l11f9h:
	ld (sexp1),de
	pop bc
	ret
sub_11ffh:
	ld iy,bp_tab
	push de
l1204h:
	ld e,(iy+006h)
	ld d,(iy+007h)
	call CP.HL.DE
	jr z,l1216h
	ld de,BP_SIZE
	add iy,de
	jr l1204h
l1216h:
	pop de
	ld (iy+006h),e
	ld (iy+007h),d
	ret

CMD.Y:
	call get.decdigit
	jr c,l122fh
	inc de
	push af
	call assert_eol
	pop af
	call sub_1248h
	jp l127ch
l122fh:
	call assert_eol
	xor a
l1233h:
	push af
	call sub_1248h
	call outbl4
	pop af
	inc a
	bit 0,a
	push af
	call z,CRLF
	pop af
	cp LF
	jr c,l1233h
	ret

sub_1248h:
	ld c,a
	ld b,0
	add a,'0'+080h
	ld de,msg.Y+1
	ld (de),a
	dec de
	ld hl,reg.Y
	add hl,bc
	add hl,bc
	ex de,hl
	ld c,003h
	jp l129ah

CMD.X:
	call SKIPBL
	call sub_1315h
	jp nc,l0d41h
	call assert_eol
	ld a,b
	cp 01fh
	jr z,l12c6h
	cp 020h
	jr z,l12b6h
	ex de,hl
	ld hl,b_0x132A_start
	call sub_0a48h
l1279h:
	call l129ah
l127ch:
	call OUTBL
	push de
	push bc
	call INLINE
	call SKIPBL
	jr z,l1297h
	call get_arg
	ld b,h
	ld c,l
	pop af
	pop hl
	ld (hl),c
	bit 0,a
	ret z
	inc hl
	ld (hl),b
	ret
l1297h:
	pop af
	pop hl
	ret
l129ah:
	ld b,c
	call PSTR
	ld a,'='
	call OUTCHAR
	ld a,(de)
	bit 0,b
	jp z,out.hex
	ld l,a
	inc de
	ld a,(de)
	dec de
	ld h,a
	bit 1,b
	jp z,out.hl
	jp out.hl.@

l12b6h:
	call prnt_f
	ld a,0f3h
	ld (reg.iff),a
	scf
	call sub_12d1h
	ld (reg.f),a
	ret

l12c6h:
	call prnt_f2
	and a
	call sub_12d1h
	ld (reg.f2),a
	ret

sub_12d1h:
	ex af,af'
	ld b,000h
	call outbl
	call assert_eol
	call inline
l12ddh:
	call skipbl
	ld a,b
	ret z
	push bc
	ld hl,tab_pr_flags
	call lookupch
	jp nc,error
	ld a,b
	cp 008h
	jr z,l12feh
	inc b
	ld a,001h
	jr l12f7h
l12f6h:
	rlca
l12f7h:
	djnz l12f6h
	pop bc
	or b
	ld b,a
	jr l12ddh
l12feh:
	ex af,af'
	jp nc,ERROR
	ex af,af'
	ld a,0FBh
	ld (reg.iff),a
	pop bc
	jr l12ddh

tab_pr_flags:
	db	'CNV H ZSE'
	db	0

sub_1315h:
	call sub_0a0eh
	ret nc
	ld a,b
	add a,b
	add a,b
	ld hl,b_0x136C_start
	call ADD_HL_A
	ld c,(hl)
	inc hl
	ld a,(hl)
	inc hl
	ld h,(hl)
	ld l,a
	scf
	ret

b_0x132A_start:
	if ROMSYS
	 DC	'ROMSEL'
	endif
	if CPU_Z180
	DC	'CBAR'
	DC	'BBR'
	else
	 DC	'BNK'
	endif
	DC	'BC'''
	DC	'DE'''
	DC	'HL'''
	DC	'BC'
	DC	'DE'
	DC	'HL'
	DC	'A'''
	DC	'B'''
	DC	'C'''
	DC	'D'''
	DC	'E'''
	DC	'H'''
	DC	'L'''
	DC	'A'
	DC	'B'
	DC	'C'
	DC	'D'
	DC	'E'
	DC	'H'
	DC	'L'
	DC	'IX'
	DC	'IY'
	DC	'SP'
	DC	'PC'
	DC	'X'
	DC	'Y'
	DC	'S'
	DC	'P'
	DC	'I'
	DC	'F'''
	DC	'F'
	DB	0
b_0x136C_start:
	if	ROMSYS
	 defb	000h
	 defw	uromen
	endif
	if CPU_Z180
	defb	000h
	defw	ucbar
	defb	000h
	defw	ubbr
	else
	 defb	000h
	 defw	ubnk
	endif
	defb	003h
	defw	reg.c2
	defb	003h
	defw	reg.e2
	defb	003h
	defw	reg.l2
	defb	003h
	defw	reg.c
	defb	003h
	defw	reg.e
	defb	003h
	defw	reg.l
	defb	000h
	defw	reg.a2
	defb	000h
	defw	reg.b2
	defb	000h
	defw	reg.c2
	defb	000h
	defw	reg.d2
	defb	000h
	defw	reg.e2
	defb	000h
	defw	reg.h2
	defb	000h
	defw	reg.l2
	defb	000h
	defw	reg.a
	defb	000h
	defw	reg.b
	defb	000h
	defw	reg.c
	defb	000h
	defw	reg.d
	defb	000h
	defw	reg.e
	defb	000h
	defw	reg.h
	defb	000h
	defw	reg.l
	defb	003h
	defw	reg.ix
	defb	003h
	defw	reg.iy
	defb	003h
	defw	reg.sp
	defb	003h
	defw	reg.pc
	defb	003h
	defw	reg.ix
	defb	003h
	defw	reg.iy
	defb	003h
	defw	reg.sp
	defb	003h
	defw	reg.pc
	defb	000h
	defw	reg.i
	defb	000h
	defw	reg.f2
	defb	000h
	defw	reg.f
CMD.S:
	ld	hl,(lst.S)
	call	get_lastarg_def
l13d8h:
	ld	(lst.S),hl
	call	out.hl.@
	call	OUTBL
	comst
	ld	a,(hl)
	comend
	call	out.hex
	call	outbl2
	call	INLINE
	call	SKIPBL
	inc	hl
	jr	z,l13d8h
	dec	hl
	inc	de
	cp	'.'
	jp	z,assert_eol
	cp	'-'
	jr	nz,l1406h
	ld	a,(de)
	or	a
	dec	hl
	jr	z,l13d8h
	inc	hl
l1406h:
	dec	de
	call	get_bytes_m
	jr	l13d8h

CMD.@:
	call	assert_eol
	ld	hl,MSG_at
	ld	de,offs.@
	ld	c,001h
	jp	l1279h
MSG_at:
	dc	'@'

CMD.I:
	ld	hl,CMD.I
	ld	(CMD_RPT),hl
	ld	hl,(lst.IP)
	call	get_lastarg_def
	ld	(lst.IP),hl
	ld	b,h
	ld	c,l
	if CPU_Z180
	 ld	a,b
	 or	a
	 jr	nz,l1442h
	 ld	a,c
	 ld	hl,ucbar
	 cp	cbar
	 jr	z,l143fh
	 ld	hl,ubbr
	 cp	bbr
	 jr	nz,l1442h
l143fh:
	 ld	a,(hl)
	 jr	l1444h
l1442h:
	endif
	in	a,(c)
l1444h:
	push	af
	call	out.hex
	call	outbl4
	pop	af
	call	out.bin.b
	jp	CRLF
CMD.O:
	ld	hl,CMD.O
	ld	(CMD_RPT),hl
	ld	hl,(lst.OD)
	call	get_arg_def
	ld	a,l
	ld	(lst.OD),a
	push	af
	call	skip_to_nextarg
	ld	hl,(lst.OP)
	call	get_lastarg_def
	ld	(lst.OP),hl
	ld	b,h
	ld	c,l
	if CPU_Z180
	 ld	a,b
	 or	a
	 jr	nz,l1489h
	 ld	a,c
	 ld	hl,ucbar
	 cp	cbar
	 jr	z,l148dh
	 ld	hl,ubbr
	 cp	bbr
	 jr	z,l148dh
	 cp	cbr
	 jp	z,ERROR
l1489h:
	endif
	pop	af
	out	(c),a
	ret
	if CPU_Z180
l148dh:
	 pop	af
	 ld	(hl),a
	 ret
	endif

CMD.V:
	call	get_arg3		;1490	get from, size, to
cmp_mem:
	push	bc
	comst
	 ld	a,(de)
	 ld	b,(hl)
	comend
	cp	b
	jr	z,l14bah
	ld	c,a
	call	out.hl.@
	call	OUTBL
	ld	a,b
	call	out.hex
	call	outbl2
	ld	a,c
	call	out.hex
	call	OUTBL
	ex	de,hl
	call	out.hl.@
	ex	de,hl
	call	CRLF
l14bah:
	pop	bc
	inc	hl
	inc	de
	dec	bc
	ld	a,b
	or	c
	jr	nz,cmp_mem
	ret

CMD.M:
	ld	a,(de)
	cp	'V'
	jr	nz,bm_nv
	inc	de
bm_nv:
	push	af			;14c9	save 'V' flag
	call	get_arg3
	push	hl
	push	de
	push	bc
	call	CP.HL.DE
	jr	nc,bm_mvdown
	add	hl,bc
	ex	de,hl
	add	hl,bc
	ex	de,hl
	dec	hl
	dec	de
	comst
	 lddr
	comend
	jr	bm_done
bm_mvdown:
	comst
	ldir
	comend
bm_done:
	pop	bc
	pop	de
	pop	hl
	pop	af
	jr	z,cmp_mem		;14ed	validate?
	ret
CMD.H:
	call	EXPR
	jp	c,l173ch		;no parameters, print High and Max
	call	skip_to_nextarg
	push	hl
	call	EXPR
	push	af
	call	assert_eol
	pop	af
	ex	de,hl
	pop	hl
	jr	c,l1511h
	push	hl
	push	de
	add	hl,de
	call	l1511h
	pop	de
	pop	hl
	and	a
	sbc	hl,de
l1511h:
	call	out.hl			;1511	val
	call	outbl2
	call	sub_0928h		;1517	-val
	call	outbl4
	call	out.hl.dec		;151d	dec
	call	outbl2
	call	out.hl.decm		;1523	-dec
	call	outbl4
	call	out.bin.w		;1529	bin
	call	outbl2
	ld	a,l
	call	out.ascii
	jp	CRLF

CMD.Q:
	ld a,(de)
	sub 'J'
	ld (lst.Qj),a
	jr nz,l153fh
	inc de
l153fh:
	call get_arg_range
	push bc
	push hl
	call sub_15a7h
	pop hl
l1548h:
	call sub_1594h
	jr nz,l1562h
	push bc
	push hl
	ld a,(lst.Qj)
	or a
	jr nz,l1559h
	ld bc,-8
	add hl,bc
l1559h:
	ld bc,MEMDUMP_CNT
	and a
	call memdump
	pop hl
	pop bc
l1562h:
	inc hl
	ex (sp),hl
	dec hl
	ld a,h
	or l
	ex (sp),hl
	jr nz,l1548h
	pop bc
	ret

CMD.Z:
	call get_arg_range
	push bc
	push hl
	call sub_15a7h
	ld a,b
	pop hl
	pop bc
	push hl
	ex de,hl
l1579h:
	push af
	ld a,(hl)
	comst
	ld (de),a
	comend
	pop af
	inc de
	cpi
	jp po,l1592h
	dec a
	jr nz,l1579h
	pop hl
	comst
	ldir
	comend
	ret
l1592h:
	pop hl
	ret

sub_1594h:
	push hl
	push de
	push bc
l1597h:
	ld a,(de)
	comst
	cp (hl)
	comend
	jr nz,l15a3h
	inc de
	inc hl
	djnz l1597h
l15a3h:
	pop bc
	pop de
	pop hl
	ret

sub_15a7h:
	ld hl,ci.buf+1
	call get_bytes
	ld de,ci.buf+1
	and a
	sbc hl,de
	ld b,l
	ret nz
	jp ERROR

get_bytes:
	db	0e6h		;15b8  and 037h (clear carry, skip next opc)
get_bytes_m:
	scf
l15bah:
	push af
	call skip_to_nextarg
	cp 'W'
	jr nz,l15d9h
	inc de
	push hl
	call sub_0a68h
	ex de,hl
	pop bc
	pop af
	push af
	push bc
	ex (sp),hl
	jr nc,l15d3h
	comst
l15d3h:
	ld (hl),e
	comend
	inc hl
	ld c,d
	pop de
	jr l15e5h
l15d9h:
	cp ''''
	jr z,l15f1h
	push hl
	call EXPR
	ld c,l
	pop hl
	jr c,l1626h
l15e5h:
	pop af
	push af
	jr nc,l15edh
	comst
l15edh:
	ld (hl),c
	comend
	inc hl
	jr l161eh
l15f1h:
	inc de
	ld a,(de)
	cp ''''
	jr z,l1607h
	or a
	jr z,l1626h
l15fah:
	ld c,a
	pop af
	push af
	jr nc,l1603h
	comst
l1603h:
	ld (hl),c
	comend
	inc hl
	jr l15f1h
l1607h:
	inc de
	ld a,(de)
	cp ''''
	jr z,l15fah
	cp '.'
	jr nz,l161eh
	inc de
	dec hl
	pop af
	push af
	jr nc,l161bh
	comst
l161bh:
	set 7,(hl)
	comend
	inc hl
l161eh:
	pop af
	jr nc,l15bah
	ld (lst.S),hl
	jr l15bah

l1626h:
	pop af
	ret nc
	ld (lst.S),hl
	ret

CMD.D:
	ld hl,CMD.D
	ld (CMD_RPT),hl
	ld hl,(lst.D)
	ld bc,00080h
	call sub_0a82h
	scf
memdump:
	push bc
	push de
	push hl
	ex af,af'
l1640h:
	call out.hl.@
	call z,outbl2
	call OUTBL
	ld de,0
l164ch:
	comst
	ld a,(hl)
	comend
	inc hl
	call out.hex
	call OUTBL
	dec bc
	inc e
	ld a,e
	cp 010h
	jr z,l1668h
	and 003h
	call z,OUTBL
	ld a,b
	or c
	jr nz,l164ch
l1668h:
	call OUTBL
	and a
	sbc hl,de
l166eh:
	comst
	ld a,(hl)
	comend
	call sub_168fh
	call OUTCHAR
	inc hl
	dec e
	jr nz,l166eh
	ex af,af'
	jr nc,l1683h
	ld (lst.D),hl
l1683h:
	ex af,af'
	call CRLF
	ld a,b
	or c
	jr nz,l1640h
	pop hl
	pop de
	pop bc
	ret
sub_168fh:
	and 07fh
	cp 07fh
	jr z,l1698h
	cp 020h
	ret nc
l1698h:
	ld a,02eh
	ret

;	Read Intel Hex File from console.
CMD.R:
	ld hl,0
	call get_lastarg_def	;169e	get offset from command line
	push hl
	ld hl,0
	ld (HILOD),hl
w_recstart:
	call i.getchar
	jr z,l16deh
	cp ':'
	jr nz,w_recstart
	ld c,0			;16b1	init checksum
	call i.gethexbyte	;16b3	record len
	ld b,a
	call i.gethexbyte	;16b7	address high
	ld h,a
	call i.gethexbyte	;16bb	address low
	ld l,a
	call i.gethexbyte	;16bf	record type (ignored)
	ld a,b
	and a			;16c3	record len == 0?
	jr z,l16deh
l16c6h:
	call i.gethexbyte
	pop de			;16c9	offset
	push de
	push hl
	add hl,de
	call i.storebyte
	pop hl
	inc hl
	djnz l16c6h		;16d2	repeat for record len
	call i.gethexbyte	;16d4	checksum
	ld a,c
	and a
	jp nz,ERROR		;16d9	exit if checksum error
	jr w_recstart		;16dc	next record
l16deh:
	pop hl
	call i.gethexbyte
	jp l173fh

i.gethexbyte:
	call sub_16f6h
	rlca
	rlca
	rlca
	rlca
	ld d,a
	call sub_16f6h
	add a,d
	ld d,a
	add a,c
	ld c,a
	ld a,d
	ret

sub_16f6h:
	call i.getchar
	jr z,l16ffh
	call sub_0d26h
	ret nc
l16ffh:
	jp ERROR

i.getchar:
	call $ci
	cp 01ah
	ret

i.storebyte:
	push af
	push de
	ld de,TPA		;170a	lowest allowed load address
	call CP.HL.DE
	jp c,ERROR
	ld de,$stcka		;1713	highest allowed load address
	call CP.HL.DE
	jp nc,ERROR
	ld de,(HILOD)
	call CP.HL.DE
	jr c,l1728h
	ld (HILOD),hl
l1728h:
	ld de,(MAXLOD)
	call CP.HL.DE
	jr c,l1734h
	ld (MAXLOD),hl
l1734h:
	pop de
	pop af
	comst
	ld (hl),a		;173a	store byte
	comend
	ret

l173ch:
	call assert_eol
l173fh:
	ld hl,MSG_high
	call PSTR
	ld hl,(HILOD)
	call out.hl
	ld hl,MSG_max
	call PSTR
	ld hl,(MAXLOD)
	call out.hl
	jp CRLF

MSG_high:
	DC	'High = '
MSG_max:
	DC	'  Max = '

CMD.A:
	ld hl,(lst.A)
	call get_lastarg_def
	push hl
	pop iy
	ld hl,l17c4h
	ld (CMD_ERR),hl
	ld (XB068),sp
l177ch:
	push iy
	pop hl
	ld (lst.A),hl
	ld (OFFS.pc),hl
	push hl
	call sub_1f3fh
	pop iy
	ld c,b
	ld de,(offs.@)
	ld a,d
	or e
	ld b,011h
	jr z,l1798h
	ld b,019h
l1798h:
	call OUTBL
	ld a,(CON.COL)
	cp b
	jr c,l1798h
	push bc
	call INLINE
	pop bc
	call SKIPBL
	cp '.'
	ret z
	cp '-'
	jr nz,l17b6h
	ld iy,(XB06C)
	jr l177ch
l17b6h:
	and a
	call nz,sub_17cdh
	ld (XB06C),iy
	ld b,0
	add iy,bc
	jr l177ch
l17c4h:
	call l07eah
	ld sp,(XB068)
	jr l177ch

sub_17cdh:
	call SKIPBL
	ld hl,t_MNEMONICS
	call sub_0a15h
	jp nc,ERROR
	call SKIPBL
	push de
	ld a,b
	add a,b
	add a,b
	ld hl,b_0x17EE_start
	call ADD_HL_A
	ld e,(hl)
	inc hl
	ld d,(hl)
	inc hl
	ld b,(hl)
	ex de,hl
	pop de
	jp (hl)

b_0x17EE_start:
	defw l1b54h
	defb 088h
	defw l1b74h
	defb 080h
	defw l1babh
	defb 0a0h
	defw l1c14h
	defb 040h
	defw l1c38h
	defb 0c4h
	defw l1b36h
	defb 03fh
	defw l1babh
	defb 0b8h
	defw gen.opc.ED2
	defb 0a9h
	defw gen.opc.ED2
	defb 0b9h
	defw gen.opc.ED2
	defb 0a1h
	defw gen.opc.ED2
	defb 0b1h
	defw l1b36h
	defb 02fh
	defw l1b36h
	defb 027h
	defw l1dabh
	defb 005h
	defw l1b36h
	defb 0f3h
	defw l1ca4h
	defb 010h
	defw l1b36h
	defb 0fbh
	defw l1d54h
	defb 0e3h
	defw l1b36h
	defb 0d9h
	defw l1b36h
	defb 076h
	defw l1cbfh
	defb 046h
	defw l1cf8h
	defb 040h
	defw l1dabh
	defb 004h
	defw gen.opc.ED2
	defb 0aah
	defw gen.opc.ED2
	defb 0bah
	defw gen.opc.ED2
	defb 0a2h
	defw gen.opc.ED2
	defb 0b2h
	defw l1c5eh
	defb 0c2h
	defw l1cabh
	defb 020h
	defw l1934h
	defb 040h
	defw gen.opc.ED2
	defb 0a8h
	defw gen.opc.ED2
	defb 0b8h
	defw gen.opc.ED2
	defb 0a0h
	defw gen.opc.ED2
	defb 0b0h
	defw gen.opc.ED2
	defb 044h
	defw l1b36h
	defb 000h
	defw l1babh
	defb 0b0h
	defw gen.opc.ED2
	defb 0bbh
	defw gen.opc.ED2
	defb 0b3h
	defw l1d2ch
	defb 041h
	defw gen.opc.ED2
	defb 0abh
	defw gen.opc.ED2
	defb 0a3h
	defw l1ce4h
	defb 0c1h
	defw l1ce4h
	defb 0c5h
	defw l1c14h
	defb 080h
	defw l1c50h
	defb 0c0h
	defw gen.opc.ED2
	defb 04dh
	defw gen.opc.ED2
	defb 045h
	defw l1bd8h
	defb 010h
	defw l1b36h
	defb 017h
	defw l1bd8h
	defb 000h
	defw l1b36h
	defb 007h
	defw gen.opc.ED2
	defb 06fh
	defw l1bd8h
	defb 018h
	defw l1b36h
	defb 01fh
	defw l1bd8h
	defb 008h
	defw l1b36h
	defb 00fh
	defw gen.opc.ED2
	defb 067h
	defw l1cd5h
	defb 0c7h
	defw l1b54h
	defb 098h
	defw l1b36h
	defb 037h
	defw l1c14h
	defb 0c0h
	defw l1bd8h
	defb 020h
	defw l1bd8h
	defb 028h
	defw l1bd8h
	defb 038h
	defw l1babh
	defb 090h
	defw l1babh
	defb 0a8h
	defw A.IN0
	defb 000h
	defw A.MLT
b_0x18BC_start:
	defb 04ch
	ld b,e
	dec de

b_0x18BF_start:
	defb 08bh
	defw gen.opc.ED2
	defb 09bh
	defw gen.opc.ED2
	defb 083h
	defw gen.opc.ED2
	defb 093h
	defw l18fdh
	defb 001h
	defw gen.opc.ED2
	defb 076h
	defw l191dh
	defb 004h
	defw l192ch
	defb 074h
A.IN0:
	call sub_1e41h
	jr nc,l1931h
	cp 006h
	jr z,l1931h
	rlca
	rlca
	rlca
	add a,b
	ld b,a
	call sub_1ed1h
	call sub_1e06h
l18e9h:
	call assert_eol
	comst
	ld (iy+000h),0edh
	ld (iy+001h),b
	ld (iy+002h),l
	comend
	ld c,003h
	ret
l18fdh:
	call sub_1e06h
	call sub_1ed1h
	call sub_1e41h
	jr nc,l1931h
	cp 006h
	jr z,l1931h
	rlca
	rlca
	rlca
	add a,b
	ld b,a
	jr l18e9h
A.MLT:
	call sub_1e2eh
	jr nc,l1931h
	add a,b
	ld b,a
	jp gen.opc.ED2
l191dh:
	call sub_1e41h
	jr nc,l192ah
	rlca
	rlca
	rlca
	add a,b
	ld b,a
	jp gen.opc.ED2
l192ah:
	ld b,064h
l192ch:
	call sub_1e12h
	jr l18e9h
l1931h:
	jp ERROR
l1934h:
	call sub_1e41h
	jp c,l19bfh
	call sub_1e68h
	jp c,l1a64h
	call sub_1e2eh
	jp c,l1a93h
	call sub_1e50h
	jp c,l1af0h
	ld a,(de)
	cp 049h
	jp z,l1b0ch
	cp 052h
	jp z,l1b14h
	cp 028h
	jp nz,ERROR
	inc de
	call sub_1e2eh
	jp c,l1b23h
	call tst_EXPR
	call sub_1ed8h
	call sub_1ed1h
	call sub_1e2eh
	jr c,l19adh
	call sub_1e50h
	jr nc,l1991h
	ld b,022h
l1978h:
	call assert_eol
	ld a,(pfx.IXY)
l197eh:
	comst
	ld (iy+000h),a
	ld (iy+001h),b
	ld (iy+002h),l
	ld (iy+003h),h
	comend
	ld c,004h
	ret
l1991h:
	ld a,(de)
	cp 041h
	jp nz,ERROR
	inc de
	ld b,032h
l199ah:
	call assert_eol
	comst
	ld (iy+000h),b
	ld (iy+001h),l
	ld (iy+002h),h
	comend
	ld c,003h
	ret
l19adh:
	cp 020h
	jr z,l19bbh
	add a,043h
	ld b,a
l19b4h:
	call assert_eol
	ld a,0edh
	jr l197eh
l19bbh:
	ld b,022h
	jr l199ah
l19bfh:
	ld b,a
	call sub_1ed1h
	call sub_1e41h
	jr nc,l19dbh
	push af
	ld a,b
	rlca
	rlca
	rlca
	ld b,a
	pop af
	add a,b
	add a,040h
	cp 076h
	jp z,ERROR
l19d7h:
	ld b,a
	jp l1b36h
l19dbh:
	call sub_1e68h
	jr nc,l1a02h
	ld a,b
	rlca
	rlca
	rlca
	add a,046h
	cp 076h
	jp z,ERROR
l19ebh:
	ld b,a
	call assert_eol
	ld a,(pfx.IXY)
	comst
	ld (iy+000h),a
	ld (iy+001h),b
	ld (iy+002h),c
	comend
	ld c,003h
	ret
l1a02h:
	ld a,(de)
	cp 'I'
	jr z,l1a15h
	cp 'R'
	jr nz,l1a21h
	ld a,b
	cp 007h
	jp nz,ERROR
	ld b,05fh
	jr l1a1dh
l1a15h:
	ld a,b
	cp 007h
	jp nz,ERROR
	ld b,057h
l1a1dh:
	inc de
	jp gen.opc.ED2
l1a21h:
	cp '('
	jr z,l1a3fh
	call sub_1e12h
	ld a,b			;1a28	ld r,nn
	rlca
	rlca
	rlca
	add a,006h
l1a2eh:
	ld b,a
l1a2fh:
	call assert_eol
	comst
	ld (iy+000h),b
	ld (iy+001h),l
	comend
	ld c,002h
	ret
l1a3fh:
	inc de
	ld a,b
	cp 007h
	jp nz,ERROR
	call sub_1e2eh
	jr nc,l1a59h
	cp 030h
	jp nc,ERROR
	add a,00ah
	ld b,a
	call sub_1ed8h
	jp l1b36h
l1a59h:
	call tst_EXPR
	call sub_1ed8h
	ld b,03ah
	jp l199ah
l1a64h:
	call sub_1ed1h
	call sub_1e41h
	jr nc,l1a76h
	cp 006h
	jp z,ERROR
	add a,070h
	jp l19ebh
l1a76h:
	call sub_1e12h
	call assert_eol
	ld a,(pfx.IXY)
	comst
	ld (iy+000h),a		;1a83	dd/fd
	ld (iy+001h),036h
	ld (iy+002h),c		;1a8a 	displacement
	ld (iy+003h),l		;1a8d	nn
	comend
	ld c,4
	ret
l1a93h:
	ld b,a
	call sub_1ed1h
	ld hl,t_HL.AF
	call sub_0a23h
	jr c,l1abeh
	call sub_1e50h
	jr nc,l1ac7h
	ld a,b
	cp 030h
	jr nz,l1b20h
	ld b,0f9h
l1aabh:
	call assert_eol
	ld a,(pfx.IXY)
	comst
	ld (iy+000h),a
	ld (iy+001h),b
	comend
	ld c,002h
	ret
l1abeh:
	ld a,b
	cp 030h
	jr nz,l1b20h
	ld b,0f9h
	jr l1b36h
l1ac7h:
	ld a,(de)
	cp 028h
	jr nz,l1ae3h
	inc de
	call tst_EXPR
	call sub_1ed8h
	ld a,b
	cp 020h
	jr z,l1adeh
	add a,04bh
	ld b,a
	jp l19b4h
l1adeh:
	ld b,02ah
	jp l199ah
l1ae3h:
	call tst_EXPR
	call assert_eol
	ld a,001h
	add a,b
	ld b,a
	jp l199ah
l1af0h:
	call sub_1ed1h
	ld a,(de)
	cp 028h
	jr nz,l1b04h
	inc de
	call tst_EXPR
	call sub_1ed8h
	ld b,02ah
	jp l1978h
l1b04h:
	call tst_EXPR
	ld b,021h
	jp l1978h
l1b0ch:
	inc de
	call sub_1ed1h
	ld b,047h
	jr l1b1ah
l1b14h:
	inc de
	call sub_1ed1h
	ld b,04fh
l1b1ah:
	ld a,(de)
	inc de
	cp 041h
	jr z,gen.opc.ED2
l1b20h:
	jp ERROR
l1b23h:
	cp 020h
	jr nc,l1b20h
	add a,002h
	ld b,a
	call sub_1ed8h
	call sub_1ed1h
	ld a,(de)
	cp 041h
	jr nz,l1b20h
	inc de
l1b36h:
	call assert_eol
	comst
	ld (iy+000h),b
	comend
	ld c,001h
	ret
gen.opc.ED2:
	call assert_eol
	comst
	ld (iy+000h),0edh
	ld (iy+001h),b
	comend
	ld c,002h
	ret
l1b54h:
	ld hl,t_HL.AF
	call sub_0a23h
	jr nc,l1babh
	call sub_1ed1h
	call sub_1e2eh
	jp nc,ERROR
	push af
	ld a,b
	cp 088h
	ld b,04ah
	jr z,l1b6fh
	ld b,042h
l1b6fh:
	pop af
	add a,b
l1b71h:
	ld b,a
	jr gen.opc.ED2
l1b74h:
	ld hl,t_HL.AF
	call sub_0a23h
	jr c,l1b9dh
	call sub_1e50h
	jr nc,l1babh
	call sub_1ed1h
	ld hl,t_BC.DE.IX.SP
	ld a,(pfx.IXY)
	cp 0fdh
	jr nz,l1b91h
	ld hl,t_BC.DE.IY.SP
l1b91h:
	call sub_1e2bh
	jp nc,ERROR
	add a,009h
l1b99h:
	ld b,a
	jp l1aabh
l1b9dh:
	call sub_1ed1h
	call sub_1e2eh
	jp nc,ERROR
	add a,009h
	jp l19d7h
l1babh:
	ld a,(de)
	cp 041h
	jr nz,l1bbbh
	push de
	inc de
	call skip_to_nextarg
	jr z,l1bbah
	pop de
	jr l1bbbh
l1bbah:
	pop af
l1bbbh:
	call sub_1e41h
	jr c,l1bceh
	call sub_1e68h
	jr c,l1bd2h
	call sub_1e12h
	ld a,b
	add a,046h
	jp l1a2eh
l1bceh:
	add a,b
	jp l19d7h
l1bd2h:
	ld a,b
	add a,006h
	jp l19ebh
l1bd8h:
	call sub_1e41h
	jr c,l1c01h
	call sub_1e68h
	jp nc,ERROR
	ld a,b
	add a,006h
	ld b,a
l1be7h:
	call assert_eol
	ld a,(pfx.IXY)
	comst
	ld (iy+000h),a
	ld (iy+001h),0cbh
	ld (iy+002h),c
	ld (iy+003h),b
	comend
	ld c,004h
	ret
l1c01h:
	add a,b
l1c02h:
	ld b,a
	call assert_eol
	comst
	ld (iy+000h),0cbh
	ld (iy+001h),b
	comend
	ld c,002h
	ret
l1c14h:
	call sub_1de6h
	call sub_1ed1h
	call sub_1e41h
	jr c,l1c2fh
	call sub_1e68h
	jp nc,ERROR
	ld a,l
	rlca
	rlca
	rlca
	add a,006h
	add a,b
	ld b,a
	jr l1be7h
l1c2fh:
	add a,b
	ld b,a
	ld a,l
	rlca
	rlca
	rlca
	add a,b
	jr l1c02h
l1c38h:
	push de
	call sub_1eb8h
	jr nc,l1c47h
	add a,b
	ld b,a
	call skip_to_nextarg
	jr z,l1c49h
	pop de
	push de
l1c47h:
	ld b,0cdh
l1c49h:
	pop af
	call tst_EXPR
	jp l199ah
l1c50h:
	call sub_1eb8h
	jr nc,l1c59h
	add a,b
	ld b,a
	jr l1c5bh
l1c59h:
	ld b,0c9h
l1c5bh:
	jp l1b36h
l1c5eh:
	push de
	call sub_1eb8h
	jr c,l1c71h
l1c64h:
	pop de
	ld hl,b_0x1C97_start
	call sub_0a15h
	jr c,l1c7fh
	ld b,0c3h
	jr l1c79h
l1c71h:
	add a,b
	ld b,a
	call skip_to_nextarg
	jr nz,l1c64h
	pop af
l1c79h:
	call tst_EXPR
	jp l199ah
l1c7fh:
	call assert_eol
	ld a,b
	and a
	jr nz,l1c8bh
	ld b,0e9h
	jp l1b36h
l1c8bh:
	ld b,0ddh
	dec a
	jr z,l1c92h
	ld b,0fdh
l1c92h:
	ld l,0e9h
	jp l1a2fh

b_0x1C97_start:
	DC	'(HL)'
	DC	'(IX)'
	DC	'(IY)'
	DB	0

l1ca4h:
	call skip_to_nextarg
	ld b,010h
	jr l1cb9h
l1cabh:
	call sub_1ebfh
	jr c,l1cb4h
	ld b,018h
	jr l1cb9h
l1cb4h:
	add a,b
	ld b,a
	call sub_1ed1h
l1cb9h:
	call sub_1defh
	jp l1a2fh
l1cbfh:
	call sub_1e12h
	ld a,l
	cp 003h
	jr nc,l1d23h
	and a
	jr z,l1cd2h
	ld b,056h
	cp 001h
	jr z,l1cd2h
	ld b,05eh
l1cd2h:
	jp gen.opc.ED2
l1cd5h:
	call sub_1e12h
	ld a,l
	push af
	add a,b
	ld b,a
	pop af
	and 0c7h
	jr nz,l1d23h
	jp l1b36h
l1ce4h:
	call sub_1e50h
	jr c,l1cf2h
	call sub_1e25h
	jr nc,l1d23h
	add a,b
	jp l19d7h
l1cf2h:
	ld a,b
	add a,020h
	jp l1b99h
l1cf8h:
	call sub_1e41h
	jr nc,l1d23h
	cp 006h
	jr z,l1d23h
	rlca
	rlca
	rlca
	add a,b
	ld b,a
	cp 078h
	jr nz,l1d1ah
	call sub_1ed1h
	call sub_1d26h
	jr c,l1d20h
	call sub_1e06h
	ld b,0dbh
	jp l1a2fh
l1d1ah:
	call sub_1ed1h
	call sub_1d26h
l1d20h:
	jp c,gen.opc.ED2
l1d23h:
	jp ERROR
sub_1d26h:
	ld hl,t__C_
	jp sub_0a23h
l1d2ch:
	call sub_1d26h
	jr nc,l1d44h
	call sub_1ed1h
	call sub_1e41h
	jr nc,l1d23h
	cp 006h
	jr z,l1d23h
	rlca
	rlca
	rlca
	add a,b
	jp l1b71h
l1d44h:
	call sub_1e06h
	call sub_1ed1h
	cp 041h
	jr nz,l1d23h
	inc de
	ld b,0d3h
	jp l1a2fh
l1d54h:
	ld hl,b_0x1D80_start
	call sub_0a15h
	jp nc,ERROR
	ld c,b
	call assert_eol
	ld b,000h
	ld hl,b_0x1DA1_start
	add hl,bc
	add hl,bc
	ld a,(hl)
	comst
	ld (iy+000h),a
	comend
	ld c,001h
	inc hl
	ld a,(hl)
	and a
	ret z
	comst
	ld (iy+001h),a
	comend
	ld c,002h
	ret

b_0x1D80_start:
	DC	'AF,AF'''
l1d86h:
	DC	'DE,HL'
	DC	'(SP),HL'
	DC	'(SP),IX'
	DC	'(SP),IY'
	db	000h

b_0x1DA1_start:
	db	008h
	db	000h
	db	0ebh
	db	000h
	db	0e3h
	db	000h
	db	0ddh
	db	0e3h
	db	0fdh
	db	0e3h
l1dabh:
	call sub_1e50h
	jr c,l1dc6h
	call sub_1e2eh
	jr c,l1dd2h
	call sub_1e41h
	jr c,l1ddfh
	call sub_1e68h
	jp nc,ERROR
	ld a,b
	add a,030h
	jp l19ebh
l1dc6h:
	ld a,b
	ld b,023h
	cp 004h
	jr z,l1dcfh
	ld b,02bh
l1dcfh:
	jp l1aabh
l1dd2h:
	push af
	ld a,b
	ld b,003h
	cp 004h
	jr z,l1ddch
	ld b,00bh
l1ddch:
	pop af
	jr l1de2h
l1ddfh:
	rlca
	rlca
	rlca
l1de2h:
	add a,b
	jp l19d7h
sub_1de6h:
	call sub_1e12h
	ld a,l
	cp 008h
	jr nc,error1
	ret
sub_1defh:
	call tst_EXPR
	push bc
	push iy
	pop bc
	and a
	sbc hl,bc
	dec hl
	dec hl
	pop bc
	call sub_1e15h
	ld a,h
	xor l
	bit 7,a
	jr nz,error1
	ret
sub_1e06h:
	ld a,(de)
	cp 028h
	jr nz,sub_1e12h
	inc de
	call sub_1e12h
	jp sub_1ed8h

sub_1e12h:
	call tst_EXPR
sub_1e15h:
	ld a,h
	and a
	ret z
	inc a
	ret z
	jr error1

tst_EXPR:
	push bc
	call EXPR
	pop bc
	ret nc
error1:
	jp ERROR
sub_1e25h:
	push hl
	ld hl,t_BC.DE.HL.AF
	jr l1e32h
sub_1e2bh:
	push hl
	jr l1e32h
sub_1e2eh:
	push hl
	ld hl,t_BC.DE.HL.SP
l1e32h:
	push bc
	call sub_0a15h
	jr nc,l1e3eh
	ld a,b
	rlca
	rlca
	rlca
	rlca
	scf
l1e3eh:
	pop bc
	pop hl
	ret
sub_1e41h:
	call SKIPBL
	push bc
	push hl
	ld hl,t_BCDEHL_HL_A
	call sub_0a15h
	ld a,b
	pop hl
	pop bc
	ret
sub_1e50h:
	push hl
	push bc
	ld hl,t_IX.IY
	call sub_0a15h
	jr nc,l1e65h
	ld a,0ddh
	dec b
	jr nz,l1e61h
	ld a,0fdh
l1e61h:
	ld (pfx.IXY),a
	scf
l1e65h:
	pop bc
	pop hl
	ret
sub_1e68h:
	push hl
	push bc
	ld a,(de)
	cp '('
	jr nz,l1eb4h
	push de
	inc de
	ld hl,t_IX.IY
	call sub_0a15h
	jr nc,l1eb3h
	pop af
	ld a,0ddh
	dec b
	jr nz,l1e81h
	ld a,0fdh
l1e81h:
	ld (pfx.IXY),a
	ld a,(de)
	cp '+'
	jr z,l1e95h
	cp ')'
	ld hl,0
	jr z,l1eadh
	cp '-'
	jp nz,ERROR
l1e95h:
	push af
	inc de
	call sub_1e12h		;1e97	get displacement
	pop af
	cp '+'
	jr z,l1ea7h
	ld b,h
	ld c,l
	ld hl,0
	and a
	sbc hl,bc
l1ea7h:
	ld a,(de)
	cp ')'
	jp nz,ERROR
l1eadh:
	inc de
	pop bc
	ld c,l
	pop hl
	scf
	ret
l1eb3h:
	pop de
l1eb4h:
	pop bc
	pop hl
	and a
	ret
sub_1eb8h:
	ld hl,t_tstfl_ZCPS
	ld c,007h
	jr l1ec4h
sub_1ebfh:
	ld hl,t_tstfl_ZC
	ld c,003h
l1ec4h:
	push bc
	call sub_0a15h
	ld a,b
	pop bc
	ret nc
	and c
	rlca
	rlca
	rlca
	scf
	ret
sub_1ed1h:
	call skip_to_nextarg
	ret z
l1ed5h:
	jp ERROR
sub_1ed8h:
	ld a,(de)
	cp 029h
	jr nz,l1ed5h
	inc de
	ret
CMD.L:
	ld hl,CMD.L
	ld (CMD_RPT),hl
	call EXPR
	jr nc,l1eedh
	ld hl,(lst.L)
l1eedh:
	push hl
	pop iy
	call skip_to_nextarg
	call sub_0aa5h
	jr nc,l1f17h
	call assert_eol
	ld b,010h
l1efdh:
	push bc
	push iy
	pop hl
	push hl
	call sub_1f3fh
	call CRLF
	pop iy
	ld c,b
	ld b,000h
	add iy,bc
	ld (lst.L),iy
	pop bc
	djnz l1efdh
	ret
l1f17h:
	call assert_eol
	ld h,b
	ld l,c
	ld a,b
	or c
	jr nz,l1f21h
	dec hl
l1f21h:
	push hl
	push iy
	pop hl
	push hl
	call sub_1f3fh
	call CRLF
	pop iy
	ld e,b
	ld d,000h
	add iy,de
	ld (lst.L),iy
	pop hl
	and a
	sbc hl,de
	ret z
	ret c
	jr l1f21h
sub_1f3fh:
	call out.hl.@
	call z,OUTBL
	call OUTBL
	sub a
	ld (CON.COL),a
	call sub_1f77h
	and a
	ret z
l1f51h:
	call OUTBL
	ld a,(CON.COL)
	cp 010h
	jr c,l1f51h
sub_1f5bh:
	ld de,(offs.@)
	ld a,d
	or e
	ret z
	ld a,'('
	call OUTCHAR
	ld a,'@'
	call OUTCHAR
	and a
	sbc hl,de
	call out.hl
	ld a,')'
	jp OUTCHAR
sub_1f77h:
	sub a
	ld (XBE03),a
	call sub_1f9eh
	jr nc,l1f91h
	push bc
	call sub_2581h
	ex de,hl
	call sub_1fdbh
	pop bc
	ld a,(XBE03)
	ld hl,(XBE01)
	scf
	ret
l1f91h:
	ld hl,b_0x1F9B_start
	call PSTR
	ld b,001h
	sub a
	ret

b_0x1F9B_start:
	DC	'???'

sub_1f9eh:
	sub a
	ld (is.pfx.IXY),a
	comst
	ld a,(iy+000h)
	comend
	cp 0edh
	jp z,disas_pfx.ED
	cp 0ddh
	jr z,l1fc5h
	cp 0fdh
	jr z,l1fc9h
sub_1fb6h:
	comst
	ld a,(iy+000h)
	comend
	cp 0cbh
	jp z,l2061h
	jp l2078h
l1fc5h:
	ld a,001h
	jr l1fcbh
l1fc9h:
	ld a,002h
l1fcbh:
	ld (is.pfx.IXY),a
	call sub_1fdch
	ret nc
	push bc
	call sub_1fb6h
	pop af
	add a,b
	ld b,a
	scf
	ret

sub_1fdbh:
	jp (hl)

sub_1fdch:
	inc iy
	ld hl,b_0x2011_start
	call sub_20bbh
	ld b,002h
	ret c
	ld hl,l202ch
	call sub_20bbh
	ld b,001h
	ret c
	comst
	ld a,(iy+000h)
	comend
	cp 0cbh
	jr nz,l200fh
	comst
	ld a,(iy+002h)
	comend
	cp 036h
	ret z
	and 007h
	cp 006h
	jr nz,l200fh
	ld b,002h
	scf
	ret
l200fh:
	and a
	ret

b_0x2011_start:
	db	034h
	db	035h
	db	036h
	db	046h
	db	04eh
	db	056h
	db	05eh
	db	066h
	db	06eh
	db	070h
	db	071h
	db	072h
	db	073h
	db	074h
	db	075h
	db	076h
	db	077h
	db	07eh
	db	086h
	db	08eh
	db	096h
	db	09eh
	db	0a6h
	db	0aeh
	db	0b6h
	db	0beh
	db	000h
l202ch:
	db	009h
	db	019h
	db	021h
	db	022h
	db	023h
	db	029h
	db	02ah
	db	02bh
	db	039h
	db	0e1h
	db	0e3h
	db	0e5h
	db	0e9h
	db	0f9h
	db	000h

disas_pfx.ED:
	inc iy
	ld hl,b_0x2200_start
	call sub_209dh
	ld b,002h
	ret c
	ld hl,l2235h
	call lookup_opc
	ld b,002h
	ret c
	ld hl,l228bh
	call lookup_opc
	ld b,003h
	ret c
	ld hl,l22b4h
	call lookup_opc
	ld b,004h
	ret
l2061h:
	push iy
	inc iy
	ld a,(is.pfx.IXY)
	and a
	jr z,l206dh
	inc iy
l206dh:
	ld hl,l22c9h
	call lookup_opc
	pop iy
	ld b,002h
	ret
l2078h:
	ld hl,b_0x218B_start
	call lookup_opc
	ld b,002h
	ret c
	ld hl,b_0x20ED_start
	call sub_209dh
	ld b,001h
	ret c
	ld hl,b_0x2108_start
	call lookup_opc
	ld b,001h
	ret c
	ld hl,b_0x21D2_start
	call lookup_opc
	ret nc
	ld b,003h
	ret

sub_209dh:
	ld a,(hl)
	cp 0ffh
	ret z
	comst
	cp (iy+000h)
	comend
	jr z,l20aeh
	inc hl
	inc hl
	jr sub_209dh
l20aeh:
	inc hl
	ld c,(hl)
	ld hl,t_MNEMONICS
	ld b,000h
	add hl,bc
	ld de,l230bh
	scf
	ret
sub_20bbh:
	ld a,(hl)
	and a
	ret z
	inc hl
	comst
	cp (iy+000h)
	comend
	jr nz,sub_20bbh
	scf
	ret

lookup_opc:
	comst
	ld a,(iy+000h)
	comend
	and (hl)
	inc hl
	cp (hl)
	jr z,l20dfh
	inc hl
	inc hl
	inc hl
	inc hl
	ld a,(hl)
	and a
	jr nz,lookup_opc
	ret
l20dfh:
	inc hl
	ld c,(hl)
	inc hl
	ld e,(hl)
	inc hl
	ld d,(hl)
	ld hl,t_MNEMONICS
	ld b,000h
	add hl,bc
	scf
	ret

b_0x20ED_start:			;	1 byte opcodes (no parameters)
	db	076h		;20ed	halt
	db	039h		;20ee
	db	0d9h		;20ef	exx
	db	036h
	db	0f3h		;20f1	di
	db	02ch
	db	0fbh		;20f3	ei
	db	032h
	db	000h		;20f5	nop
	db	069h
	db	007h		;20f7	rlca
	db	09eh
	db	00fh		;20f9	rrca
	db	0adh
	db	017h		;20fb	rla
	db	098h
	db	01fh		;20fd	rra
	db	0a7h
	db	027h		;20ff	daa
	db	026h
	db	02fh		;2101	cpl
	db	023h
	db	037h		;2103	scf
	db	0bah
	db	03fh		;2105	ccf
	db	010h
	db	0ffh		;2107	EOT

b_0x2108_start:			;	1 byte opcodes
	defb 0c0h		;2108	ld r,r
	defb 040h
	defb 056h
	defw l22fch

	defb 0f8h		;210d	add a,r
	defb 080h
	defb 003h
	defw l2305h

	defb 0f8h		;2112	adc a,r
	defb 088h
	defb 000h
	defw l2305h

	defb 0f8h
	defb 090h
	defb 0c9h
	defw l24ebh

	defb 0f8h
	defb 098h
	defb 0b7h
	defw l2305h

	defb 0f8h
	defb 0a0h
	defb 006h
	defw l24ebh

	defb 0f8h
	defb 0a8h
	defb 0cch
	defw l24ebh

	defb 0f8h
	defb 0b0h
	defb 06ch
	defw l24ebh

	defb 0f8h
	defb 0b8h
	defb 013h
	defw l24ebh

	defb 0c7h
	defb 0c0h		;2136	ret cc
	defb 08bh
	defw l2561h

	defb 0c7h		;213a	rst
	defb 0c7h
	defb 0b4h
	defw l231eh

	defb 0ffh		;213f	ret
	defb 0c9h
	defb 08bh
	defw l230bh

	defb 0cfh		;2144	pop rr
	defb 0c1h
	defb 081h
	defw l2546h

	defb 0cfh		;2149	push rr
	defb 0c5h
	defb 084h
	defw l2546h

	defb 0ffh		;214e	ex (sp),hl
	defb 0e3h
	defb 034h
	defw l232ah

	defb 0ffh		;2153	jp (hl)
	defb 0e9h
	defb 052h
	defw l2338h

	defb 0ffh		;2158	ex de,hl
	defb 0ebh
	defb 034h
	defw l2345h

	defb 0ffh		;215d	ld sp,hl
	defb 0f9h
	defb 056h
	defw l234bh

	defb 0cfh		;2162	inc rr
	defb 003h
	defb 041h
	defw l254bh

	defb 0cfh		;2167	dec rr
	defb 00bh
	defb 029h
	defw l254bh


	defb 0c7h		;216c	inc r
	defb 004h
	defb 041h
	defw l24dfh

	defb 0c7h		;2171	dec r
	defb 005h
	defb 029h
	defw l24dfh

	defb 0ffh		;2176	ex af,af'
	defb 008h
	defb 034h
	defw l2357h

	defb 0cfh		;217b	add hl,rr
	defb 009h
	defb 003h
	defw l235dh

	defb 0efh		;2180	ld (rr),a ;rr=bc,de
	defb 002h
	defb 056h
	defw l2366h

	defb 0efh		;2185	ld a,(rr) ;rr=bc,de
	defb 00ah
	defb 056h
	defw l236fh

	defb 000h		;218a	EOT

b_0x218B_start:			;	2 byte opdodes
	defb 0c7h		;218b	ld r,nn
	defb 006h
	defb 056h
	defw l2384h

	defb 0ffh		;2190	add a,nn
	defb 0c6h
	defb 003h
	defw l237fh

	defb 0ffh		;2195	adc a,nn
	defb 0ceh
	defb 000h
	defw l237fh

	defb 0ffh		;219a	sub a,nn
	defb 0d6h
	defb 0c9h
	defw l2397h

	defb 0ffh
	defb 0deh
	defb 0b7h
	defw l237fh

	defb 0ffh		;21a4	and a,nn
	defb 0e6h
	defb 006h
	defw l2397h

	defb 0ffh
	defb 0eeh
	defb 0cch
	defw l2397h

	defb 0ffh
	defb 0f6h
	defb 06ch
	defw l2397h

	defb 0ffh		;21b3	cp a,nn
	defb 0feh
	defb 013h
	defw l2397h

	defb 0ffh		;21b8	djnz
	defb 010h
	defb 02eh
	defw l23b0h

	defb 0ffh		;21bd	jr
	defb 018h
	defb 054h
	defw l23b0h

	defb 0e7h		;21c2	jr,cc
	defb 020h
	defb 054h
	defw l23a1h

	defb 0ffh
	defb 0d3h		;21c8	out (nn),a
	defb 076h
	defw l23d5h

	defb 0ffh		;21cc	in a,(nn)
	defb 0dbh
	defb 03fh
	defw l23c3h

	defb 000h		;21d1	EOT

b_0x21D2_start:			;	3 byte opcodes
	defb 0c7h
	defb 0c2h
	defb 052h
	defw l23e0h

	defb 0c7h
	defb 0c4h
	defb 00ch
	defw l23e0h

	defb 0cfh
	defb 001h
	defb 056h
	defw l23fch

	defb 0ffh
	defb 0c3h
	defb 052h
	defw l23e6h

	defb 0ffh
	defb 0cdh
	defb 00ch
	defw l23e6h

	defb 0ffh
	defb 022h
	defb 056h
	defw l2404h

	defb 0ffh
	defb 02ah
	defb 056h
	defw l240dh

	defb 0ffh
	defb 032h
	defb 056h
	defw l2416h

	defb 0ffh
	defb 03ah
	defb 056h
	defw l2421h

	defb 000h

b_0x2200_start:			;	prefix ED + 1 byte opcode
	defb 044h		;2200	neg
	defb 066h
	defb 045h		;2202	retn
	defb 092h
	defb 04dh		;2204	reti
	defb 08eh
	defb 067h		;2206	rrd
	defb 0b1h
	defb 06fh		;2208	rld
	defb 0a2h
	defb 0a0h		;220a	ldi
	defb 05fh
	defb 0a1h
	defb 01ch
	defb 0a2h
	defb 04bh
	defb 0a3h
	defb 07dh
	defb 0a8h		;2212	ldd
	defb 058h
	defb 0a9h
	defb 015h
	defb 0aah
	defb 044h
	defb 0abh
	defb 079h
	defb 0b0h		;221a	ldir
	defb 062h
	defb 0b1h
	defb 01fh
	defb 0b2h
	defb 04eh
	defb 0b3h
	defb 072h
	defb 0b8h		;2222	lddr
	defb 05bh
	defb 0b9h
	defb 018h
	defb 0bah
	defb 047h
	defb 0bbh
	defb 06eh
	defb 08bh		;222a	otdm
	defb 0d5h
	defb 09bh		;222c	otdmr
	defb 0d9h
	defb 083h		;222e	otim
	defb 0deh
	defb 093h		;2230	otimr
	defb 0e2h
	defb 076h		;2232	slp
	defb 0ebh
	defb 0ffh		;2234	EOT

l2235h:
	defb 0e7h		;2235	in r,(c) ;r=bcde
	defb 040h
	defb 03fh
	defw l2455h

	defb 0f7h		;223a	in r,(c) ;r=hl
	defb 060h
	defb 03fh
	defw l2455h

	defb 0ffh		;223f	in r,(c) ;r=a
	defb 078h
	defb 03fh
	defw l2455h

	defb 0e7h
	defb 041h
	defb 076h
	defw l2461h

	defb 0f7h
	defb 061h
	defb 076h
	defw l2461h

	defb 0ffh		;224e	out (c),r ;r=a
	defb 079h
	defb 076h
	defw l2461h

	defb 0cfh		;2253	sbc hl,rr
	defb 042h
	defb 0b7h
	defw l246dh

	defb 0cfh		;2258	adc hl,rr
	defb 04ah
	defb 000h
	defw l246dh

	defb 0ffh		;225d	im 0
	defb 046h
	defb 03dh
	defw l2427h

	defb 0ffh		;2262	im 1
	defb 056h
	defb 03dh
	defw l242bh

	defb 0ffh		;2267	im 2
	defb 05eh
	defb 03dh
	defw l242fh

	defb 0ffh		;226c	ld i,a
	defb 047h
	defb 056h
	defw l2434h

	defb 0ffh
	defb 057h
	defb 056h
	defw l2439h

	defb 0ffh
	defb 04fh
	defb 056h
	defw l243eh

	defb 0ffh
	defb 05fh
	defb 056h
	defw l2443h

	defb 0cfh		;2280	mlt rr
	defb 04ch
	defb 0d2h
	defw l254bh

	defb 0c7h		;2285	tst r
	defb 004h
	defb 0eeh
	defw l24dfh

	defb 000h

l228bh:
	defb 0e7h
	defb 000h
	defb 0cfh
	defw l230ch

	defb 0f7h
	defb 020h
	defb 0cfh
	defw l230ch

	defb 0ffh
	defb 038h
	defb 0cfh
	defw l230ch

	defb 0e7h
	defb 001h
	defb 0e7h
	defw l2315h

	defb 0f7h
	defb 021h
	defb 0e7h
	defw l2315h

	defb 0ffh
	defb 039h
	defb 0e7h
	defw l2315h

	defb 0ffh
	defb 064h
	defb 0eeh
	defw l2397h

	defb 0ffh
	defb 074h
	defb 0f1h
	defw l2397h
	defb 000h

l22b4h:
	defb 0efh
	defb 043h
	defb 056h

b_0x22B7_start:
	defw l2476h

b_0x22B9_start:
	defb 0ffh
	defb 073h
	defb 056h

b_0x22BC_start:
	defw l2476h

b_0x22BE_start:
	defb 0efh
	defb 04bh
	defb 056h

b_0x22C1_start:
	defw l247fh

b_0x22C3_start:
	defb 0ffh
	defb 07bh
	defb 056h

b_0x22C6_start:
	defw l247fh

b_0x22C8_start:
	defb 000h
l22c9h:
	defb 0f8h
	defb 000h
	defb 09bh

b_0x22CC_start:
	defw l24aeh

b_0x22CE_start:
	defb 0f8h
	defb 008h
	defb 0aah

b_0x22D1_start:
	defw l24aeh

b_0x22D3_start:
	defb 0f8h
	defb 010h
	defb 096h

b_0x22D6_start:
	defw l24aeh

b_0x22D8_start:
	defb 0f8h
	defb 018h
	defb 0a5h

b_0x22DB_start:
	defw l24aeh

b_0x22DD_start:
	defb 0f8h
	defb 020h
	defb 0c0h

b_0x22E0_start:
	defw l24aeh

b_0x22E2_start:
	defb 0f8h
	defb 028h
	defb 0c3h

b_0x22E5_start:
	defw l24aeh

b_0x22E7_start:
	defb 0f8h
	defb 038h
	defb 0c6h

b_0x22EA_start:
	defw l24aeh

b_0x22EC_start:
	defb 0c0h
	defb 040h
	defb 009h

b_0x22EF_start:
	defw l2487h

b_0x22F1_start:
	defb 0c0h
	defb 080h
	defb 088h

b_0x22F4_start:
	defw l2487h

b_0x22F6_start:
	defb 0c0h
	defb 0c0h
	defb 0bdh

b_0x22F9_start:
	defw l2487h

b_0x22FB_start:
	defb 000h
l22fch:
	call l24dfh
	call sub_257ch
	jp l24ebh
l2305h:
	call sub_2579h
	jp l24ebh
l230bh:
	ret
l230ch:
	call l24dfh
	call sub_257ch
	jp l23c6h
l2315h:
	call l23c6h
	call sub_257ch
	jp l24dfh
l231eh:
	comst
	ld a,(iy+000h)
	comend
	and 038h
	jp out.hex
l232ah:
	ld hl,b_0x2333_start
	call PSTR
	jp l253eh

b_0x2333_start:
	DC	'(SP),'

l2338h:
	ld a,'('
	call OUTCHAR
	call l253eh
	ld a,')'
	jp OUTCHAR
l2345h:
	ld hl,l1d86h
	jp PSTR
l234bh:
	ld hl,b_0x2354_start
	call PSTR
	jp l253eh

b_0x2354_start:
	DC	'SP,'

l2357h:
	ld hl,b_0x1D80_start
	jp PSTR
l235dh:
	call l253eh
	call sub_257ch
	jp l254bh
l2366h:
	call sub_2372h
	call sub_257ch
	jp l23dbh
l236fh:
	call sub_2579h
sub_2372h:
	ld a,'('
	call OUTCHAR
	call l254bh
	ld a,')'
	jp OUTCHAR
l237fh:
	call sub_2579h
	jr l2397h
l2384h:
	call l24dfh
	call sub_257ch
	ld a,(is.pfx.IXY)
	and a
	comst
	ld a,(iy+002h)
	comend
	jr nz,l239eh
l2397h:
	comst
	ld a,(iy+001h)
	comend
l239eh:
	jp out.hex
l23a1h:
	comst
	ld a,(iy+000h)
	comend
	and 018h
	call sub_2568h
	call sub_257ch
l23b0h:
	comst
	ld c,(iy+001h)
	comend
	ld a,c
	rla
	sbc a,a
	ld b,a
	push iy
	pop hl
	add hl,bc
	inc hl
	inc hl
	jr l23f0h
l23c3h:
	call sub_2579h
l23c6h:
	ld a,028h
	call OUTCHAR
	comst
	ld a,(iy+001h)
	comend
	jp l252bh
l23d5h:
	call l23c6h
	call sub_257ch
l23dbh:
	ld a,041h
	jp OUTCHAR
l23e0h:
	call l2561h
	call sub_257ch
l23e6h:
	comst
	ld l,(iy+001h)
	ld h,(iy+002h)
	comend
l23f0h:
	ld a,002h
sub_23f2h:
	ld (XBE03),a
	ld (XBE01),hl
	call out.hl
	ret
l23fch:
	call l254bh
	call sub_257ch
	jr l23e6h
l2404h:
	call sub_24c6h
	call sub_257ch
	jp l253eh
l240dh:
	call l253eh
	call sub_257ch
	jp sub_24c6h
l2416h:
	call sub_24c6h
	call sub_257ch
	ld a,041h
	jp OUTCHAR
l2421h:
	call sub_2579h
	jp sub_24c6h
l2427h:
	ld a,030h
	jr l2431h
l242bh:
	ld a,031h
	jr l2431h
l242fh:
	ld a,032h
l2431h:
	jp OUTCHAR
l2434h:
	ld hl,b_0x2449_start
	jr l2446h
l2439h:
	ld hl,l244ch
	jr l2446h
l243eh:
	ld hl,l244fh
	jr l2446h
l2443h:
	ld hl,l2452h
l2446h:
	jp PSTR

b_0x2449_start:
	DC	'I,A'
l244ch:
	DC	'A,I'
l244fh:
	DC	'R,A'
l2452h:
	DC	'A,R'

l2455h:
	call l24dfh
	call sub_257ch
	ld hl,t__C_
	jp PSTR
l2461h:
	ld hl,t__C_
	call PSTR
	call sub_257ch
	jp l24dfh
l246dh:
	call l253eh
	call sub_257ch
	jp l254bh
l2476h:
	call sub_24c6h
	call sub_257ch
	jp l254bh
l247fh:
	call l254bh
	call sub_257ch
	jr sub_24c6h
l2487h:
	ld a,(is.pfx.IXY)
	and a
	jr nz,l2496h
	comst
	ld a,(iy+001h)
	comend
	jr l249dh
l2496h:
	comst
	ld a,(iy+002h)
	comend
l249dh:
	push af
	rra
	rra
	rra
	and 007h
	add a,'0'
	call OUTCHAR
	call sub_257ch
	pop af
	jr l24f2h
l24aeh:
	ld a,(is.pfx.IXY)
	and a
	jr nz,l24bdh
	comst
	ld a,(iy+001h)
	comend
	jr l24c4h
l24bdh:
	comst
	ld a,(iy+002h)
	comend
l24c4h:
	jr l24f2h
sub_24c6h:
	ld a,'('
	call OUTCHAR
	comst
	ld l,(iy+001h)
	ld h,(iy+002h)
	comend
	ld a,001h
	call sub_23f2h
	ld a,')'
	jp OUTCHAR
l24dfh:
	comst
	ld a,(iy+000h)
	comend
	rra
	rra
	rra
	jr l24f2h
l24ebh:
	comst
	ld a,(iy+000h)
	comend
l24f2h:
	and 007h
	cp 006h
	jr nz,l2533h
	ld a,(is.pfx.IXY)
	and a
	ld a,006h
	jr z,l2533h
	ld hl,b_0x2538_start
	ld a,(is.pfx.IXY)
	dec a
	jr z,l250ch
	ld hl,b_0x253B_start
l250ch:
	call PSTR
	comst
	ld a,(iy+001h)
	comend
	and a
	push af
	jp m,l2523h
	ld a,'+'
	call OUTCHAR
	pop af
	jr l252bh
l2523h:
	ld a,'-'
	call OUTCHAR
	pop af
	neg
l252bh:
	call out.hex
	ld a,')'
	jp OUTCHAR
l2533h:
	ld hl,t_BCDEHL_HL_A
	jr l2572h

b_0x2538_start:
	DC	'(IX'
b_0x253B_start:
	DC	'(IY'

l253eh:
	ld a,(is.pfx.IXY)
	ld hl,t_HL.IX.IY
	jr l2572h
l2546h:
	ld hl,t_BC.DE.HL.AF
	jr l254eh
l254bh:
	ld hl,t_BC.DE.HL.SP
l254eh:
	comst
	ld a,(iy+000h)
	comend
	rra
	rra
	rra
	rra
	and 003h
	cp 002h
	jr z,l253eh
	jr l2572h
l2561h:
	comst
	ld a,(iy+000h)
	comend
sub_2568h:
	rra
	rra
	rra
	and 007h
	ld hl,t_tstfl_ZCPS
	jr l2572h
l2572h:
	ld b,a
	call sub_0a48h
	jp PSTR
sub_2579h:
	call l23dbh
sub_257ch:
	ld a,','
	jp OUTCHAR
sub_2581h:
	call PSTR
l2584h:
	call OUTBL
	inc c
	ld a,c
	cp 006h
	jr nz,l2584h
	ret

t_MNEMONICS:
	DC	'ADC'
	DC	'ADD'
	DC	'AND'
	DC	'BIT'
	DC	'CALL'
	DC	'CCF'
	DC	'CP'
	DC	'CPD'
	DC	'CPDR'
	DC	'CPI'
	DC	'CPIR'
	DC	'CPL'
	DC	'DAA'
	DC	'DEC'
	DC	'DI'
	DC	'DJNZ'
	DC	'EI'
	DC	'EX'
	DC	'EXX'
	DC	'HALT'
	DC	'IM'
	DC	'IN'
	DC	'INC'
	DC	'IND'
	DC	'INDR'
	DC	'INI'
	DC	'INIR'
	DC	'JP'
	DC	'JR'
	DC	'LD'
	DC	'LDD'
	DC	'LDDR'
	DC	'LDI'
	DC	'LDIR'
	DC	'NEG'
	DC	'NOP'
	DC	'OR'
	DC	'OTDR'
	DC	'OTIR'
	DC	'OUT'
	DC	'OUTD'
	DC	'OUTI'
	DC	'POP'
	DC	'PUSH'
	DC	'RES'
	DC	'RET'
	DC	'RETI'
	DC	'RETN'
	DC	'RL'
	DC	'RLA'
	DC	'RLC'
	DC	'RLCA'
	DC	'RLD'
	DC	'RR'
	DC	'RRA'
	DC	'RRC'
	DC	'RRCA'
	DC	'RRD'
	DC	'RST'
	DC	'SBC'
	DC	'SCF'
	DC	'SET'
	DC	'SLA'
	DC	'SRA'
	DC	'SRL'
	DC	'SUB'
	DC	'XOR'
	DC	'IN0'
	DC	'MLT'
	DC	'OTDM'
	DC	'OTDMR'
	DC	'OTIM'
	DC	'OTIMR'
	DC	'OUT0'
	DC	'SLP'
	DC	'TST'
	DC	'TSTIO'
	DB	0

t_BCDEHL_HL_A:
	DC	'B'
	DC	'C'
	DC	'D'
	DC	'E'
	DC	'H'
	DC	'L'
	DC	'(HL)'
	DC	'A'
	DB	0
t_BC.DE.HL.SP:
	DC	'BC'
	DC	'DE'
	DC	'HL'
	DC	'SP'
	DB	0
t_BC.DE.HL.AF:
	DC	'BC'
	DC	'DE'
t_HL.AF:
	DC	'HL'
	DC	'AF'
	DB	0
t_BC.DE.IY.SP:
	DC	'BC'
	DC	'DE'
	DC	'IY'
	DC	'SP'
	DB	0
t_BC.DE.IX.SP:
	DC	'BC'
	DC	'DE'
	DC	'IX'
	DC	'SP'
	DB	0
t_HL.IX.IY:
	DC	'HL'
t_IX.IY:
	DC	'IX'
	DC	'IY'
	DB	0
t_tstfl_ZC:
	DC	'NZ'
	DC	'Z'
	DC	'NC'
	DC	'C'
	DC	'NE'
	DC	'EQ'
	DC	'GE'
	DC	'LT'
	DB	0
t_tstfl_ZCPS:
	DC	'NZ'
	DC	'Z'
	DC	'NC'
	DC	'C'
	DC	'PO'
	DC	'PE'
	DC	'P'
	DC	'M'
	DC	'NE'
	DC	'EQ'
	DC	'GE'
	DC	'LT'
	DC	'NV'
	DC	'V'
	DB	0
t__C_:
	DC	'(C)'
	DB	0

sub_26e7h:
	ld hl,(REG.PC)
	ld a,h
	or l
	jr z,l2715h
	ld iy,(REG.PC)
	call sub_1f9eh
	jp nc,ERROR
	ld c,b
	ld b,000h
	ld hl,(REG.PC)
	add hl,bc
	call sub_1117h
	ld iy,(REG.PC)
	ld hl,b_0x2717_start
	call lookup_opc
	ccf
	ret c
	ex de,hl
	call CALL.HL
	call c,sub_1117h
l2715h:
	scf
	ret

b_0x2717_start:
	db	0ffh
	db	0ddh
	db	000h
	dw	x278d

	db	0ffh
	db	0fdh
	db	000h
	dw	x2792

	db	0ffh
	db	0edh
	db	000h
	dw	x27a2

l2726h:
	db	0ffh
	db	0cdh
	db	000h
	dw	x275e

	db	0ffh
	db	0c3h
	db	000h
	dw	x2769

	db	0ffh
	db	0e9h
	db	000h
	dw	x2788

	db	0ffh
	db	0c9h
	db	000h
	dw	x27c9

	db	0ffh
	db	0cfh
	db	000h
	dw	x280e

	db	0c7h
	db	0c7h
	db	000h
	dw	x27ea

	db	0c7h
	db	0c4h
	db	000h
	dw	x275e

	db	0f7h
	db	010h
	db	000h
	dw	x2775

	db	0e7h
	db	020h
	db	000h
	dw	x2775

	db	0c7h
	db	0c2h
	db	000h
	dw	x2769

	db	0c7h
	db	0c0h
	db	000h
	dw	x27b3

	db	000h

x275e:
	ld a,(XBFE8)
	and a
	jr nz,x2769
	ld a,(TCFLG)
	and a
	ret nz

x2769:
	comst
	ld l,(iy+001h)
	ld h,(iy+002h)
	comend
	scf
	ret

x2775:
	comst
	ld c,(iy+001h)
	comend
	ld a,c
	rla
	sbc a,a
	ld b,a
	ld hl,(REG.PC)
	add hl,bc
	inc hl
	inc hl
	scf
	ret

x2788:
	ld hl,(REG.L)
	scf
	ret

x278d:
	ld hl,(reg.ix)
	jr l2795h

x2792:
	ld hl,(reg.iy)
l2795h:
	comst
	ld a,(iy+001h)
	comend
	cp 0e9h
	scf
	ret z
	and a
	ret

x27a2:
	comst
	ld a,(iy+001h)
	comend
	cp 04dh
	jr z,x27c9
	cp 045h
	jr z,x27c9
	and a
	ret

x27b3:
	comst
	ld a,(iy+000h)
	comend
	ld (XBEDD),a
	ld hl,(REG.F)
	push hl
	pop af
	call XBEDD
	scf
	jr c,x27c9
	ret

x27c9:
	ld a,(XBFE8)
	and a
	jr nz,l27dah
	ld a,(TCFLG)
	and a
	jr z,l27dah
	call l27dah
	pop hl
	ret
l27dah:
	ld hl,(REG.SP)
	comst
	ld e,(hl)
	inc hl
	ld d,(hl)
	comend
	ex de,hl
	call sub_1117h
	and a
	ret

x27ea:
	ld a,(ddtzrst)
	comst
	cp (iy+000h)
	comend
	ret z
	comst
	ld a,(iy+000h)
	comend
	and 038h
	ld l,a
	ld h,000h
	ld a,(XBFE8)
	and a
	jr nz,l280ch
	ld a,(TCFLG)
	and a
	ret nz
l280ch:
	scf
	ret

x280e:
	and a
	ret

CMD.C:
	ld hl,CMD.C
	ld a,001h
	jr l281bh

CMD.T:
	xor a
	ld hl,CMD.T
l281bh:
	ld (CMD_RPT),hl
	ld (TCFLG),a
	ld a,(de)
	sub 'N'
	jr nz,l2827h
	inc de
l2827h:
	ld (TCNFLG),a
	ld a,(de)
	sub 'J'
	jr nz,l2830h
	inc de
l2830h:
	ld (TRJFLG),a
	call sub_289fh
	jr z,l283eh
	ld hl,1
	call get_lastarg_def
l283eh:
	ld (TCCSTR),hl
	sub a
	ld (XA747),a
l2845h:
	call sub_26e7h
	jr l289ch
l284ah:
	call sub_0e68h
	ld a,(TRJFLG)
	and a
	jr nz,l2864h
	ld iy,(REG.PC)
	call sub_28c1h
	jr z,l2864h
	ld hl,l2726h
	call lookup_opc
	jr nc,l2845h
l2864h:
	ld a,(XBFEA)
	and a
	jr z,l2881h
	ld de,(TCCSTR)
	call EXPR
	ld a,h
	or l
	add a,0ffh
	sbc a,a
	ld hl,XBFEA
	xor (hl)
	bit 1,a
	jr z,l288ch
l287eh:
	jp l102eh
l2881h:
	ld hl,(TCCSTR)
	dec hl
	ld (TCCSTR),hl
	ld a,h
	or l
	jr z,l287eh
l288ch:
	call sub_26e7h
	jr nc,l287eh
	ld a,(TCNFLG)
	ld b,a
	ld a,(XA747)
	or b
	ld (XA747),a
l289ch:
	jp l1183h

sub_289fh:
	call SKIPBL
	xor a
	ld (XBFEA),a
	ld a,(de)
	cp 'U'
	jr z,l28aeh
	cp 'W'
	ret nz

l28aeh:
	inc de
	push af
	push de
	call EXPR
	jp c,ERROR
	call assert_eol
	pop hl
	pop af
	ld (XBFEA),a
	sub a
	ret

sub_28c1h:
	comst
	ld a,(iy+000h)
	ld b,(iy+0001)
	comend
	cp 0edh
	jr z,l28dbh
	and 0dfh
	cp 0ddh
	ret nz
	ld a,b
	cp 0e9h
	ret
l28dbh:
	ld a,b
	and 0f7h
	cp 045h
	ret

?excom:
	ex (sp),hl
	push af
	push bc
	push de
	ld c,(hl)
	ld b,000h
	inc hl
	ld a,?lcmax
	sub c
	ld de,?exeit
	ldir
	ex de,hl
	ld (hl),018h
	inc hl
	ld (hl),a
	ex de,hl
	pop de
	pop bc
	pop af
	ex (sp),hl
	if CPU_Z180
	push hl
	ld hl,(ubbr)

	else
	 push af
	 ld a,(ubnk)
	endif
	if ROMSYS
	 push af
	 ld a,(uromen)
	endif
	jp ?comcod

;------------------------------------------
;	ddtram
;------------------------------------------

vartab:
;	dseg
	cseg
ddtram:
;todo:
; The following 2 params are changeable by user.
; Should these moved to top ram?
;
ddtzrst:
	rst	DDTZRSTVEC	;rst used by ddtz
ddtei:	ei			;ints enabled/disabled while ddtz is running
	ret			;
offs.pc:
	dw	TPA
offs.@:
	dw	0
CMD_ERR:
	dw	0
CMD_RPT:
	dw	DDTZML
ci.buf:
	db	80
	rept	83
	db	0
	endm
CON.COL:
	db 	0
XA747:
	db	0
bp_tab:
	rept	BP_CNT
	db	0,0
	dw	0,0,0
	endm
BP_SIZE	equ	8
sexp1:
	dw	sexpbuf
sexp2:
	dw	sexpbuf
sexpbuf:
	rept	128
	db	0
	endm
sexpbufe:

msg.Y:
	dc	'Y0'
reg.Y:
	rept	10
	dw	0
	endm
lst.S:
	dw	0
lst.IP:
	dw	0
lst.OP:
	dw	0
lst.OD:
	db	0
lst.Qj:
	db	0
lst.D:
	dw	0
HILOD:
	dw	0
MAXLOD:
	dw	0
XB068:
	dw	0
lst.A:
	dw	0
XB06C:
	dw	0
pfx.IXY:
	db	000h
is.pfx.IXY:
	db	000h
lst.L:
	dw	0
XBE01:
	dw	0
XBE03:
	db	000h
XBEDD:
	ret		;ret cc
	and a
	pop hl
	inc hl
	jp (hl)
XBFE8:
	db	0
TCFLG:
	db	0
XBFEA:
	db	0
TCCSTR:
	dw	0
TCNFLG:
	db	0
TRJFLG:
	db	0
wstrtflg:
	db	1

	cseg
vartabe:

;------------------------------------------

	.phase	sysram_start+bs$stack$size
$stack:
$stcka	equ	$ - bs$stack$size

curphse	defl	$
	.dephase
sysramc:
	.phase curphse
topcodbeg:

reg.l2:	db	0		; 0fe50h
reg.h2:	db	0		; 0fe51h
reg.e2:	db	0		; 0fe52h
reg.d2:	db	0		; 0fe53h
reg.c2:	db	0		; 0fe54h
reg.b2:	db	0		; 0fe55h
reg.f2:	db	0		; 0fe56h
reg.a2:	db	0		; 0fe57h
	db	0
reg.i:	db	high ivtab
reg.iy:	dw	0		; 0fe5ah
reg.ix:	dw	0		; 0fe5ch
reg.e:	db	0		; 0fe5eh
reg.d:	db	0		; 0fe5fh
reg.c:	db	0		; 0fe60h
reg.b:	db	0		; 0fe61h
	if	ROMSYS
udcntl:	 db	CWAITIO		; 0fe62h	(mem-, io- wait)
uromen:	 db	ROM_DIS		; 0fe63h
	endif
	if CPU_Z180
ubbr:	db	0		; 0fe64h
ucbar:	db	USR$CBAR	; 0fe65h
	else
	 db	0		; 0fe64h
ubnk:	 db	0		; 0fe65h
	endif
reg.f:	db	0		; 0fe66h
reg.a:	db	0		; 0fe67h
reg.l:	db	0		; 0fe68h
reg.h:	db	0		; 0fe69h
reg.sp:	dw	TOPRAM		; 0fe6ah

$go:
	if	ROMSYS
	 out (000h),a		;064c fe6c
	 out0 (dcntl),l
	 pop hl
	endif
	if CPU_Z180
	out0 (cbar),h
	out0 (bbr),l
	else
	 ld a,h
	 call selbnk
	endif
	pop af
	pop hl
	ld sp,(reg.sp)
reg.iff:
	ei
	db	0C3h		;jp TPA	;065f feff ($+1): reg.pc
reg.pc:
	dw	TPA

bpent:
	ld (reg.l),hl		;0662 fe82: bpent:
	pop hl
	dec hl
	ld (reg.pc),hl
	ld (reg.sp),sp
	ld sp,reg.l
	push af
	if CPU_Z180
;;;	 TODO: cbar on trap?
	in0 h,(cbar)
	in0 l,(bbr)
	ld a,SYS$CBAR
	out0 (cbar),a
	else
	 ld a,(@cbnk)
	 ld h,a
	 xor a
	 ld l,a
	 call selbnk
	endif
	 push hl

	if ROMSYS
	 in0 l,(dcntl)
	 ld a,CWAITROM+CWAITIO
	 out0 (dcntl),a
	 ld a,($crom)
	 cp c$rom
	 ld a,ROM_EN
	 out (000h),a
	endif

	jp bpddtz

?comcod:
	if ROMSYS
	 out (000h),a		;0692 feb2
	 pop af
	endif

	if CPU_Z180
	out0 (cbar),h
	out0 (bbr),l
	pop hl
	else
	 call selbnk
	 pop af
	endif
?exeit:
	ds ?lcmax+2
	push af
	if CPU_Z180
	ld a,SYS$CBAR
	out0 (cbar),a

;;;	 TODO: bbr?
	else
	 xor a
	 call selbnk
	endif
	if ROMSYS
	 ld a,ROM_EN
	 out (000h),a
	endif

	pop af
	ret

topcodend:
curph	defl	$
	.dephase
sysrame:

	end