Previous 199869 Revisions Next

r34070 Friday 26th December, 2014 at 15:37:30 UTC by David Haywood
arcompact (nw)
[src/emu/cpu/arcompact]arcompact_execute.c arcompact_make.py

trunk/src/emu/cpu/arcompact/arcompact_execute.c
r242581r242582
17451745}
17461746
17471747
1748ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0a_p00(OPS_32) // MOV<f> b, c
1749{
1750   int size = 4;
1751   UINT32 limm = 0;
1752   int got_limm = 0;
17531748
1754   COMMON32_GET_breg
1755   COMMON32_GET_creg
1756   COMMON32_GET_F
1757
1758   if (creg == LIMM_REG)
1759   {
1760      // opcode          iiii iBBB ppII IIII FBBB CCCC CC-- ----
1761      // MOV b   <- limm 0010 0RRR 0000 1010 0RRR 1111 10RR RRRR  [LIMM]  (creg = LIMM)
1762      // MOV.F b <- limm 0010 0RRR 0000 1010 1RRR 1111 10RR RRRR  [LIMM]  (creg = LIMM)
1763
1764      if (!got_limm)
1765      {
1766         GET_LIMM_32;
1767         size = 8;
1768      }
1769
1770      m_regs[breg] = limm;
1771
1772      if (F)
1773      { // currently not supported
1774         arcompact_fatal("unimplemented MOV.F %08x", op);
1775      }
1776
1777      return m_pc + (size>>0);
1778
1779   }
1780   else
1781   {
1782      // opcode          iiii iBBB ppII IIII FBBB CCCC CC-- ----
1783      // MOV   b <- c    0010 0RRR 0000 1010 0RRR cccc ccRR RRRR
1784      // MOV.F b <- c    0010 0RRR 0000 1010 1RRR cccc ccRR RRRR
1785
1786      m_regs[breg] = m_regs[creg];
1787
1788      if (F)
1789      { // currently not supported
1790         arcompact_fatal("unimplemented MOV.F %08x", op);
1791      }
1792
1793      return m_pc + (size>>0);
1794   }
1795
1796   return m_pc + (size>>0);
1797
1798}
1799
1800ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0a_p01(OPS_32)
1801{
1802   // opcode          iiii i--- ppII IIII F--- uuuu uu-- ----
1803   // MOV   b <- u6   0010 0RRR 0100 1010 0RRR uuuu uuRR RRRR
1804   // MOV.F b <- u6   0010 0RRR 0100 1010 1RRR uuuu uuRR RRRR
1805
1806   int size = 4;
1807
1808   COMMON32_GET_breg
1809   COMMON32_GET_u6
1810   COMMON32_GET_F
1811
1812   m_regs[breg] = u;
1813
1814   if (F)
1815   { // currently not supported
1816      arcompact_fatal("unimplemented MOV.F b <- u6 %08x", op);
1817   }
1818
1819   return m_pc + (size>>0);
1820}
1821
1822ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0a_p10(OPS_32)
1823{
1824   int size = 4;
1825
1826   COMMON32_GET_breg;
1827   COMMON32_GET_s12;
1828   COMMON32_GET_F;
1829
1830   m_regs[breg] = S;
1831
1832   if (F)
1833   { // currently not supported
1834      arcompact_fatal("unimplemented MOV.F b <- s12 %08x", op);
1835   }
1836
1837   return m_pc + (size>>0);}
1838
1839ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0a_p11_m0(OPS_32)
1840{
1841   int size = 4;
1842   arcompact_fatal("arcompact_handle04_0a_p11_m0\n");
1843   return m_pc + (size >> 0);
1844}
1845
1846ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0a_p11_m1(OPS_32)
1847{
1848   int size = 4;
1849   arcompact_fatal("arcompact_handle04_0a_p11_m1\n");
1850   return m_pc + (size >> 0);
1851}
1852
1853
18541749ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_0b(OPS_32)
18551750{
18561751   return arcompact_handle04_helper(PARAMS, opcodes_04[0x0b], /*"TST"*/ 1,0);
trunk/src/emu/cpu/arcompact/arcompact_make.py
r242581r242582
33import sys
44import re
55
6def EmitGroup04_Handle_NZ_Flags(f, funcname, opname):
7        print >>f, "      if (result & 0x80000000) { STATUS32_SET_N; }"
8        print >>f, "      else { STATUS32_CLEAR_N; }"
9        print >>f, "      if (result == 0x00000000) { STATUS32_SET_Z; }"
10        print >>f, "      else { STATUS32_CLEAR_Z; }"
611
7def EmitGroup04(f,funcname, opname, opexecute):
12def EmitGroup04_no_Flags(f, funcname, opname):
13       print >>f, "      // no flag changes"
14
15def EmitGroup04_unsupported_Flags(f, funcname, opname):
16        print >>f, "      arcompact_fatal(\"arcompact_handle%s (%s) (F set)\\n\"); // not yet supported" % (funcname, opname)
17
18def EmitGroup04_Flaghandler(f,funcname, opname, flagcondition, flaghandler):
19    if flagcondition == -1:
20        print >>f, "   if (F)"
21        print >>f, "   {"
22        flaghandler(f, funcname, opname)
23        print >>f, "   }"
24    elif flagcondition == 0:
25        print >>f, "   if (0)"
26        print >>f, "   {"
27        flaghandler(f, funcname, opname)
28        print >>f, "   }"
29    elif flagcondition == 1:
30        print >>f, "   if (1)"
31        print >>f, "   {"
32        flaghandler(f, funcname, opname)
33        print >>f, "   }"
34
35def EmitGroup04(f,funcname, opname, opexecute, ignore_a, breg_is_dst_only, flagcondition, flaghandler):
836    # the mode 0x00 handler 
937    print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p00(OPS_32)" % (funcname)
1038    print >>f, "{"
1139    print >>f, "   int size = 4;"
40   
1241    print >>f, "   UINT32 limm = 0;"
42   
1343    print >>f, "   int got_limm = 0;"
1444    print >>f, "   "
1545    print >>f, "   COMMON32_GET_breg;"
16    print >>f, "   COMMON32_GET_F;"
46
47    if flagcondition == -1:
48        print >>f, "   COMMON32_GET_F;"
49   
1750    print >>f, "   COMMON32_GET_creg;"
18    print >>f, "   COMMON32_GET_areg;"
51
52    if ignore_a == 0:
53        print >>f, "   COMMON32_GET_areg;"
54    elif ignore_a == 1:
55       print >>f, "     //COMMON32_GET_areg; // areg is reserved / not used"
56   
1957    print >>f, "   "
20    print >>f, "   UINT32 b, c;"
58   
59    print >>f, "   UINT32 c;"
60    if breg_is_dst_only == 0:
61        print >>f, "   UINT32 b;"
62        print >>f, "   "
63        print >>f, "   if (breg == LIMM_REG)"
64        print >>f, "   {"
65        print >>f, "      GET_LIMM_32;"
66        print >>f, "      size = 8;"
67        print >>f, "      got_limm = 1;"
68        print >>f, "      b = limm;"
69        print >>f, "   }"
70        print >>f, "   else"
71        print >>f, "   {"
72        print >>f, "      b = m_regs[breg];"
73        print >>f, "   }"
74   
2175    print >>f, "   "
22    print >>f, "   if (breg == LIMM_REG)"
23    print >>f, "   {"
24    print >>f, "      GET_LIMM_32;"
25    print >>f, "      size = 8;"
26    print >>f, "      got_limm = 1;"
27    print >>f, "      b = limm;"
28    print >>f, "   }"
29    print >>f, "   else"
30    print >>f, "   {"
31    print >>f, "      b = m_regs[breg];"
32    print >>f, "   }"
33    print >>f, "   "
3476    print >>f, "   if (creg == LIMM_REG)"
3577    print >>f, "   {"
3678    print >>f, "      if (!got_limm)"
r242581r242582
4890    print >>f, "   /* 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?) */"
4991    print >>f, "   %s" % (opexecute)
5092    print >>f, "   "
51    print >>f, "   if (F)"
52    print >>f, "   {"
53    print >>f, "      arcompact_fatal(\"arcompact_handle%s_p00 (%s) (F set)\\n\"); // not yet supported" % (funcname, opname)
54    print >>f, "   }"
93    EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler)
5594    print >>f, "   return m_pc + (size >> 0);"
5695    print >>f, "}"
5796    print >>f, ""
r242581r242582
6099    print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p01(OPS_32)" % (funcname)
61100    print >>f, "{"
62101    print >>f, "   int size = 4;"
63    print >>f, "   UINT32 limm = 0;"
102   
103    if breg_is_dst_only == 0:   
104        print >>f, "   UINT32 limm = 0;"
105   
64106    print >>f, "/*   int got_limm = 0; */"
65107    print >>f, "   "
66108    print >>f, "   COMMON32_GET_breg;"
67    print >>f, "   COMMON32_GET_F;"
109   
110    if flagcondition == -1:
111        print >>f, "   COMMON32_GET_F;"
112   
68113    print >>f, "   COMMON32_GET_u6;"
69    print >>f, "   COMMON32_GET_areg;"
114   
115    if ignore_a == 0:
116        print >>f, "   COMMON32_GET_areg;"
117    elif ignore_a == 1:
118       print >>f, "     //COMMON32_GET_areg; // areg is reserved / not used"
119   
70120    print >>f, "   "
71    print >>f, "   UINT32 b, c;"
72    print >>f, "   "
73    print >>f, "   /* is having b as LIMM valid here? LIMM vs. fixed u6 value makes no sense */"
74    print >>f, "   if (breg == LIMM_REG)"
75    print >>f, "   {"
76    print >>f, "      GET_LIMM_32;"
77    print >>f, "      size = 8;"
78    print >>f, "/*      got_limm = 1; */"
79    print >>f, "      b = limm;"
80    print >>f, "   }"
81    print >>f, "   else"
82    print >>f, "   {"
83    print >>f, "      b = m_regs[breg];"
84    print >>f, "   }"
121   
122    print >>f, "   UINT32 c;"
123    if breg_is_dst_only == 0:
124        print >>f, "   UINT32 b;"
125        print >>f, "   "
126        print >>f, "   /* is having b as LIMM valid here? LIMM vs. fixed u6 value makes no sense */"
127        print >>f, "   if (breg == LIMM_REG)"
128        print >>f, "   {"
129        print >>f, "      GET_LIMM_32;"
130        print >>f, "      size = 8;"
131        print >>f, "/*      got_limm = 1; */"
132        print >>f, "      b = limm;"
133        print >>f, "   }"
134        print >>f, "   else"
135        print >>f, "   {"
136        print >>f, "      b = m_regs[breg];"
137        print >>f, "   }"
138   
85139    print >>f, "    "
86140    print >>f, "    c = u;"
87141    print >>f, "   "
88142    print >>f, "   /* 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?) */"
89143    print >>f, "   %s" % (opexecute)
90144    print >>f, "   "
91    print >>f, "   if (F)"
92    print >>f, "   {"
93    print >>f, "      arcompact_fatal(\"arcompact_handle%s_p01 (%s) (F set)\\n\"); // not yet supported" % (funcname, opname)
94    print >>f, "   }"
145    EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler)
95146    print >>f, "   return m_pc + (size >> 0);"
96147    print >>f, "}"
97148    print >>f, ""
r242581r242582
100151    print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p10(OPS_32)" % (funcname)
101152    print >>f, "{"
102153    print >>f, "   int size = 4;"
103    print >>f, "   UINT32 limm = 0;"
154
155    if breg_is_dst_only == 0:
156        print >>f, "   UINT32 limm = 0;"
157   
104158    print >>f, "/*   int got_limm = 0; */"
105159    print >>f, "   "
106160    print >>f, "   COMMON32_GET_breg;"
107    print >>f, "   COMMON32_GET_F;"
161
162    if flagcondition == -1:   
163        print >>f, "   COMMON32_GET_F;"
164   
108165    print >>f, "   COMMON32_GET_s12;"
109    print >>f, "   COMMON32_GET_areg;"
166   
167    if ignore_a == 0:   
168        print >>f, "   COMMON32_GET_areg;"
169    elif ignore_a == 1:
170       print >>f, "     //COMMON32_GET_areg; // areg is reserved / not used"
171   
110172    print >>f, "   "
111    print >>f, "   UINT32 b, c;"
112    print >>f, "   "
113    print >>f, "   /* is having b as LIMM valid here? LIMM vs. fixed u6 value makes no sense */"
114    print >>f, "   if (breg == LIMM_REG)"
115    print >>f, "   {"
116    print >>f, "      GET_LIMM_32;"
117    print >>f, "      size = 8;"
118    print >>f, "/*      got_limm = 1; */"
119    print >>f, "      b = limm;"
120    print >>f, "   }"
121    print >>f, "   else"
122    print >>f, "   {"
123    print >>f, "      b = m_regs[breg];"
124    print >>f, "   }"
173    print >>f, "   UINT32 c;"
174    if breg_is_dst_only == 0:
175        print >>f, "   UINT32 b;"
176        print >>f, "   "
177        print >>f, "   /* is having b as LIMM valid here? LIMM vs. fixed u6 value makes no sense */"
178        print >>f, "   if (breg == LIMM_REG)"
179        print >>f, "   {"
180        print >>f, "      GET_LIMM_32;"
181        print >>f, "      size = 8;"
182        print >>f, "/*      got_limm = 1; */"
183        print >>f, "      b = limm;"
184        print >>f, "   }"
185        print >>f, "   else"
186        print >>f, "   {"
187        print >>f, "      b = m_regs[breg];"
188        print >>f, "   }"
189   
125190    print >>f, "    "
126191    print >>f, "    c = (UINT32)S;"
127192    print >>f, "   "
128193    print >>f, "   /* 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?) */"
129194    print >>f, "   %s" % (opexecute)
130195    print >>f, "   "
131    print >>f, "   if (F)"
132    print >>f, "   {"
133    print >>f, "      arcompact_fatal(\"arcompact_handle%s_p01 (%s) (F set)\\n\"); // not yet supported" % (funcname, opname)
134    print >>f, "   }"
196    EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler)
135197    print >>f, "   return m_pc + (size >> 0);"
136198    print >>f, "}"
137199    print >>f, ""
r242581r242582
182244    sys.exit(1)
183245
184246
185EmitGroup04(f, "04_00", "ADD", "m_regs[areg] = b + c;" )
247EmitGroup04(f, "04_00", "ADD", "UINT32 result = b + c; m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
186248
187EmitGroup04(f, "04_02", "SUB", "m_regs[areg] = b - c;" )
249EmitGroup04(f, "04_02", "SUB", "UINT32 result = b - c; m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
188250
189EmitGroup04(f, "04_04", "AND", "m_regs[areg] = b & c;" )
190EmitGroup04(f, "04_05", "OR",  "m_regs[areg] = b | c;" )
191EmitGroup04(f, "04_06", "BIC", "m_regs[areg] = b & (~c);" )
192EmitGroup04(f, "04_07", "XOR", "m_regs[areg] = b ^ c;" )
251EmitGroup04(f, "04_04", "AND", "UINT32 result = b & c; m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags  )
252EmitGroup04(f, "04_05", "OR",  "UINT32 result = b | c; m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags  )
253EmitGroup04(f, "04_06", "BIC", "UINT32 result = b & (~c); m_regs[areg] = result;",  0,0, -1, EmitGroup04_unsupported_Flags  )
254EmitGroup04(f, "04_07", "XOR", "UINT32 result = b ^ c; m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags  )
193255
194EmitGroup04(f, "04_0f", "BSET", "m_regs[areg] = b | (1 << (c & 0x1f));" )
256EmitGroup04(f, "04_0a", "MOV", "UINT32 result = c; m_regs[breg] = result;", 1,1, -1, EmitGroup04_Handle_NZ_Flags )
195257
196EmitGroup04(f, "04_15", "ADD2", "m_regs[areg] = b + (c << 2);" )
197EmitGroup04(f, "04_16", "ADD3", "m_regs[areg] = b + (c << 3);" )
258EmitGroup04(f, "04_0f", "BSET", "UINT32 result = b | (1 << (c & 0x1f)); m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags  )
198259
260EmitGroup04(f, "04_15", "ADD2", "UINT32 result = b + (c << 2); m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags  )
261EmitGroup04(f, "04_16", "ADD3", "UINT32 result = b + (c << 3); m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags  )
199262
200EmitGroup04(f, "05_00", "ASL", "m_regs[areg] = b << (c&0x1f);" )
201EmitGroup04(f, "05_01", "LSR", "m_regs[areg] = b >> (c&0x1f);" )
202263
264EmitGroup04(f, "05_00", "ASL", "UINT32 result = b << (c&0x1f); m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags  )
265EmitGroup04(f, "05_01", "LSR", "UINT32 result = b >> (c&0x1f); m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags  )
266
203267#  xxx_S b, b, u5 format opcodes
204268EmitGroup17(f, "17_00", "ASL_S",  "m_regs[breg] = m_regs[breg] << (u&0x1f);" )
205269EmitGroup17(f, "17_01", "LSR_S",  "m_regs[breg] = m_regs[breg] >> (u&0x1f);" )


Previous 199869 Revisions Next


© 1997-2024 The MAME Team