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
|
info
prefix z80_
opcode_size 8
extra_tables cb ed dded fded ddcb fdcb dd fd
body z80_run_op
sync_cycle z80_sync_cycle
interrupt z80_interrupt
include z80_util.c
header z80.h
declare
void init_z80_opts(z80_options * options, memmap_chunk const * chunks, uint32_t num_chunks, memmap_chunk const * io_chunks, uint32_t num_io_chunks, uint32_t clock_divider, uint32_t io_address_mask);
z80_context * init_z80_context(z80_options *options);
void z80_run(z80_context *context, uint32_t target_cycle);
void z80_assert_reset(z80_context * context, uint32_t cycle);
void z80_clear_reset(z80_context * context, uint32_t cycle);
void z80_assert_busreq(z80_context * context, uint32_t cycle);
void z80_clear_busreq(z80_context * context, uint32_t cycle);
void z80_assert_nmi(z80_context *context, uint32_t cycle);
uint8_t z80_get_busack(z80_context * context, uint32_t cycle);
void z80_invalidate_code_range(z80_context *context, uint32_t start, uint32_t end);
void z80_adjust_cycles(z80_context * context, uint32_t deduction);
void z80_serialize(z80_context *context, serialize_buffer *buf);
void z80_deserialize(deserialize_buffer *buf, void *vcontext);
void zinsert_breakpoint(z80_context * context, uint16_t address, uint8_t * bp_handler);
void zremove_breakpoint(z80_context * context, uint16_t address);
void z80_options_free(z80_options *opts);
void z80_sync_cycle(z80_context *context, uint32_t target_cycle);
regs
main 8 b c d e h l f a
alt 8 b' c' d' e' h' l' f' a'
i 8
r 8
rhigh 8
iff1 8
iff2 8
imode 8
sp 16
ix 16
iy 16
pc 16
wz 16
nflag 8
last_flag_result 8
pvflag 8
chflags 8
zflag 8
scratch1 16
scratch2 16
busreq 8
busack 8
reset 8
io_map ptrmemmap_chunk
io_chunks 32
io_mask 32
int_cycle 32
int_end_cycle 32
int_value 8
nmi_cycle 32
system ptrvoid
fastread ptr8 64
fastwrite ptr8 64
mem_pointers ptr8 4
flags
register f
S 7 sign last_flag_result.7
Z 6 zero zflag
Y 5 bit-5 last_flag_result.5
H 4 half-carry chflags.3
P 2 parity pvflag
V 2 overflow pvflag
X 3 bit-3 last_flag_result.3
N 1 none nflag
C 0 carry chflags.7
z80_op_fetch
cycles 1
add 1 r r
mov pc scratch1
ocall read_8
add 1 pc pc
z80_run_op
#printf "Z80: %X @ %d\n" pc cycles
#printf "Z80: %X - A: %X, B: %X, C: %X D: %X, E: %X, H: %X, L: %X, SP: %X, IX: %X, IY: %X @ %d\n" pc a b c d e h l sp ix iy cycles
z80_op_fetch
dispatch scratch1
z80_interrupt
cmp int_cycle cycles
if >=U
mov 0 iff1
mov 0 iff2
cycles 6
update_sync
switch imode
case 0
dispatch int_value
case 1
dispatch 0xFF
case 2
lsl i 8 pc
or int_value pc pc
#CD is call
dispatch 0xCD
end
else
cmp nmi_cycle cycles
if >=U
mov 0xFFFFFFFF nmi_cycle
mov 0 iff1
local pch 8
lsr pc 8 pch
meta high pch
meta low pc
z80_push
mov 0x66 pc
update_sync
end
end
11001011 cb_prefix
z80_op_fetch
dispatch scratch1 cb
11011101 dd_prefix
z80_op_fetch
dispatch scratch1 dd
11101101 ed_prefix
z80_op_fetch
dispatch scratch1 ed
11111101 fd_prefix
z80_op_fetch
dispatch scratch1 fd
dd 11001011 ddcb_prefix
z80_calc_index ix
cycles 2
mov pc scratch1
ocall read_8
add 1 pc pc
dispatch scratch1 ddcb
fd 11001011 fdcb_prefix
z80_calc_index iy
cycles 2
mov pc scratch1
ocall read_8
add 1 pc pc
dispatch scratch1 fdcb
z80_check_cond
arg cond 8
local invert 8
switch cond
case 0
meta istrue invert
lnot zflag invert
case 1
meta istrue zflag
case 2
meta istrue invert
not chflags invert
and 0x80 invert invert
case 3
meta istrue invert
and 0x80 chflags invert
case 4
meta istrue invert
lnot pvflag invert
case 5
meta istrue pvflag
case 6
meta istrue invert
not last_flag_result invert
and 0x80 invert invert
case 7
meta istrue invert
and 0x80 last_flag_result invert
end
z80_fetch_hl
lsl h 8 scratch1
or l scratch1 scratch1
ocall read_8
z80_store_hl
lsl h 8 scratch2
or l scratch2 scratch2
ocall write_8
z80_fetch_immed
mov pc scratch1
ocall read_8
add 1 pc pc
z80_fetch_immed16
mov pc scratch1
ocall read_8
mov scratch1 wz
add 1 pc pc
mov pc scratch1
ocall read_8
add 1 pc pc
lsl scratch1 8 scratch1
or scratch1 wz wz
z80_fetch_immed_reg16
mov pc scratch1
ocall read_8
mov scratch1 low
add 1 pc pc
mov pc scratch1
ocall read_8
mov scratch1 high
add 1 pc pc
z80_fetch_immed_to_reg16
mov pc scratch1
ocall read_8
mov scratch1 reg
add 1 pc pc
mov pc scratch1
ocall read_8
add 1 pc pc
lsl scratch1 8 scratch1
or scratch1 reg reg
01RRR110 ld_from_hl
z80_fetch_hl
mov scratch1 main.R
01DDDSSS ld_from_reg
mov main.S main.D
dd 01DDD100 ld_from_ixh
invalid D 6
lsr ix 8 main.D
dd 01100SSS ld_to_ixh
invalid S 6
local tmp 16
and 0xFF ix ix
lsl main.S 8 tmp
or tmp ix ix
dd 0110D10S ld_ixb_to_ixb
dd 01DDD101 ld_from_ixl
invalid D 6
mov ix main.D
dd 01101SSS ld_to_ixl
invalid S 6
and 0xFF00 ix ix
or main.S ix ix
dd 01100101 ld_ixl_to_ixh
local tmp 16
lsl ix 8 tmp
and 0xFF ix ix
or tmp ix ix
dd 01101100 ld_ixh_to_ixl
local tmp 16
lsr ix 8 tmp
and 0xFF00 ix ix
or tmp ix ix
fd 01DDD100 ld_from_iyh
invalid D 6
lsr iy 8 main.D
fd 01100SSS ld_to_iyh
invalid S 6
local tmp 16
and 0xFF iy iy
lsl main.S 8 tmp
or tmp iy iy
fd 0110D10S ld_iyb_to_iyb
fd 01DDD101 ld_from_iyl
invalid D 6
mov iy main.D
fd 01101SSS ld_to_iyl
invalid S 6
and 0xFF00 iy iy
or main.S iy iy
fd 01100101 ld_iyl_to_iyh
local tmp 16
lsl iy 8 tmp
and 0xFF iy iy
or tmp iy iy
fd 01101100 ld_iyh_to_iyl
local tmp 16
lsr iy 8 tmp
and 0xFF00 iy iy
or tmp iy iy
z80_calc_index
arg index 16
mov index wz
z80_fetch_immed
sext 16 scratch1 scratch1
add scratch1 wz wz
z80_fetch_index
arg index 16
z80_calc_index index
mov wz scratch1
cycles 5
ocall read_8
z80_store_index
mov wz scratch2
ocall write_8
dd 01RRR110 ld_from_ix
z80_fetch_index ix
mov scratch1 main.R
fd 01RRR110 ld_from_iy
z80_fetch_index iy
mov scratch1 main.R
00RRR110 ld_immed
z80_fetch_immed
mov scratch1 main.R
dd 00100110 ld_immed_ixh
z80_fetch_immed
lsl scratch1 8 scratch1
and 0xFF ix ix
or scratch1 ix ix
dd 00101110 ld_immed_ixl
z80_fetch_immed
and 0xFF00 ix ix
or scratch1 ix ix
fd 00100110 ld_immed_iyh
z80_fetch_immed
lsl scratch1 8 scratch1
and 0xFF iy iy
or scratch1 iy iy
fd 00101110 ld_immed_iyl
z80_fetch_immed
and 0xFF00 iy iy
or scratch1 iy iy
01110RRR ld_to_hl
mov main.R scratch1
z80_store_hl
dd 01110RRR ld_to_ix
z80_calc_index ix
mov wz scratch2
mov main.R scratch1
cycles 5
ocall write_8
fd 01110RRR ld_to_iy
z80_calc_index iy
mov wz scratch2
mov main.R scratch1
cycles 5
ocall write_8
00110110 ld_to_hl_immed
z80_fetch_immed
z80_store_hl
dd 00110110 ld_to_ixd_immed
z80_calc_index ix
z80_fetch_immed
cycles 2
mov wz scratch2
ocall write_8
fd 00110110 ld_to_iyd_immed
z80_calc_index iy
z80_fetch_immed
cycles 2
mov wz scratch2
ocall write_8
00001010 ld_a_from_bc
lsl b 8 wz
or c wz wz
mov wz scratch1
add 1 wz wz
ocall read_8
mov scratch1 a
00011010 ld_a_from_de
lsl d 8 wz
or e wz wz
mov wz scratch1
add 1 wz wz
ocall read_8
mov scratch1 a
00111010 ld_a_from_immed
z80_fetch_immed16
mov wz scratch1
add 1 wz wz
ocall read_8
mov scratch1 a
00000010 ld_a_to_bc
local tmp 8
lsl b 8 scratch2
or c scratch2 scratch2
mov a scratch1
add c 1 tmp
lsl a 8 wz
or tmp wz wz
ocall write_8
00010010 ld_a_to_de
local tmp 8
lsl d 8 scratch2
or e scratch2 scratch2
mov a scratch1
add e 1 tmp
lsl a 8 wz
or tmp wz wz
ocall write_8
00110010 ld_a_to_immed
local tmp 16
z80_fetch_immed16
mov wz scratch2
mov a scratch1
add 1 wz wz
ocall write_8
and 0xFF wz wz
lsl a 8 tmp
or tmp wz wz
ed 01000111 ld_i_a
mov a i
cycles 1
ed 01001111 ld_r_a
mov a r
and 0x80 a rhigh
cycles 1
ed 01011111 ld_a_r
cycles 1
and 0x7F r a
or rhigh a a
update_flags SZYH0XN0
mov iff2 pvflag
ed 01010111 ld_a_i
cycles 1
mov i a
update_flags SZYH0XN0
mov iff2 pvflag
00000001 ld_bc_immed
meta high b
meta low c
z80_fetch_immed_reg16
00010001 ld_de_immed
meta high d
meta low e
z80_fetch_immed_reg16
00100001 ld_hl_immed
meta high h
meta low l
z80_fetch_immed_reg16
00110001 ld_sp_immed
meta reg sp
z80_fetch_immed_to_reg16
dd 00100001 ld_ix_immed
meta reg ix
z80_fetch_immed_to_reg16
fd 00100001 ld_iy_immed
meta reg iy
z80_fetch_immed_to_reg16
z80_fetch16_from_immed
z80_fetch_immed16
mov wz scratch1
ocall read_8
mov scratch1 low
add 1 wz wz
mov wz scratch1
ocall read_8
mov scratch1 high
add 1 wz wz
00101010 ld_hl_from_immed
meta low l
meta high h
z80_fetch16_from_immed
ed 01001011 ld_bc_from_immed
meta low c
meta high b
z80_fetch16_from_immed
ed 01011011 ld_de_from_immed
meta low e
meta high d
z80_fetch16_from_immed
ed 01101011 ld_hl_from_immed_slow
meta low l
meta high h
z80_fetch16_from_immed
z80_fetch_reg16_from_immed
z80_fetch_immed16
mov wz scratch1
ocall read_8
mov scratch1 reg
add 1 wz wz
mov wz scratch1
ocall read_8
lsl scratch1 8 scratch1
or scratch1 reg reg
add 1 wz wz
ed 01111011 ld_sp_from_immed
meta reg sp
z80_fetch_reg16_from_immed
dd 00101010 ld_ix_from_immed
meta reg ix
z80_fetch_reg16_from_immed
fd 00101010 ld_iy_from_immed
meta reg iy
z80_fetch_reg16_from_immed
00100010 ld_hl_to_immed
z80_fetch_immed16
mov wz scratch2
mov l scratch1
ocall write_8
add 1 wz wz
mov wz scratch2
mov h scratch1
ocall write_8
add 1 wz wz
dd 00100010 ld_ix_to_immed
z80_fetch_immed16
mov wz scratch2
mov ix scratch1
ocall write_8
add 1 wz wz
mov wz scratch2
lsr ix 8 scratch1
ocall write_8
add 1 wz wz
fd 00100010 ld_iy_to_immed
z80_fetch_immed16
mov wz scratch2
mov iy scratch1
ocall write_8
add 1 wz wz
mov wz scratch2
lsr iy 8 scratch1
ocall write_8
add 1 wz wz
z80_regpair_to_immed
z80_fetch_immed16
mov wz scratch2
mov low scratch1
ocall write_8
add 1 wz wz
mov high scratch1
mov wz scratch2
ocall write_8
add 1 wz wz
ed 01000011 ld_bc_to_immed
meta low c
meta high b
z80_regpair_to_immed
ed 01010011 ld_de_to_immed
meta low e
meta high d
z80_regpair_to_immed
ed 01100011 ld_hl_to_immed_slow
meta low l
meta high h
z80_regpair_to_immed
ed 01110011 ld_sp_to_immed
meta low sp
local sph 8
lsr sp 8 sph
meta high sph
z80_regpair_to_immed
11111001 ld_sp_hl
cycles 2
lsl h 8 sp
or l sp sp
dd 11111001 ld_sp_ix
cycles 2
mov ix sp
fd 11111001 ld_sp_iy
cycles 2
mov iy sp
z80_push
cycles 1
sub 1 sp sp
mov sp scratch2
mov high scratch1
ocall write_8
sub 1 sp sp
mov sp scratch2
mov low scratch1
ocall write_8
11000101 push_bc
meta high b
meta low c
z80_push
11010101 push_de
meta high d
meta low e
z80_push
11100101 push_hl
meta high h
meta low l
z80_push
11110101 push_af
meta high a
meta low f
z80_push
dd 11100101 push_ix
local ixh 8
lsr ix 8 ixh
meta high ixh
meta low ix
z80_push
fd 11100101 push_iy
local iyh 8
lsr iy 8 iyh
meta high iyh
meta low iy
z80_push
z80_pop
mov sp scratch1
ocall read_8
add 1 sp sp
mov scratch1 low
mov sp scratch1
ocall read_8
add 1 sp sp
mov scratch1 high
11000001 pop_bc
meta high b
meta low c
z80_pop
11010001 pop_de
meta high d
meta low e
z80_pop
11100001 pop_hl
meta high h
meta low l
z80_pop
11110001 pop_af
meta high a
meta low f
z80_pop
dd 11100001 pop_ix
local ixh 16
meta high ixh
meta low ix
z80_pop
lsl ixh 8 ixh
or ixh ix ix
fd 11100001 pop_iy
local iyh 16
meta high iyh
meta low iy
z80_pop
lsl iyh 8 iyh
or iyh iy iy
11101011 ex_de_hl
xchg e l
xchg d h
00001000 ex_af_af
xchg a a'
xchg f f'
11011001 exx
xchg b b'
xchg c c'
xchg d d'
xchg e e'
xchg h h'
xchg l l'
11100011 ex_sp_hl
mov sp scratch1
ocall read_8
xchg l scratch1
cycles 1
mov sp scratch2
ocall write_8
add 1 sp scratch1
ocall read_8
xchg h scratch1
cycles 2
add 1 sp scratch2
ocall write_8
lsl h 8 wz
or l wz wz
dd 11100011 ex_sp_ix
mov sp scratch1
ocall read_8
mov scratch1 wz
mov ix scratch1
cycles 1
mov sp scratch2
ocall write_8
add 1 sp scratch1
ocall read_8
lsl scratch1 8 scratch1
or scratch1 wz wz
lsr ix 8 scratch1
cycles 2
add 1 sp scratch2
ocall write_8
mov wz ix
fd 11100011 ex_sp_iy
mov sp scratch1
ocall read_8
mov scratch1 wz
mov iy scratch1
cycles 1
mov sp scratch2
ocall write_8
add 1 sp scratch1
ocall read_8
lsl scratch1 8 scratch1
or scratch1 wz wz
lsr iy 8 scratch1
cycles 2
add 1 sp scratch2
ocall write_8
mov wz iy
10000RRR add_reg
add a main.R a
update_flags SZYHVXN0C
dd 10000100 add_ixh
lsr ix 8 scratch1
add a scratch1 a
update_flags SZYHVXN0C
dd 10000101 add_ixl
and ix 0xFF scratch1
add a scratch1 a
update_flags SZYHVXN0C
fd 10000100 add_iyh
lsr iy 8 scratch1
add a scratch1 a
update_flags SZYHVXN0C
fd 10000101 add_iyl
and iy 0xFF scratch1
add a scratch1 a
update_flags SZYHVXN0C
10000110 add_hl
z80_fetch_hl
add a scratch1 a
update_flags SZYHVXN0C
dd 10000110 add_ixd
z80_fetch_index ix
add a scratch1 a
update_flags SZYHVXN0C
fd 10000110 add_iyd
z80_fetch_index iy
add a scratch1 a
update_flags SZYHVXN0C
11000110 add_immed
z80_fetch_immed
add a scratch1 a
update_flags SZYHVXN0C
z80_add16_hl
arg src 16
lsl h 8 hlt
or l hlt hlt
add 1 hlt wz
add src hlt hlt
update_flags YHXN0C
mov hlt l
lsr hlt 8 h
cycles 7
00001001 add_hl_bc
local hlw 16
local bcw 16
meta hlt hlw
lsl b 8 bcw
or c bcw bcw
z80_add16_hl bcw
00011001 add_hl_de
local hlw 16
local dew 16
meta hlt hlw
lsl d 8 dew
or e dew dew
z80_add16_hl dew
00101001 add_hl_hl
local hlw 16
meta hlt hlw
z80_add16_hl hlw
00111001 add_hl_sp
local hlw 16
meta hlt hlw
z80_add16_hl sp
dd 00001001 add_ix_bc
lsl b 8 scratch1
or c scratch1 scratch1
add scratch1 ix ix
update_flags YHXN0C
cycles 7
dd 00011001 add_ix_de
lsl d 8 scratch1
or e scratch1 scratch1
add scratch1 ix ix
update_flags YHXN0C
cycles 7
dd 00101001 add_ix_ix
add ix ix ix
update_flags YHXN0C
cycles 7
dd 00111001 add_ix_sp
add sp ix ix
update_flags YHXN0C
cycles 7
fd 00001001 add_iy_bc
lsl b 8 scratch1
or c scratch1 scratch1
add scratch1 iy iy
update_flags YHXN0C
cycles 7
fd 00011001 add_iy_de
lsl d 8 scratch1
or e scratch1 scratch1
add scratch1 iy iy
update_flags YHXN0C
cycles 7
fd 00101001 add_iy_iy
add iy iy iy
update_flags YHXN0C
cycles 7
fd 00111001 add_iy_sp
add sp iy iy
update_flags YHXN0C
cycles 7
10001RRR adc_reg
adc a main.R a
update_flags SZYHVXN0C
dd 10001100 adc_ixh
lsr ix 8 scratch1
adc a scratch1 a
update_flags SZYHVXN0C
dd 10001101 adc_ixl
and ix 0xFF scratch1
adc a scratch1 a
update_flags SZYHVXN0C
fd 10001100 adc_iyh
lsr iy 8 scratch1
adc a scratch1 a
update_flags SZYHVXN0C
fd 10001101 adc_iyl
and iy 0xFF scratch1
adc a scratch1 a
update_flags SZYHVXN0C
10001110 adc_hl
z80_fetch_hl
adc a scratch1 a
update_flags SZYHVXN0C
dd 10001110 adc_ixd
z80_fetch_index ix
adc a scratch1 a
update_flags SZYHVXN0C
fd 10001110 adc_iyd
z80_fetch_index iy
adc a scratch1 a
update_flags SZYHVXN0C
11001110 adc_immed
z80_fetch_immed
adc a scratch1 a
update_flags SZYHVXN0C
z80_adc16_hl
arg src 16
lsl h 8 hlt
or l hlt hlt
add 1 hlt wz
adc src hlt hlt
update_flags SZYHVXN0C
mov hlt l
lsr hlt 8 h
cycles 7
ed 01001010 adc_hl_bc
local hlw 16
local bcw 16
meta hlt hlw
lsl b 8 bcw
or c bcw bcw
z80_adc16_hl bcw
ed 01011010 adc_hl_de
local hlw 16
local dew 16
meta hlt hlw
lsl d 8 dew
or e dew dew
z80_adc16_hl dew
ed 01101010 adc_hl_hl
local hlw 16
meta hlt hlw
z80_adc16_hl hlw
ed 01111010 adc_hl_sp
local hlw 16
meta hlt hlw
z80_adc16_hl sp
10010RRR sub_reg
sub main.R a a
update_flags SZYHVXN1C
dd 10010100 sub_ixh
lsr ix 8 scratch1
sub scratch1 a a
update_flags SZYHVXN1C
dd 10010101 sub_ixl
and ix 0xFF scratch1
sub scratch1 a a
update_flags SZYHVXN1C
fd 10010100 sub_iyh
lsr iy 8 scratch1
sub scratch1 a a
update_flags SZYHVXN1C
fd 10010101 sub_iyl
and iy 0xFF scratch1
sub scratch1 a a
update_flags SZYHVXN1C
10010110 sub_hl
z80_fetch_hl
sub scratch1 a a
update_flags SZYHVXN1C
dd 10010110 sub_ixd
z80_fetch_index ix
sub scratch1 a a
update_flags SZYHVXN1C
fd 10010110 sub_iyd
z80_fetch_index iy
sub scratch1 a a
update_flags SZYHVXN1C
11010110 sub_immed
z80_fetch_immed
sub scratch1 a a
update_flags SZYHVXN1C
10011RRR sbc_reg
sbc main.R a a
update_flags SZYHVXN1C
dd 10011100 sbc_ixh
lsr ix 8 scratch1
sbc scratch1 a a
update_flags SZYHVXN1C
dd 10011101 sbc_ixl
and ix 0xFF scratch1
sbc scratch1 a a
update_flags SZYHVXN1C
fd 10011100 sbc_iyh
lsr iy 8 scratch1
sbc scratch1 a a
update_flags SZYHVXN1C
fd 10011101 sbc_iyl
and iy 0xFF scratch1
sbc scratch1 a a
update_flags SZYHVXN1C
10011110 sbc_hl
z80_fetch_hl
sbc scratch1 a a
update_flags SZYHVXN1C
dd 10011110 sbc_ixd
z80_fetch_index ix
sbc scratch1 a a
update_flags SZYHVXN1C
fd 10011110 sbc_iyd
z80_fetch_index iy
sbc scratch1 a a
update_flags SZYHVXN1C
11011110 sbc_immed
z80_fetch_immed
sbc scratch1 a a
update_flags SZYHVXN1C
z80_sbc16_hl
arg src 16
lsl h 8 hlt
or l hlt hlt
add 1 hlt wz
sbc src hlt hlt
update_flags SZYHVXN1C
mov hlt l
lsr hlt 8 h
cycles 7
ed 01000010 sbc_hl_bc
local hlw 16
local bcw 16
meta hlt hlw
lsl b 8 bcw
or c bcw bcw
z80_sbc16_hl bcw
ed 01010010 sbc_hl_de
local hlw 16
local dew 16
meta hlt hlw
lsl d 8 dew
or e dew dew
z80_sbc16_hl dew
ed 01100010 sbc_hl_hl
local hlw 16
meta hlt hlw
z80_sbc16_hl hlw
ed 01110010 sbc_hl_sp
local hlw 16
meta hlt hlw
z80_sbc16_hl sp
10100RRR and_reg
and a main.R a
update_flags SZYH1PXN0C0
dd 10100100 and_ixh
lsr ix 8 scratch1
and scratch1 a a
update_flags SZYH1PXN0C0
dd 10100101 and_ixl
and ix a a
update_flags SZYH1PXN0C0
fd 10100100 and_iyh
lsr iy 8 scratch1
and scratch1 a a
update_flags SZYH1PXN0C0
fd 10100101 and_iyl
and iy a a
update_flags SZYH1PXN0C0
10100110 and_hl
z80_fetch_hl
and a scratch1 a
update_flags SZYH1PXN0C0
dd 10100110 and_ixd
z80_fetch_index ix
and a scratch1 a
update_flags SZYH1PXN0C0
fd 10100110 and_iyd
z80_fetch_index iy
and a scratch1 a
update_flags SZYH1PXN0C0
11100110 and_immed
z80_fetch_immed
and a scratch1 a
update_flags SZYH1PXN0C0
10110RRR or_reg
or a main.R a
update_flags SZYH0PXN0C0
dd 10110100 or_ixh
lsr ix 8 scratch1
or scratch1 a a
update_flags SZYH0PXN0C0
dd 10110101 or_ixl
or ix a a
update_flags SZYH0PXN0C0
fd 10110100 or_iyh
lsr iy 8 scratch1
or scratch1 a a
update_flags SZYH0PXN0C0
fd 10110101 or_iyl
or iy a a
update_flags SZYH0PXN0C0
10110110 or_hl
z80_fetch_hl
or a scratch1 a
update_flags SZYH0PXN0C0
dd 10110110 or_ixd
z80_fetch_index ix
or a scratch1 a
update_flags SZYH0PXN0C0
fd 10110110 or_iyd
z80_fetch_index iy
or a scratch1 a
update_flags SZYH0PXN0C0
11110110 or_immed
z80_fetch_immed
or a scratch1 a
update_flags SZYH0PXN0C0
10101RRR xor_reg
xor a main.R a
update_flags SZYH0PXN0C0
dd 10101100 xor_ixh
lsr ix 8 scratch1
xor scratch1 a a
update_flags SZYH0PXN0C0
dd 10101101 xor_ixl
xor ix a a
update_flags SZYH0PXN0C0
fd 10101100 xor_iyh
lsr iy 8 scratch1
xor scratch1 a a
update_flags SZYH0PXN0C0
fd 10101101 xor_iyl
xor iy a a
update_flags SZYH0PXN0C0
10101110 xor_hl
z80_fetch_hl
xor a scratch1 a
update_flags SZYH0PXN0C0
dd 10101110 xor_ixd
z80_fetch_index ix
xor a scratch1 a
update_flags SZYH0PXN0C0
fd 10101110 xor_iyd
z80_fetch_index iy
xor a scratch1 a
update_flags SZYH0PXN0C0
11101110 xor_immed
z80_fetch_immed
xor a scratch1 a
update_flags SZYH0PXN0C0
10111RRR cp_reg
mov main.R last_flag_result
cmp main.R a
update_flags SZHVN1C
dd 10111100 cp_ixh
local tmp 8
lsr ix 8 tmp
mov tmp last_flag_result
cmp tmp a
update_flags SZHVN1C
dd 10111101 cp_ixl
local tmp 8
mov ix tmp
mov ix last_flag_result
cmp tmp a
update_flags SZHVN1C
fd 10111100 cp_iyh
local tmp 8
lsr iy 8 tmp
mov tmp last_flag_result
cmp tmp a
update_flags SZHVN1C
fd 10111101 cp_iyl
local tmp 8
mov iy tmp
mov iy last_flag_result
cmp tmp a
update_flags SZHVN1C
10111110 cp_hl
local tmp 8
z80_fetch_hl
mov scratch1 tmp
mov scratch1 last_flag_result
cmp tmp a
update_flags SZHVN1C
dd 10111110 cp_ixd
local tmp 8
z80_fetch_index ix
mov scratch1 tmp
mov scratch1 last_flag_result
cmp tmp a
update_flags SZHVN1C
fd 10111110 cp_iyd
local tmp 8
z80_fetch_index iy
mov scratch1 tmp
mov scratch1 last_flag_result
cmp tmp a
update_flags SZHVN1C
11111110 cp_immed
local tmp 8
z80_fetch_immed
mov scratch1 tmp
mov scratch1 last_flag_result
cmp tmp a
update_flags SZHVN1C
00RRR100 inc_reg
add 1 main.R main.R
update_flags SZYHVXN0
dd 00100100 inc_ixh
add 0x100 ix ix
update_flags SZYHVXN0
dd 00101100 inc_ixl
local tmp 8
mov ix tmp
add 1 tmp tmp
update_flags SZYHVXN0
and 0xFF00 ix ix
or tmp ix ix
fd 00100100 inc_iyh
add 0x100 iy iy
update_flags SZYHVXN0
fd 00101100 inc_iyl
local tmp 8
mov iy tmp
add 1 tmp tmp
update_flags SZYHVXN0
and 0xFF00 iy iy
or tmp iy iy
00110100 inc_hl
local tmp 8
z80_fetch_hl
#TODO: Either make DSL compiler smart enough to optimize these unnecessary moves out
#or add some syntax to force a certain size on an operation so they are unnecessary
mov scratch1 tmp
add 1 tmp tmp
update_flags SZYHVXN0
mov tmp scratch1
cycles 1
z80_store_hl
dd 00110100 inc_ixd
local tmp 8
z80_fetch_index ix
#TODO: Either make DSL compiler smart enough to optimize these unnecessary moves out
#or add some syntax to force a certain size on an operation so they are unnecessary
mov scratch1 tmp
add 1 tmp tmp
update_flags SZYHVXN0
mov tmp scratch1
cycles 1
z80_store_index
fd 00110100 inc_iyd
local tmp 8
z80_fetch_index iy
#TODO: Either make DSL compiler smart enough to optimize these unnecessary moves out
#or add some syntax to force a certain size on an operation so they are unnecessary
mov scratch1 tmp
add 1 tmp tmp
update_flags SZYHVXN0
mov tmp scratch1
cycles 1
z80_store_index
z80_inc_pair
arg high 8
arg low 8
cycles 2
local word 16
lsl high 8 word
or low word word
add 1 word word
mov word low
lsr word 8 high
00000011 inc_bc
z80_inc_pair b c
00010011 inc_de
z80_inc_pair d e
00100011 inc16_hl
z80_inc_pair h l
00110011 inc_sp
add 1 sp sp
dd 00100011 inc_ix
add 1 ix ix
fd 00100011 inc_iy
add 1 iy iy
00RRR101 dec_reg
sub 1 main.R main.R
update_flags SZYHVXN1
dd 00100101 dec_ixh
sub 0x100 ix ix
update_flags SZYHVXN1
dd 00101101 dec_ixl
local tmp 8
mov ix tmp
sub 1 tmp tmp
update_flags SZYHVXN1
and 0xFF00 ix ix
or tmp ix ix
fd 00100101 dec_iyh
sub 0x100 iy iy
update_flags SZYHVXN1
fd 00101101 dec_iyl
local tmp 8
mov iy tmp
sub 1 tmp tmp
update_flags SZYHVXN1
and 0xFF00 iy iy
or tmp iy iy
00110101 dec_hl
local tmp 8
z80_fetch_hl
#TODO: Either make DSL compiler smart enough to optimize these unnecessary moves out
#or add some syntax to force a certain size on an operation so they are unnecessary
mov scratch1 tmp
sub 1 tmp tmp
update_flags SZYHVXN1
mov tmp scratch1
cycles 1
z80_store_hl
dd 00110101 dec_ixd
local tmp 8
z80_fetch_index ix
#TODO: Either make DSL compiler smart enough to optimize these unnecessary moves out
#or add some syntax to force a certain size on an operation so they are unnecessary
mov scratch1 tmp
sub 1 tmp tmp
update_flags SZYHVXN1
mov tmp scratch1
cycles 1
z80_store_index
fd 00110101 dec_iyd
local tmp 8
z80_fetch_index iy
#TODO: Either make DSL compiler smart enough to optimize these unnecessary moves out
#or add some syntax to force a certain size on an operation so they are unnecessary
mov scratch1 tmp
sub 1 tmp tmp
update_flags SZYHVXN1
mov tmp scratch1
cycles 1
z80_store_index
z80_dec_pair
arg high 8
arg low 8
local word 16
lsl high 8 word
or low word word
sub 1 word word
mov word low
lsr word 8 high
cycles 2
00001011 dec_bc
z80_dec_pair b c
00011011 dec_de
z80_dec_pair d e
00101011 dec16_hl
z80_dec_pair h l
00111011 dec_sp
sub 1 sp sp
dd 00101011 dec_ix
sub 1 ix ix
fd 00101011 dec_iy
sub 1 iy iy
00101111 cpl
not a a
update_flags YH1XN1
ed 01DDD100 neg
neg a a
update_flags SZYHVXN1C
00111111 ccf
local tmp 8
and 0x80 last_flag_result last_flag_result
and 0x7F a tmp
or tmp last_flag_result last_flag_result
and 0x80 chflags chflags
lsr chflags 4 tmp
or tmp chflags chflags
xor 0x80 chflags chflags
update_flags N0
00110111 scf
local tmp 8
and 0x80 last_flag_result last_flag_result
and 0x7F a tmp
or tmp last_flag_result last_flag_result
update_flags H0N0C1
00000000 nop
01110110 halt
cmp nmi_cycle cycles
if >=U
else
cmp int_cycle cycles
if >=U
if iff1
else
sub 1 pc pc
end
else
sub 1 pc pc
end
end
11110011 di
mov 0 iff1
mov 0 iff2
update_sync
11111011 ei
mov 1 iff1
mov 1 iff2
update_sync
cmp int_cycle cycles
if >=U
add 1 cycles int_cycle
end
ed 01D00110 im0
mov 0 imode
ed 01D10110 im1
mov 1 imode
ed 01D11110 im2
mov 2 imode
ed 01D01110 im3
#some sources call this mode 0/1, but unclear
#if the behavior is really different from im 0
mov 0 imode
11000011 jp
z80_fetch_immed16
mov wz pc
11101001 jp_hl
lsl h 8 pc
or l pc pc
dd 11101001 jp_ix
mov ix pc
fd 11101001 jp_iy
mov iy pc
11CCC010 jp_cc
z80_check_cond C
z80_fetch_immed16
if istrue
mov wz pc
end
00011000 jr
z80_fetch_immed
#TODO: determine if this updates wz
sext 16 scratch1 scratch1
add scratch1 pc pc
cycles 5
001CC000 jr_cc
z80_check_cond C
z80_fetch_immed
if istrue
sext 16 scratch1 scratch1
add scratch1 pc pc
cycles 5
end
00010000 djnz
cycles 1
z80_fetch_immed
sub 1 b b
if b
sext 16 scratch1 scratch1
add scratch1 pc pc
cycles 5
end
11001101 call_uncond
z80_fetch_immed16
local pch 8
lsr pc 8 pch
meta high pch
meta low pc
z80_push
mov wz pc
11CCC100 call_cond
local pch 8
z80_fetch_immed16
z80_check_cond C
if istrue
lsr pc 8 pch
meta high pch
meta low pc
z80_push
mov wz pc
end
11TTT111 rst
local pch 8
lsr pc 8 pch
meta high pch
meta low pc
z80_push
lsl T 3 scratch1
mov scratch1 pc
11001001 ret
local pch 16
meta high pch
meta low pc
z80_pop
lsl pch 8 pch
or pch pc pc
ed 01001101 reti
local pch 16
cycles 1
meta high pch
meta low pc
z80_pop
lsl pch 8 pch
or pch pc pc
ed 01NN1101 retn
mov iff2 iff1
local pch 16
cycles 1
meta high pch
meta low pc
z80_pop
lsl pch 8 pch
or pch pc pc
11CCC000 ret_cond
local pch 16
cycles 1
z80_check_cond C
if istrue
meta high pch
meta low pc
z80_pop
lsl pch 8 pch
or pch pc pc
end
11011011 in_abs
z80_fetch_immed
ocall io_read8
mov scratch1 a
ed 01RRR000 in_bc
lsl b 8 scratch1
or c scratch1 scratch1
ocall io_read8
mov scratch1 main.R
z80_ini_ind
arg change 16
local tmp 8
cycles 1
lsl 8 b wz
or c wz wz
add change wz wz
sub 1 b b
update_flags SZYX
lsl b 8 scratch1
or c scratch1 scratch1
ocall io_read8
and 0x80 scratch1 nflag
mov wz tmp
add tmp scratch1 tmp
update_flags C
z80_store_hl
lsl h 8 scratch2
or l scratch2 scratch2
add change scratch2 scratch2
mov scratch2 l
lsr scratch2 8 h
and 7 tmp tmp
xor b tmp tmp
update_flags P
lsr chflags 4 tmp
or tmp chflags chflags
ed 10100010 ini
z80_ini_ind 1
ed 10110010 inir
z80_ini_ind 1
if zflag
else
sub 2 pc pc
cycles 5
end
ed 10101010 ind
z80_ini_ind -1
ed 10111010 indr
z80_ini_ind -1
if zflag
else
sub 2 pc pc
cycles 5
end
11010011 out_abs
z80_fetch_immed
mov scratch1 scratch2
mov a scratch1
ocall io_write8
ed 01RRR001 out_bc
lsl b 8 scratch2
or c scratch2 scratch2
mov main.R scratch1
ocall io_write8
z80_outi_outd
arg change 16
local tmp 8
cycles 1
z80_fetch_hl
and 0x80 scratch1 nflag
lsl h 8 scratch2
or l scratch2 scratch2
add change scratch2 scratch2
mov scratch2 l
lsr scratch2 8 h
add l scratch1 tmp
update_flags C
and 7 tmp tmp
lsl b 8 scratch2
or c scratch2 scratch2
ocall io_write8
sub 1 b b
update_flags SZYX
lsl 8 b wz
or c wz wz
add change wz wz
xor b tmp tmp
update_flags P
lsr chflags 4 tmp
or tmp chflags chflags
ed 10100011 outi
z80_outi_outd 1
ed 10110011 otir
z80_outi_outd 1
if zflag
else
sub 2 pc pc
cycles 5
end
ed 10101011 outd
z80_outi_outd -1
ed 10111011 otdr
z80_outi_outd -1
if zflag
else
sub 2 pc pc
cycles 5
end
00000111 rlca
rol a 1 a
update_flags YH0XN0C
00010111 rla
rlc a 1 a
update_flags YH0XN0C
00001111 rrca
ror a 1 a
update_flags YH0XN0C
00011111 rra
rrc a 1 a
update_flags YH0XN0C
cb 00000RRR rlc
rol main.R 1 main.R
update_flags SZYH0PXN0C
cb 00000110 rlc_hl
local tmp 8
z80_fetch_hl
mov scratch1 tmp
rol tmp 1 tmp
update_flags SZYH0PXN0C
mov tmp scratch1
z80_store_hl
z80_rlc_index
arg tmp 8
mov wz scratch1
ocall read_8
cycles 1
mov scratch1 tmp
rol tmp 1 tmp
update_flags SZYH0PXN0C
mov tmp scratch1
z80_store_index
ddcb 00000110 rlc_ixd
local tmp 8
z80_rlc_index tmp
ddcb 00000RRR rlc_ixd_reg
z80_rlc_index main.R
fdcb 00000110 rlc_iyd
local tmp 8
z80_rlc_index tmp
fdcb 00000RRR rlc_iyd_reg
z80_rlc_index main.R
cb 00010RRR rl
rlc main.R 1 main.R
update_flags SZYH0PXN0C
cb 00010110 rl_hl
local tmp 8
z80_fetch_hl
mov scratch1 tmp
rlc tmp 1 tmp
update_flags SZYH0PXN0C
mov tmp scratch1
z80_store_hl
z80_rl_index
arg tmp 8
mov wz scratch1
ocall read_8
cycles 1
mov scratch1 tmp
rlc tmp 1 tmp
update_flags SZYH0PXN0C
mov tmp scratch1
z80_store_index
ddcb 00010110 rl_ixd
local tmp 8
z80_rl_index tmp
fdcb 00010110 rl_iyd
local tmp 8
z80_rl_index tmp
ddcb 00010RRR rl_ixd_reg
z80_rl_index main.R
fdcb 00010RRR rl_iyd_reg
z80_rl_index main.R
cb 00001RRR rrc
ror main.R 1 main.R
update_flags SZYH0PXN0C
cb 00001110 rrc_hl
local tmp 8
z80_fetch_hl
mov scratch1 tmp
ror tmp 1 tmp
update_flags SZYH0PXN0C
mov tmp scratch1
z80_store_hl
z80_rrc_index
arg tmp 8
mov wz scratch1
ocall read_8
cycles 1
mov scratch1 tmp
ror tmp 1 tmp
update_flags SZYH0PXN0C
mov tmp scratch1
z80_store_index
ddcb 00001110 rrc_ixd
local tmp 8
z80_rrc_index tmp
ddcb 00001RRR rrc_ixd_reg
z80_rrc_index main.R
fdcb 00001110 rrc_iyd
local tmp 8
z80_rrc_index tmp
fdcb 00001RRR rrc_iyd_reg
z80_rrc_index main.R
cb 00011RRR rr
rrc main.R 1 main.R
update_flags SZYH0PXN0C
cb 00011110 rr_hl
local tmp 8
z80_fetch_hl
mov scratch1 tmp
rrc tmp 1 tmp
update_flags SZYH0PXN0C
mov tmp scratch1
z80_store_hl
z80_rr_index
arg tmp 8
mov wz scratch1
ocall read_8
cycles 1
mov scratch1 tmp
rrc tmp 1 tmp
update_flags SZYH0PXN0C
mov tmp scratch1
z80_store_index
ddcb 00011110 rr_ixd
local tmp 8
z80_rr_index tmp
ddcb 00011RRR rr_ixd_reg
z80_rr_index main.R
fdcb 00011110 rr_iyd
local tmp 8
z80_rr_index tmp
fdcb 00011RRR rr_iyd_reg
z80_rr_index main.R
cb 00100RRR sla
lsl main.R 1 main.R
update_flags SZYH0PXN0C
cb 00100110 sla_hl
local tmp 8
z80_fetch_hl
mov scratch1 tmp
lsl tmp 1 tmp
update_flags SZYH0PXN0C
mov tmp scratch1
z80_store_hl
z80_sla_index
arg tmp 8
mov wz scratch1
ocall read_8
cycles 1
mov scratch1 tmp
lsl tmp 1 tmp
update_flags SZYH0PXN0C
mov tmp scratch1
z80_store_index
ddcb 00100110 sla_ixd
local tmp 8
z80_sla_index tmp
ddcb 00100RRR sla_ixd_reg
z80_sla_index main.R
fdcb 00100110 sla_iyd
local tmp 8
z80_sla_index tmp
fdcb 00100RRR sla_iyd_reg
z80_sla_index main.R
cb 00101RRR sra
asr main.R 1 main.R
update_flags SZYH0PXN0C
cb 00101110 sra_hl
local tmp 8
z80_fetch_hl
mov scratch1 tmp
asr tmp 1 tmp
update_flags SZYH0PXN0C
mov tmp scratch1
z80_store_hl
z80_sra_index
arg tmp 8
mov wz scratch1
ocall read_8
cycles 1
mov scratch1 tmp
asr tmp 1 tmp
update_flags SZYH0PXN0C
mov tmp scratch1
z80_store_index
ddcb 00101110 sra_ixd
local tmp 8
z80_sra_index tmp
ddcb 00101RRR sra_ixd_reg
z80_sra_index main.R
fdcb 00101110 sra_iyd
local tmp 8
z80_sra_index tmp
fdcb 00101RRR sra_iyd_reg
z80_sra_index main.R
cb 00110RRR sll
lsl main.R 1 main.R
update_flags SZ0YH0XN0C
or 1 main.R main.R
update_flags P
cb 00110110 sll_hl
local tmp 8
z80_fetch_hl
mov scratch1 tmp
lsl tmp 1 tmp
update_flags SZ0YH0XN0C
or 1 tmp tmp
update_flags P
mov tmp scratch1
z80_store_hl
z80_sll_index
arg tmp 8
mov wz scratch1
ocall read_8
cycles 1
mov scratch1 tmp
lsl tmp 1 tmp
update_flags SZ0YH0XN0C
or 1 tmp tmp
update_flags P
mov tmp scratch1
z80_store_index
ddcb 00110110 sll_ixd
local tmp 8
z80_sll_index tmp
ddcb 00110RRR sll_ixd_reg
z80_sll_index main.R
fdcb 00110110 sll_iyd
local tmp 8
z80_sll_index tmp
fdcb 00110RRR sll_iyd_reg
z80_sll_index main.R
cb 00111RRR srl
lsr main.R 1 main.R
update_flags SZYH0PXN0C
cb 00111110 srl_hl
local tmp 8
z80_fetch_hl
mov scratch1 tmp
lsr tmp 1 tmp
update_flags SZYH0PXN0C
mov tmp scratch1
z80_store_hl
z80_srl_index
arg tmp 8
mov wz scratch1
ocall read_8
cycles 1
mov scratch1 tmp
lsr tmp 1 tmp
update_flags SZYH0PXN0C
mov tmp scratch1
z80_store_index
ddcb 00111110 srl_ixd
local tmp 8
z80_srl_index tmp
ddcb 00111RRR srl_ixd_reg
z80_srl_index main.R
fdcb 00111110 srl_iyd
local tmp 8
z80_srl_index tmp
fdcb 00111RRR srl_iyd_reg
z80_srl_index main.R
cb 01BBBRRR bit_reg
local tmp 8
lsl 1 B tmp
mov main.R last_flag_result
and main.R tmp tmp
update_flags SZH1PN0
cb 01BBB110 bit_hl
local tmp 8
z80_fetch_hl
cycles 1
lsl 1 B tmp
lsr wz 8 last_flag_result
and scratch1 tmp tmp
update_flags SZH1PN0
ddcb 01BBBRRR bit_ixd
local tmp 8
mov wz scratch1
ocall read_8
cycles 1
lsl 1 B tmp
lsr wz 8 last_flag_result
and scratch1 tmp tmp
update_flags SZH1PN0
fdcb 01BBBRRR bit_iyd
local tmp 8
mov wz scratch1
ocall read_8
cycles 1
lsl 1 B tmp
lsr wz 8 last_flag_result
and scratch1 tmp tmp
update_flags SZH1PN0
cb 10BBBRRR res_reg
local tmp 8
lsl 1 B tmp
not tmp tmp
and main.R tmp main.R
cb 10BBB110 res_hl
z80_fetch_hl
cycles 1
local tmp 8
lsl 1 B tmp
not tmp tmp
and scratch1 tmp scratch1
z80_store_hl
z80_res_index
arg bit 8
arg tmp 8
lsl 1 bit tmp
not tmp tmp
mov wz scratch1
ocall read_8
cycles 1
and scratch1 tmp tmp
mov tmp scratch1
z80_store_index
ddcb 10BBB110 res_ixd
local tmp 8
z80_res_index B tmp
ddcb 10BBBRRR res_ixd_reg
z80_res_index B main.R
fdcb 10BBB110 res_iyd
local tmp 8
z80_res_index B tmp
fdcb 10BBBRRR res_iyd_reg
z80_res_index B main.R
cb 11BBBRRR set_reg
local tmp 8
lsl 1 B tmp
or main.R tmp main.R
cb 11BBB110 set_hl
z80_fetch_hl
cycles 1
local tmp 8
lsl 1 B tmp
or scratch1 tmp scratch1
z80_store_hl
z80_set_index
arg bit 8
arg tmp 8
lsl 1 bit tmp
mov wz scratch1
ocall read_8
cycles 1
or scratch1 tmp tmp
mov tmp scratch1
z80_store_index
ddcb 11BBB110 set_ixd
local tmp 8
z80_set_index B tmp
ddcb 11BBBRRR set_ixd_reg
z80_set_index B main.R
fdcb 11BBB110 set_iyd
local tmp 8
z80_set_index B tmp
fdcb 11BBBRRR set_iyd_reg
z80_set_index B main.R
z80_fetch_mod_hl
local tmp 16
arg change 16
lsl h 8 tmp
or l tmp tmp
mov tmp scratch1
add change tmp tmp
mov tmp l
lsr tmp 8 h
ocall read_8
cycles 2
z80_ldd_ldi
arg change 16
local tmp 16
local tmp8 8
z80_fetch_mod_hl change
add a scratch1 tmp8
update_flags H0XN0
and 0x2 tmp8 tmp8
lsl tmp8 4 tmp8
and 0x88 last_flag_result last_flag_result
or tmp8 last_flag_result last_flag_result
lsl d 8 tmp
or e tmp tmp
mov tmp scratch2
add change tmp tmp
mov tmp e
lsr tmp 8 d
ocall write_8
lsl b 8 tmp
or c tmp tmp
sub 1 tmp tmp
mov tmp c
lsr tmp 8 b
mov c pvflag
or b pvflag pvflag
ed 10100000 ldi
z80_ldd_ldi 1
ed 10101000 ldd
z80_ldd_ldi -1
ed 10110000 ldir
z80_ldd_ldi 1
if pvflag
add 1 pc wz
sub 2 pc pc
cycles 5
end
ed 10111000 lddr
z80_ldd_ldi -1
if pvflag
add 1 pc wz
sub 2 pc pc
cycles 5
end
z80_cpd_cpi
local tmp 16
local tmp8 8
local hf 8
arg change 16
z80_fetch_mod_hl change
sub scratch1 a tmp8
update_flags SZHN1
lsr chflags 3 hf
and 1 hf hf
sub hf tmp8 tmp8
update_flags X
and 0x2 tmp8 tmp8
lsl tmp8 4 tmp8
and 0x88 last_flag_result last_flag_result
or tmp8 last_flag_result last_flag_result
lsl b 8 tmp
or c tmp tmp
sub 1 tmp tmp
mov tmp c
lsr tmp 8 b
mov c pvflag
or b pvflag pvflag
cycles 5
ed 10100001 cpi
z80_cpd_cpi 1
ed 10101001 cpd
z80_cpd_cpi -1
ed 10110001 cpir
z80_cpd_cpi 1
if pvflag
if zflag
else
add 1 pc wz
sub 2 pc pc
cycles 5
end
end
ed 10111001 cpdr
z80_cpd_cpi -1
if pvflag
if zflag
else
add 1 pc wz
sub 2 pc pc
cycles 5
end
end
00100111 daa
local diff 8
local tmp 8
local low 8
and 0xF a low
and 0x8 chflags tmp
if tmp
mov 6 diff
else
cmp 0xA low
if >=U
mov 6 diff
else
mov 0 diff
end
end
and 0x80 chflags tmp
if tmp
or 0x60 diff diff
update_flags C1
else
cmp 0x9A a
if >=U
or 0x60 diff diff
update_flags C1
else
update_flags C0
end
end
if nflag
sub diff a a
update_flags SZYHPX
else
add diff a a
update_flags SZYHPX
end
dd OOOOOOOO dd_normal
dispatch O
fd OOOOOOOO fd_normal
dispatch O
ed 01101111 rld
local tmp 8
local tmp2 8
z80_fetch_hl
cycles 4
lsr scratch1 4 tmp
lsl scratch1 4 scratch1
and 0xF a tmp2
or tmp2 scratch1 scratch1
and 0xF0 a a
or tmp a a
update_flags SZYH0XPN0
z80_store_hl
ed 01100111 rrd
local tmp 8
local tmp2 8
z80_fetch_hl
cycles 4
and 0xF scratch1 tmp
lsr scratch1 4 scratch1
lsl a 4 tmp2
or tmp2 scratch1 scratch1
and 0xF0 a a
or tmp a a
update_flags SZYH0XPN0
z80_store_hl
|