trunk/src/emu/cpu/arcompact/arcompact_execute.c
| r242545 | r242546 | |
| 1179 | 1179 | size = 8; |
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | | arcompact_log("unimplemented %s %08x", optext, op); |
| 1182 | arcompact_log("unimplemented %s %08x (reg-reg)", optext, op); |
| 1183 | 1183 | return m_pc + (size>>0); |
| 1184 | 1184 | } |
| 1185 | 1185 | |
| r242545 | r242546 | |
| 1296 | 1296 | ARCOMPACT_RETTYPE arcompact_device::arcompact_01_01_01_helper(OPS_32, const char* optext) |
| 1297 | 1297 | { |
| 1298 | 1298 | int size = 4; |
| 1299 | | arcompact_log("unimplemented %s %08x", optext, op); |
| 1299 | arcompact_log("unimplemented %s %08x (reg-imm)", optext, op); |
| 1300 | 1300 | return m_pc + (size>>0); |
| 1301 | 1301 | } |
| 1302 | 1302 | |
| r242545 | r242546 | |
| 1657 | 1657 | } |
| 1658 | 1658 | |
| 1659 | 1659 | |
| 1660 | #define SETUP_HANDLE04_0x_P00 \ |
| 1661 | int size = 4; \ |
| 1662 | UINT32 limm = 0; \ |
| 1663 | int got_limm = 0; \ |
| 1664 | \ |
| 1665 | COMMON32_GET_breg; \ |
| 1666 | COMMON32_GET_F; \ |
| 1667 | COMMON32_GET_creg; \ |
| 1668 | COMMON32_GET_areg; \ |
| 1669 | \ |
| 1670 | UINT32 b, c; \ |
| 1671 | \ |
| 1672 | if (breg == LIMM_REG) \ |
| 1673 | { \ |
| 1674 | GET_LIMM_32; \ |
| 1675 | size = 8; \ |
| 1676 | got_limm = 1; \ |
| 1677 | b = limm; \ |
| 1678 | } \ |
| 1679 | else \ |
| 1680 | { \ |
| 1681 | b = m_regs[breg]; \ |
| 1682 | } \ |
| 1683 | \ |
| 1684 | if (creg == LIMM_REG) \ |
| 1685 | { \ |
| 1686 | if (!got_limm) \ |
| 1687 | { \ |
| 1688 | GET_LIMM_32; \ |
| 1689 | size = 8; \ |
| 1690 | } \ |
| 1691 | c = limm; \ |
| 1692 | } \ |
| 1693 | else \ |
| 1694 | { \ |
| 1695 | c = m_regs[creg]; \ |
| 1696 | } \ |
| 1697 | /* todo: is the limm, limm syntax valid? (it's pointless.) */ \ |
| 1698 | /* todo: if areg = LIMM then there is no result (but since that register can never be read, I guess it doesn't matter if we store it there anyway?) */ \ |
| 1699 | |
| 1700 | |
| 1701 | |
| 1660 | 1702 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_00_p00(OPS_32) |
| 1661 | 1703 | { |
| 1704 | SETUP_HANDLE04_0x_P00 |
| 1705 | |
| 1706 | m_regs[areg] = b + c; |
| 1707 | |
| 1708 | if (F) |
| 1709 | { |
| 1710 | arcompact_fatal("arcompact_handle04_00_p00 (ADD) (F set)\n"); // not yet supported |
| 1711 | } |
| 1712 | |
| 1713 | return m_pc + (size >> 0); |
| 1714 | } |
| 1715 | |
| 1716 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_00_p01(OPS_32) |
| 1717 | { |
| 1662 | 1718 | int size = 4; |
| 1663 | 1719 | UINT32 limm = 0; |
| 1664 | | int got_limm = 0; |
| 1720 | // int got_limm = 0; |
| 1665 | 1721 | |
| 1666 | 1722 | COMMON32_GET_breg; |
| 1667 | 1723 | COMMON32_GET_F; |
| 1668 | | COMMON32_GET_creg |
| 1724 | COMMON32_GET_u6 |
| 1669 | 1725 | COMMON32_GET_areg |
| 1670 | 1726 | |
| 1671 | 1727 | UINT32 b, c; |
| 1672 | 1728 | |
| 1729 | // is having b as LIMM valid here? LIMM vs. fixed u6 value makes no sense |
| 1673 | 1730 | if (breg == LIMM_REG) |
| 1674 | 1731 | { |
| 1675 | 1732 | GET_LIMM_32; |
| 1676 | 1733 | size = 8; |
| 1677 | | got_limm = 1; |
| 1734 | // got_limm = 1; |
| 1678 | 1735 | b = limm; |
| 1679 | 1736 | } |
| 1680 | 1737 | else |
| r242545 | r242546 | |
| 1682 | 1739 | b = m_regs[breg]; |
| 1683 | 1740 | } |
| 1684 | 1741 | |
| 1685 | | if (creg == LIMM_REG) |
| 1686 | | { |
| 1687 | | if (!got_limm) |
| 1688 | | { |
| 1689 | | GET_LIMM_32; |
| 1690 | | size = 8; |
| 1691 | | } |
| 1692 | | c = limm; |
| 1693 | | } |
| 1694 | | else |
| 1695 | | { |
| 1696 | | c = m_regs[creg]; |
| 1697 | | } |
| 1742 | c = u; |
| 1698 | 1743 | |
| 1699 | 1744 | // todo: if areg = LIMM then there is no result (but since that register can never be read, I guess it doesn't matter if we store it there anyway?) |
| 1700 | 1745 | m_regs[areg] = b + c; |
| 1701 | 1746 | |
| 1702 | 1747 | if (F) |
| 1703 | 1748 | { |
| 1704 | | arcompact_fatal("arcompact_handle04_00_p00 (ADD) (F set)\n"); // not yet supported |
| 1749 | arcompact_fatal("arcompact_handle04_00_p01 (ADD) (F set)\n"); // not yet supported |
| 1705 | 1750 | } |
| 1706 | 1751 | |
| 1707 | 1752 | return m_pc + (size >> 0); |
| 1708 | 1753 | } |
| 1709 | 1754 | |
| 1710 | | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_00_p01(OPS_32) |
| 1711 | | { |
| 1712 | | int size = 4; |
| 1713 | | arcompact_fatal("arcompact_handle04_00_p01 (ADD)\n"); |
| 1714 | | return m_pc + (size >> 0); |
| 1715 | | } |
| 1716 | | |
| 1717 | 1755 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_00_p10(OPS_32) |
| 1718 | 1756 | { |
| 1719 | 1757 | int size = 4; |
| r242545 | r242546 | |
| 1754 | 1792 | |
| 1755 | 1793 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_04_p00(OPS_32) |
| 1756 | 1794 | { |
| 1795 | SETUP_HANDLE04_0x_P00 |
| 1796 | |
| 1797 | m_regs[areg] = b & c; |
| 1798 | |
| 1799 | if (F) |
| 1800 | { |
| 1801 | arcompact_fatal("arcompact_handle04_04_p00 (AND) (F set)\n"); // not yet supported |
| 1802 | } |
| 1803 | |
| 1804 | return m_pc + (size >> 0); |
| 1805 | } |
| 1806 | |
| 1807 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_04_p01(OPS_32) |
| 1808 | { |
| 1757 | 1809 | int size = 4; |
| 1758 | 1810 | UINT32 limm = 0; |
| 1759 | | int got_limm = 0; |
| 1811 | // int got_limm = 0; |
| 1760 | 1812 | |
| 1761 | 1813 | COMMON32_GET_breg; |
| 1762 | 1814 | COMMON32_GET_F; |
| 1763 | | COMMON32_GET_creg |
| 1815 | COMMON32_GET_u6 |
| 1764 | 1816 | COMMON32_GET_areg |
| 1765 | 1817 | |
| 1766 | 1818 | UINT32 b, c; |
| 1767 | 1819 | |
| 1820 | // is having b as LIMM valid here? LIMM vs. fixed u6 value makes no sense |
| 1768 | 1821 | if (breg == LIMM_REG) |
| 1769 | 1822 | { |
| 1770 | 1823 | GET_LIMM_32; |
| 1771 | 1824 | size = 8; |
| 1772 | | got_limm = 1; |
| 1825 | // got_limm = 1; |
| 1773 | 1826 | b = limm; |
| 1774 | 1827 | } |
| 1775 | 1828 | else |
| r242545 | r242546 | |
| 1777 | 1830 | b = m_regs[breg]; |
| 1778 | 1831 | } |
| 1779 | 1832 | |
| 1780 | | if (creg == LIMM_REG) |
| 1781 | | { |
| 1782 | | if (!got_limm) |
| 1783 | | { |
| 1784 | | GET_LIMM_32; |
| 1785 | | size = 8; |
| 1786 | | } |
| 1787 | | c = limm; |
| 1788 | | } |
| 1789 | | else |
| 1790 | | { |
| 1791 | | c = m_regs[creg]; |
| 1792 | | } |
| 1793 | | // todo: is and a, limm, limm valid? (it's pointless.) |
| 1833 | c = u; |
| 1794 | 1834 | |
| 1795 | 1835 | // todo: if areg = LIMM then there is no result (but since that register can never be read, I guess it doesn't matter if we store it there anyway?) |
| 1796 | 1836 | m_regs[areg] = b & c; |
| 1797 | 1837 | |
| 1798 | 1838 | if (F) |
| 1799 | 1839 | { |
| 1800 | | arcompact_fatal("arcompact_handle04_04_p00 (AND) (F set)\n"); // not yet supported |
| 1840 | arcompact_fatal("arcompact_handle04_04_p01 (AND) (F set)\n"); // not yet supported |
| 1801 | 1841 | } |
| 1802 | 1842 | |
| 1803 | | return m_pc + (size >> 0);} |
| 1804 | | |
| 1805 | | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_04_p01(OPS_32) |
| 1806 | | { |
| 1807 | | int size = 4; |
| 1808 | | arcompact_fatal("arcompact_handle04_04_p01 (AND)\n"); |
| 1809 | 1843 | return m_pc + (size >> 0); |
| 1810 | 1844 | } |
| 1811 | 1845 | |
| r242545 | r242546 | |
| 1837 | 1871 | } |
| 1838 | 1872 | |
| 1839 | 1873 | |
| 1840 | | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_06_p00(OPS_32) |
| 1874 | // Bitwise AND Operation with Inverted Source |
| 1875 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_06_p00(OPS_32) // BIC |
| 1841 | 1876 | { |
| 1842 | | int size = 4; |
| 1843 | | arcompact_fatal("arcompact_handle04_06_p00 (BIC)\n"); |
| 1877 | SETUP_HANDLE04_0x_P00 |
| 1878 | |
| 1879 | m_regs[areg] = b & (~c); |
| 1880 | |
| 1881 | if (F) |
| 1882 | { |
| 1883 | arcompact_fatal("arcompact_handle04_06_p00 (BIC) (F set)\n"); // not yet supported |
| 1884 | } |
| 1885 | |
| 1844 | 1886 | return m_pc + (size >> 0); |
| 1845 | | |
| 1846 | 1887 | } |
| 1847 | 1888 | |
| 1848 | 1889 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_06_p01(OPS_32) |
| r242545 | r242546 | |
| 1874 | 1915 | } |
| 1875 | 1916 | |
| 1876 | 1917 | |
| 1877 | | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_07(OPS_32) |
| 1918 | |
| 1919 | |
| 1920 | // XOR |
| 1921 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_07_p00(OPS_32) // XOR |
| 1878 | 1922 | { |
| 1879 | | return arcompact_handle04_helper(PARAMS, opcodes_04[0x07], /*"XOR"*/ 0,0); |
| 1923 | int size = 4; |
| 1924 | arcompact_fatal("arcompact_handle04_07_p00 (XOR)\n"); |
| 1925 | return m_pc + (size >> 0); |
| 1880 | 1926 | } |
| 1881 | 1927 | |
| 1928 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_07_p01(OPS_32) |
| 1929 | { |
| 1930 | int size = 4; |
| 1931 | UINT32 limm = 0; |
| 1932 | // int got_limm = 0; |
| 1933 | |
| 1934 | COMMON32_GET_breg; |
| 1935 | COMMON32_GET_F; |
| 1936 | COMMON32_GET_u6 |
| 1937 | COMMON32_GET_areg |
| 1938 | |
| 1939 | UINT32 b, c; |
| 1940 | |
| 1941 | // is having b as LIMM valid here? LIMM vs. fixed u6 value makes no sense |
| 1942 | if (breg == LIMM_REG) |
| 1943 | { |
| 1944 | GET_LIMM_32; |
| 1945 | size = 8; |
| 1946 | // got_limm = 1; |
| 1947 | b = limm; |
| 1948 | } |
| 1949 | else |
| 1950 | { |
| 1951 | b = m_regs[breg]; |
| 1952 | } |
| 1953 | |
| 1954 | c = u; |
| 1955 | |
| 1956 | // todo: if areg = LIMM then there is no result (but since that register can never be read, I guess it doesn't matter if we store it there anyway?) |
| 1957 | m_regs[areg] = b ^ c; |
| 1958 | |
| 1959 | if (F) |
| 1960 | { |
| 1961 | arcompact_fatal("arcompact_handle04_07_p01 (XOR) (F set)\n"); // not yet supported |
| 1962 | } |
| 1963 | |
| 1964 | return m_pc + (size >> 0); |
| 1965 | } |
| 1966 | |
| 1967 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_07_p10(OPS_32) |
| 1968 | { |
| 1969 | int size = 4; |
| 1970 | arcompact_fatal("arcompact_handle04_07_p10 (XOR)\n"); |
| 1971 | return m_pc + (size >> 0); |
| 1972 | } |
| 1973 | |
| 1974 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_07_p11_m0(OPS_32) |
| 1975 | { |
| 1976 | int size = 4; |
| 1977 | arcompact_fatal("arcompact_handle04_07_p11_m0 (XOR)\n"); |
| 1978 | return m_pc + (size >> 0); |
| 1979 | } |
| 1980 | |
| 1981 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_07_p11_m1(OPS_32) |
| 1982 | { |
| 1983 | int size = 4; |
| 1984 | arcompact_fatal("arcompact_handle04_07_p11_m1 (XOR)\n"); |
| 1985 | return m_pc + (size >> 0); |
| 1986 | } |
| 1987 | |
| 1882 | 1988 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_08(OPS_32) |
| 1883 | 1989 | { |
| 1884 | 1990 | return arcompact_handle04_helper(PARAMS, opcodes_04[0x08], /*"MAX"*/ 0,0); |
| r242545 | r242546 | |
| 1890 | 1996 | } |
| 1891 | 1997 | |
| 1892 | 1998 | |
| 1893 | | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0a_p00(OPS_32) |
| 1999 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0a_p00(OPS_32) // MOV<f> b, c |
| 1894 | 2000 | { |
| 1895 | | // p00 formats not listed in appendix? |
| 1896 | | |
| 1897 | 2001 | int size = 4; |
| 1898 | 2002 | UINT32 limm = 0; |
| 1899 | 2003 | int got_limm = 0; |
| r242545 | r242546 | |
| 1930 | 2034 | // MOV b <- c 0010 0RRR 0000 1010 0RRR cccc ccRR RRRR |
| 1931 | 2035 | // MOV.F b <- c 0010 0RRR 0000 1010 1RRR cccc ccRR RRRR |
| 1932 | 2036 | |
| 1933 | | arcompact_fatal("unimplemented MOV b <- c %08x", op); |
| 2037 | m_regs[breg] = m_regs[creg]; |
| 2038 | |
| 2039 | if (F) |
| 2040 | { // currently not supported |
| 2041 | arcompact_fatal("unimplemented MOV.F %08x", op); |
| 2042 | } |
| 2043 | |
| 2044 | return m_pc + (size>>0); |
| 1934 | 2045 | } |
| 1935 | 2046 | |
| 1936 | 2047 | return m_pc + (size>>0); |
| r242545 | r242546 | |
| 1980 | 2091 | return m_pc + (size >> 0); |
| 1981 | 2092 | } |
| 1982 | 2093 | |
| 1983 | | #if 0 |
| 1984 | | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0a(OPS_32) |
| 1985 | | { |
| 1986 | | return arcompact_handle04_helper(PARAMS, opcodes_04[0x0a], /*"MOV"*/ 1,0); |
| 1987 | | } |
| 1988 | | #endif |
| 1989 | 2094 | |
| 1990 | 2095 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0b(OPS_32) |
| 1991 | 2096 | { |
| r242545 | r242546 | |
| 2007 | 2112 | return arcompact_handle04_helper(PARAMS, opcodes_04[0x0e], /*"RSUB"*/ 0,0); |
| 2008 | 2113 | } |
| 2009 | 2114 | |
| 2010 | | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0f(OPS_32) |
| 2011 | | { |
| 2012 | | return arcompact_handle04_helper(PARAMS, opcodes_04[0x0f], /*"BSET"*/ 0,0); |
| 2115 | |
| 2116 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0f_p00(OPS_32) |
| 2117 | { |
| 2118 | SETUP_HANDLE04_0x_P00 |
| 2119 | |
| 2120 | m_regs[areg] = b | (1 << (c & 0x1f)); |
| 2121 | |
| 2122 | if (F) |
| 2123 | { |
| 2124 | arcompact_fatal("arcompact_handle04_06_p00 (BSET) (F set)\n"); // not yet supported |
| 2125 | } |
| 2126 | |
| 2127 | return m_pc + (size >> 0); |
| 2013 | 2128 | } |
| 2014 | 2129 | |
| 2130 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0f_p01(OPS_32) |
| 2131 | { |
| 2132 | int size = 4; |
| 2133 | arcompact_fatal("arcompact_handle04_0f_p01 (BSET)\n"); |
| 2134 | return m_pc + (size >> 0); |
| 2135 | } |
| 2136 | |
| 2137 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0f_p10(OPS_32) |
| 2138 | { |
| 2139 | int size = 4; |
| 2140 | arcompact_fatal("arcompact_handle04_0f_p10 (BSET)\n"); |
| 2141 | return m_pc + (size >> 0); |
| 2142 | } |
| 2143 | |
| 2144 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0f_p11_m0(OPS_32) |
| 2145 | { |
| 2146 | int size = 4; |
| 2147 | arcompact_fatal("arcompact_handle04_0f_p11_m0 (BSET)\n"); |
| 2148 | return m_pc + (size >> 0); |
| 2149 | } |
| 2150 | |
| 2151 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0f_p11_m1(OPS_32) |
| 2152 | { |
| 2153 | int size = 4; |
| 2154 | arcompact_fatal("arcompact_handle04_0f_p11_m1 (BSET)\n"); |
| 2155 | return m_pc + (size >> 0); |
| 2156 | } |
| 2157 | |
| 2015 | 2158 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_10(OPS_32) |
| 2016 | 2159 | { |
| 2017 | 2160 | return arcompact_handle04_helper(PARAMS, opcodes_04[0x10], /*"BCLR"*/ 0,0); |
| r242545 | r242546 | |
| 2788 | 2931 | } |
| 2789 | 2932 | |
| 2790 | 2933 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_02(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "SUB_S",0); } |
| 2791 | | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_04(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "AND_S",0); } |
| 2934 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_04(OPS_16) // AND_S b <- b, c |
| 2935 | { |
| 2936 | int breg, creg; |
| 2937 | |
| 2938 | COMMON16_GET_breg; |
| 2939 | COMMON16_GET_creg; |
| 2940 | |
| 2941 | REG_16BIT_RANGE(breg); |
| 2942 | REG_16BIT_RANGE(creg); |
| 2943 | |
| 2944 | m_regs[breg] = m_regs[breg] & m_regs[creg]; |
| 2945 | |
| 2946 | return m_pc + (2 >> 0); |
| 2947 | } |
| 2948 | |
| 2792 | 2949 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_05(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "OR_S",0); } |
| 2793 | 2950 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_06(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "BIC_S",0); } |
| 2794 | 2951 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_07(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "XOR_S",0); } |
| r242545 | r242546 | |
| 2807 | 2964 | REG_16BIT_RANGE(breg); |
| 2808 | 2965 | REG_16BIT_RANGE(creg); |
| 2809 | 2966 | |
| 2810 | | m_regs[breg] = m_regs[creg] & 0xff; |
| 2967 | m_regs[breg] = m_regs[creg] & 0x000000ff; |
| 2811 | 2968 | |
| 2812 | 2969 | return m_pc + (2 >> 0); |
| 2813 | 2970 | |
| 2814 | 2971 | } |
| 2815 | 2972 | |
| 2816 | | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_10(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "EXTW_S",0); } |
| 2973 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_10(OPS_16) // EXTW_S |
| 2974 | { |
| 2975 | int breg, creg; |
| 2976 | |
| 2977 | COMMON16_GET_breg; |
| 2978 | COMMON16_GET_creg; |
| 2979 | |
| 2980 | REG_16BIT_RANGE(breg); |
| 2981 | REG_16BIT_RANGE(creg); |
| 2982 | |
| 2983 | m_regs[breg] = m_regs[creg] & 0x0000ffff; |
| 2984 | |
| 2985 | return m_pc + (2 >> 0); |
| 2986 | } |
| 2987 | |
| 2817 | 2988 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_11(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "ABS_S",0); } |
| 2818 | 2989 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_12(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "NOT_S",0); } |
| 2819 | 2990 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_13(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "NEG_S",0); } |
| r242545 | r242546 | |
| 2823 | 2994 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_18(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "ASL_S",0); } |
| 2824 | 2995 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_19(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "LSR_S",0); } |
| 2825 | 2996 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_1a(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "ASR_S",0); } |
| 2826 | | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_1b(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "ASL1_S",0); } |
| 2997 | |
| 2998 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_1b(OPS_16) // ASL b, c asl 1 (can also be impleneted as b = c + c) |
| 2999 | { |
| 3000 | int breg, creg; |
| 3001 | |
| 3002 | COMMON16_GET_breg; |
| 3003 | COMMON16_GET_creg; |
| 3004 | |
| 3005 | REG_16BIT_RANGE(breg); |
| 3006 | REG_16BIT_RANGE(creg); |
| 3007 | |
| 3008 | m_regs[breg] = m_regs[creg] << 1; |
| 3009 | |
| 3010 | return m_pc + (2 >> 0); |
| 3011 | } |
| 3012 | |
| 2827 | 3013 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_1c(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "ASR1_S",0); } |
| 2828 | 3014 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0f_1d(OPS_16) { return arcompact_handle0f_0x_helper(PARAMS, "LSR1_S",0); } |
| 2829 | 3015 | |
| r242545 | r242546 | |
| 2885 | 3071 | |
| 2886 | 3072 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle12(OPS_16) |
| 2887 | 3073 | { |
| 2888 | | return arcompact_handle_ld_helper(PARAMS, "LDW_S", 1, 0); |
| 3074 | // LDB_W c, [b, u6] |
| 3075 | int breg, creg, u; |
| 3076 | |
| 3077 | COMMON16_GET_breg; |
| 3078 | COMMON16_GET_creg; |
| 3079 | COMMON16_GET_u5; |
| 3080 | |
| 3081 | REG_16BIT_RANGE(breg); |
| 3082 | REG_16BIT_RANGE(creg); |
| 3083 | |
| 3084 | u <<= 1; |
| 3085 | m_regs[creg] = READ16((m_regs[breg] + u) >> 1); |
| 3086 | |
| 3087 | return m_pc + (2 >> 0); |
| 2889 | 3088 | } |
| 2890 | 3089 | |
| 2891 | 3090 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle13(OPS_16) |
| r242545 | r242546 | |
| 2893 | 3092 | return arcompact_handle_ld_helper(PARAMS, "LDW_S.X", 1, 0); |
| 2894 | 3093 | } |
| 2895 | 3094 | |
| 2896 | | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle14(OPS_16) |
| 3095 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle14(OPS_16) // ST_S c, [b, u7] |
| 2897 | 3096 | { |
| 2898 | | return arcompact_handle_ld_helper(PARAMS, "ST_S", 2, 1); |
| 3097 | int breg, creg, u; |
| 3098 | |
| 3099 | COMMON16_GET_breg; |
| 3100 | COMMON16_GET_creg; |
| 3101 | COMMON16_GET_u5; |
| 3102 | |
| 3103 | REG_16BIT_RANGE(breg); |
| 3104 | REG_16BIT_RANGE(creg); |
| 3105 | |
| 3106 | u <<= 2; |
| 3107 | |
| 3108 | WRITE32((m_regs[breg] + u) >> 2, m_regs[creg]); |
| 3109 | |
| 3110 | return m_pc + (2 >> 0); |
| 2899 | 3111 | } |
| 2900 | 3112 | |
| 2901 | 3113 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle15(OPS_16) |
| r242545 | r242546 | |
| 2903 | 3115 | return arcompact_handle_ld_helper(PARAMS, "STB_S", 0, 1); |
| 2904 | 3116 | } |
| 2905 | 3117 | |
| 2906 | | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle16(OPS_16) |
| 3118 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle16(OPS_16) // STW_S c. [b, u6] |
| 2907 | 3119 | { |
| 2908 | | return arcompact_handle_ld_helper(PARAMS, "STW_S", 1, 1); |
| 3120 | int breg, creg, u; |
| 3121 | |
| 3122 | COMMON16_GET_breg; |
| 3123 | COMMON16_GET_creg; |
| 3124 | COMMON16_GET_u5; |
| 3125 | |
| 3126 | REG_16BIT_RANGE(breg); |
| 3127 | REG_16BIT_RANGE(creg); |
| 3128 | |
| 3129 | u <<= 1; |
| 3130 | |
| 3131 | WRITE16((m_regs[breg] + u) >> 1, m_regs[creg]); |
| 3132 | |
| 3133 | return m_pc + (2 >> 0); |
| 3134 | |
| 2909 | 3135 | } |
| 2910 | 3136 | |
| 2911 | 3137 | |
| r242545 | r242546 | |
| 2984 | 3210 | return m_pc + (2 >> 0); |
| 2985 | 3211 | } |
| 2986 | 3212 | |
| 2987 | | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle18_00(OPS_16) |
| 3213 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle18_00(OPS_16) // LD_S b, [SP, u7] |
| 2988 | 3214 | { |
| 2989 | | return arcompact_handle18_0x_helper(PARAMS, "LD_S", 0); |
| 3215 | int breg; |
| 3216 | UINT32 u; |
| 3217 | |
| 3218 | COMMON16_GET_breg; |
| 3219 | COMMON16_GET_u5; |
| 3220 | |
| 3221 | REG_16BIT_RANGE(breg); |
| 3222 | |
| 3223 | UINT32 address = m_regs[REG_SP] + (u << 2); |
| 3224 | |
| 3225 | m_regs[breg] = READ32(address >> 2); |
| 3226 | |
| 3227 | return m_pc + (2 >> 0); |
| 2990 | 3228 | } |
| 2991 | 3229 | |
| 2992 | 3230 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle18_01(OPS_16) |
| 2993 | 3231 | { |
| 2994 | | return arcompact_handle18_0x_helper(PARAMS, "LDB_S", 0); |
| 3232 | return arcompact_handle18_0x_helper(PARAMS, "LDB_S (SP)", 0); |
| 2995 | 3233 | } |
| 2996 | 3234 | |
| 2997 | | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle18_02(OPS_16) |
| 3235 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle18_02(OPS_16) // ST_S b, [SP, u7] |
| 2998 | 3236 | { |
| 2999 | | return arcompact_handle18_0x_helper(PARAMS, "ST_S", 1); |
| 3237 | int breg; |
| 3238 | UINT32 u; |
| 3239 | |
| 3240 | COMMON16_GET_breg; |
| 3241 | COMMON16_GET_u5; |
| 3242 | |
| 3243 | REG_16BIT_RANGE(breg); |
| 3244 | |
| 3245 | UINT32 address = m_regs[REG_SP] + (u << 2); |
| 3246 | |
| 3247 | WRITE32(address >> 2, m_regs[breg]); |
| 3248 | |
| 3249 | return m_pc + (2 >> 0); |
| 3000 | 3250 | } |
| 3001 | 3251 | |
| 3002 | 3252 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle18_03(OPS_16) |
| 3003 | 3253 | { |
| 3004 | | return arcompact_handle18_0x_helper(PARAMS, "STB_S", 1); |
| 3254 | return arcompact_handle18_0x_helper(PARAMS, "STB_S (SP)", 1); |
| 3005 | 3255 | } |
| 3006 | 3256 | |
| 3007 | | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle18_04(OPS_16) |
| 3257 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle18_04(OPS_16) // ADD_S b, SP, u7 |
| 3008 | 3258 | { |
| 3009 | | return arcompact_handle18_0x_helper(PARAMS, "ADD_S", 1); // check format |
| 3259 | int breg; |
| 3260 | UINT32 u; |
| 3261 | |
| 3262 | COMMON16_GET_breg; |
| 3263 | COMMON16_GET_u5; |
| 3264 | |
| 3265 | REG_16BIT_RANGE(breg); |
| 3266 | |
| 3267 | m_regs[breg] = m_regs[REG_SP] + (u << 2); |
| 3268 | |
| 3269 | return m_pc + (2 >> 0); |
| 3010 | 3270 | } |
| 3011 | 3271 | |
| 3012 | 3272 | // op bits remaining for 0x18_05_xx subgroups 0x001f |
| r242545 | r242546 | |
| 3182 | 3442 | return m_pc + (2 >> 0); |
| 3183 | 3443 | } |
| 3184 | 3444 | |
| 3185 | | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle1d_helper(OPS_16, const char* optext) |
| 3445 | |
| 3446 | |
| 3447 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle1d_00(OPS_16) // BREQ_S b,0,s8 |
| 3186 | 3448 | { |
| 3187 | | arcompact_log("unimplemented %s %04x", optext, op); |
| 3449 | int breg; |
| 3450 | COMMON16_GET_breg; |
| 3451 | REG_16BIT_RANGE(breg); |
| 3452 | |
| 3453 | if (!m_regs[breg]) |
| 3454 | { |
| 3455 | int s = (op & 0x007f) >> 0; op &= ~0x007f; |
| 3456 | if (s & 0x40) s = -0x40 + (s & 0x3f); |
| 3457 | UINT32 realaddress = PC_ALIGNED32 + (s * 2); |
| 3458 | //m_regs[REG_BLINK] = m_pc + (2 >> 0); // don't link |
| 3459 | return realaddress; |
| 3460 | } |
| 3461 | |
| 3188 | 3462 | return m_pc + (2 >> 0); |
| 3189 | 3463 | } |
| 3190 | 3464 | |
| 3191 | 3465 | |
| 3192 | | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle1d_00(OPS_16) // BREQ b,0,s8 |
| 3466 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle1d_01(OPS_16) // BRNE_S b,0,s8 |
| 3193 | 3467 | { |
| 3194 | 3468 | int breg; |
| 3195 | 3469 | COMMON16_GET_breg; |
| 3196 | 3470 | REG_16BIT_RANGE(breg); |
| 3197 | 3471 | |
| 3198 | | if (!m_regs[breg]) |
| 3472 | if (m_regs[breg]) |
| 3199 | 3473 | { |
| 3200 | 3474 | int s = (op & 0x007f) >> 0; op &= ~0x007f; |
| 3201 | 3475 | if (s & 0x40) s = -0x40 + (s & 0x3f); |
| r242545 | r242546 | |
| 3208 | 3482 | } |
| 3209 | 3483 | |
| 3210 | 3484 | |
| 3211 | | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle1d_01(OPS_16) { return arcompact_handle1d_helper(PARAMS,"BRNE_S"); } |
| 3212 | | |
| 3213 | | |
| 3214 | 3485 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle1e_0x_helper(OPS_16, const char* optext) |
| 3215 | 3486 | { |
| 3216 | 3487 | arcompact_log("unimplemented %s %04x (1e_0x type)", optext, op); |
trunk/src/emu/cpu/arcompact/arcompactdasm_ops.c
| r242545 | r242546 | |
| 457 | 457 | return size; |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | // like p00 but with 'u6' istead of C |
| 460 | 461 | int arcompact_handle04_p01_helper_dasm(DASM_OPS_32, const char* optext, int ignore_dst, int b_reserved) |
| 461 | 462 | { |
| 463 | // PP |
| 464 | // 0010 0bbb 01ii iiii FBBB uuuu uuAA AAAA |
| 462 | 465 | int size = 4; |
| 463 | 466 | UINT32 limm = 0; |
| 464 | | //int got_limm = 0; |
| 467 | // int got_limm = 0; |
| 465 | 468 | |
| 466 | 469 | COMMON32_GET_breg; |
| 467 | | COMMON32_GET_F |
| 470 | COMMON32_GET_F; |
| 468 | 471 | COMMON32_GET_u6 |
| 469 | 472 | COMMON32_GET_areg |
| 470 | 473 | |
| r242545 | r242546 | |
| 472 | 475 | output += sprintf(output, "%s", flagbit[F]); |
| 473 | 476 | // output += sprintf( output, " p(%d)", p); |
| 474 | 477 | |
| 475 | | if (!b_reserved) |
| 478 | |
| 479 | if ((!b_reserved) && (breg == LIMM_REG)) |
| 476 | 480 | { |
| 477 | | if (breg == LIMM_REG) |
| 478 | | { |
| 479 | | GET_LIMM_32; |
| 480 | | size = 8; |
| 481 | | //got_limm = 1; |
| 482 | | output += sprintf(output, " 0x%08x ", limm); |
| 481 | GET_LIMM_32; |
| 482 | size = 8; |
| 483 | // got_limm = 1; |
| 484 | } |
| 483 | 485 | |
| 484 | | } |
| 485 | | else |
| 486 | | { |
| 487 | | output += sprintf(output, " %s, ", regnames[breg]); |
| 488 | | } |
| 486 | // areg can be LIMM too, but in that case LIMM indicates 'no destination' rather than an actual LIMM value following |
| 487 | |
| 488 | if (ignore_dst == 0) |
| 489 | { |
| 490 | if (areg != LIMM_REG) output += sprintf(output, " %s <-", regnames[areg]); |
| 491 | else output += sprintf(output, " <no dst> <-"); |
| 489 | 492 | } |
| 490 | | else |
| 493 | else if (ignore_dst == 1) // certain opcode types ignore the 'a' field entirely, it should be set to 0. |
| 491 | 494 | { |
| 492 | | if (breg) output += sprintf(output, "reserved(%s), ", regnames[breg]); |
| 495 | if (areg) output += sprintf(output, " <reserved %d> <-", areg); |
| 493 | 496 | } |
| 497 | else if (ignore_dst == 2) // for multiply operations areg should always be set to LIMM |
| 498 | { |
| 499 | if (areg != LIMM_REG) output += sprintf(output, " <invalid %d> <-", areg); |
| 500 | else output += sprintf(output, " <mulres> <-"); |
| 501 | } |
| 494 | 502 | |
| 495 | | output += sprintf(output, " 0x%02x ", u); |
| 496 | | if (ignore_dst == 0) |
| 503 | if (!b_reserved) |
| 497 | 504 | { |
| 498 | | if (areg != LIMM_REG) output += sprintf(output, "DST(%s)", regnames[areg]); |
| 499 | | else output += sprintf(output, "<no dst>"); |
| 505 | if (breg == LIMM_REG) |
| 506 | output += sprintf(output, " 0x%08x,", limm); |
| 507 | else |
| 508 | output += sprintf(output, " %s,", regnames[breg]); |
| 500 | 509 | } |
| 501 | 510 | else |
| 502 | 511 | { |
| 503 | | if (ignore_dst == 1) { if (areg) output += sprintf(output, "unused(%s)", regnames[areg]); } |
| 504 | | else |
| 505 | | { |
| 506 | | if (areg != LIMM_REG) output += sprintf(output, "invalid(%s)", regnames[areg]); |
| 507 | | else output += sprintf(output, "<mulres>"); |
| 508 | | } // mul operations expect A to be set to LIMM (no output) |
| 512 | if (breg) output += sprintf(output, "<reserved %d>,", breg); |
| 509 | 513 | } |
| 514 | |
| 515 | output += sprintf(output, " 0x%02x", u); |
| 516 | |
| 510 | 517 | return size; |
| 511 | 518 | } |
| 512 | 519 | |
| r242545 | r242546 | |
| 1716 | 1723 | |
| 1717 | 1724 | // op bits remaining for 0x18_xx subgroups 0x071f |
| 1718 | 1725 | |
| 1719 | | int arcompact_handle18_0x_helper_dasm(DASM_OPS_16, const char* optext, int st) |
| 1726 | int arcompact_handle18_0x_helper_dasm(DASM_OPS_16, const char* optext, int st, int format) |
| 1720 | 1727 | { |
| 1721 | 1728 | int breg, u; |
| 1722 | 1729 | |
| r242545 | r242546 | |
| 1728 | 1735 | output += sprintf( output, "%s %s ", optext, regnames[breg]); |
| 1729 | 1736 | if (st==1) output += sprintf( output, "-> "); |
| 1730 | 1737 | else output += sprintf( output, "<- "); |
| 1731 | | output += sprintf( output, "[SP, 0x%02x]", u*4); |
| 1732 | 1738 | |
| 1739 | if (format==0) output += sprintf( output, "[SP, 0x%02x]", u*4); |
| 1740 | else output += sprintf( output, "SP, 0x%02x", u*4); |
| 1741 | |
| 1742 | |
| 1733 | 1743 | return 2; |
| 1734 | 1744 | } |
| 1735 | 1745 | |
| 1736 | 1746 | int arcompact_handle18_00_dasm(DASM_OPS_16) |
| 1737 | 1747 | { |
| 1738 | | return arcompact_handle18_0x_helper_dasm(DASM_PARAMS, "LD_S", 0); |
| 1748 | return arcompact_handle18_0x_helper_dasm(DASM_PARAMS, "LD_S", 0,0); |
| 1739 | 1749 | } |
| 1740 | 1750 | |
| 1741 | 1751 | int arcompact_handle18_01_dasm(DASM_OPS_16) |
| 1742 | 1752 | { |
| 1743 | | return arcompact_handle18_0x_helper_dasm(DASM_PARAMS, "LDB_S", 0); |
| 1753 | return arcompact_handle18_0x_helper_dasm(DASM_PARAMS, "LDB_S", 0,0); |
| 1744 | 1754 | } |
| 1745 | 1755 | |
| 1746 | 1756 | int arcompact_handle18_02_dasm(DASM_OPS_16) |
| 1747 | 1757 | { |
| 1748 | | return arcompact_handle18_0x_helper_dasm(DASM_PARAMS, "ST_S", 1); |
| 1758 | return arcompact_handle18_0x_helper_dasm(DASM_PARAMS, "ST_S", 1,0); |
| 1749 | 1759 | } |
| 1750 | 1760 | |
| 1751 | 1761 | int arcompact_handle18_03_dasm(DASM_OPS_16) |
| 1752 | 1762 | { |
| 1753 | | return arcompact_handle18_0x_helper_dasm(DASM_PARAMS, "STB_S", 1); |
| 1763 | return arcompact_handle18_0x_helper_dasm(DASM_PARAMS, "STB_S", 1,0); |
| 1754 | 1764 | } |
| 1755 | 1765 | |
| 1756 | 1766 | int arcompact_handle18_04_dasm(DASM_OPS_16) |
| 1757 | 1767 | { |
| 1758 | | return arcompact_handle18_0x_helper_dasm(DASM_PARAMS, "ADD_S", 1); // check format |
| 1768 | return arcompact_handle18_0x_helper_dasm(DASM_PARAMS, "ADD_S", 1,1); // check format |
| 1759 | 1769 | } |
| 1760 | 1770 | |
| 1761 | 1771 | // op bits remaining for 0x18_05_xx subgroups 0x001f |