Previous 199869 Revisions Next

r34072 Friday 26th December, 2014 at 21:34:33 UTC by David Haywood
arcompact (nw)
[src/emu/cpu/arcompact]arcompact_execute.c arcompact_make.py arcompactdasm_ops.c

trunk/src/emu/cpu/arcompact/arcompact_execute.c
r242583r242584
135135   {
136136      case 0x00: return 1; // AL
137137      case 0x01: return CONDITION_EQ;
138
139      case 0x02: fatalerror("unhandled condition check %s", conditions[condition]); return -1;
138      case 0x02: return !CONDITION_EQ; // NE
140139      case 0x03: fatalerror("unhandled condition check %s", conditions[condition]); return -1;
141140      case 0x04: fatalerror("unhandled condition check %s", conditions[condition]); return -1;
142141      case 0x05: fatalerror("unhandled condition check %s", conditions[condition]); return -1;
r242583r242584
11441143ARCOMPACT_RETTYPE arcompact_device::arcompact_handle00_00(OPS_32)
11451144{
11461145   int size = 4;
1146
1147   COMMON32_GET_CONDITION
1148
1149   if (!check_condition(condition))
1150      return m_pc + (size>>0);
1151
11471152   // Branch Conditionally
1148   arcompact_log("unimplemented Bcc %08x", op);
1153   // 0000 0sss ssss sss0 SSSS SSSS SSNQ QQQQ
1154   INT32 address = (op & 0x07fe0000) >> 17;
1155   address |= ((op & 0x0000ffc0) >> 6) << 10;
1156   if (address & 0x80000) address = -0x80000 + (address & 0x7ffff);
1157   int n = (op & 0x00000020) >> 5; op &= ~0x00000020;
1158
1159   UINT32 realaddress = PC_ALIGNED32 + (address * 2);
1160
1161   if (n)
1162   {
1163      m_delayactive = 1;
1164      m_delayjump = realaddress;
1165      m_delaylinks = 0; // don't link
1166   }
1167   else
1168   {
1169   //   m_regs[REG_BLINK] = m_pc + (size >> 0);  // don't link
1170      return realaddress;
1171   }
1172
1173
11491174   return m_pc + (size>>0);
11501175}
11511176
r242583r242584
22192244ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_2f_05(OPS_32)  { return arcompact_handle04_2f_helper(PARAMS, "SEXB"); } // SEXB
22202245ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_2f_06(OPS_32)  { return arcompact_handle04_2f_helper(PARAMS, "SEXW"); } // SEXW
22212246
2222// EXTB
2223ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_2f_07_p00(OPS_32) // note 'b' destination for 04_2f_07_xx group
2224{
2225   SETUP_HANDLE04_2f_0x_P00;
2226   
2227   m_regs[breg] = c & 0x000000ff;
2228   if (F)
2229   {
2230      arcompact_fatal("arcompact_handle04_2f_08_p00 (EXTW) (F set)\n"); // not yet supported
2231   }
22322247
2233   return m_pc + (size >> 0);
2234}
2235
2236ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_2f_07_p01(OPS_32)
2237{
2238   int size = 4;
2239   arcompact_fatal("arcompact_handle04_2f_07_p01 (EXTB)\n");
2240   return m_pc + (size >> 0);
2241}
2242
2243ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_2f_07_p10(OPS_32)
2244{
2245   int size = 4;
2246   arcompact_fatal("illegal 04_2f_07_p10 (EXTB)\n"); // illegal mode because 'S' bits have already been used for opcode select
2247   return m_pc + (size >> 0);
2248}
2249
2250ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_2f_07_p11_m0(OPS_32)
2251{
2252   int size = 4;
2253   arcompact_fatal("arcompact_handle04_2f_07_p11_m0 (EXTB)\n");  // illegal mode because 'Q' bits have already been used for opcode select
2254   return m_pc + (size >> 0);
2255}
2256
2257ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_2f_07_p11_m1(OPS_32)
2258{
2259   int size = 4;
2260   arcompact_fatal("arcompact_handle04_2f_07_p11_m1 (EXTB)\n");  // illegal mode because 'Q' bits have already been used for opcode select
2261   return m_pc + (size >> 0);
2262}
2263
22642248// EXTW b <- c  or  EXTW  b <- limm   or EXTW  limm <- c (no result)  or EXTW  limm, limm (invalid?)
22652249ARCOMPACT_RETTYPE arcompact_device::arcompact_handle04_2f_08_p00(OPS_32) // note 'b' destination for 04_2f_08_xx group
22662250{
trunk/src/emu/cpu/arcompact/arcompact_make.py
r242583r242584
3232        flaghandler(f, funcname, opname)
3333        print >>f, "   }"
3434
35def EmitGroup04(f,funcname, opname, opexecute, ignore_a, breg_is_dst_only, flagcondition, flaghandler):
35def EmitGroup04(f,funcname, opname, opexecute, opwrite, opwrite_alt, ignore_a, breg_is_dst_only, flagcondition, flaghandler):
3636    # the mode 0x00 handler 
3737    print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p00(OPS_32)" % (funcname)
3838    print >>f, "{"
r242583r242584
5353        print >>f, "   COMMON32_GET_areg;"
5454    elif ignore_a == 1:
5555       print >>f, "     //COMMON32_GET_areg; // areg is reserved / not used"
56   
56    elif ignore_a == 2:
57       print >>f, "     //COMMON32_GET_areg; // areg bits already used as opcode select"
58 
5759    print >>f, "   "
5860   
5961    print >>f, "   UINT32 c;"
r242583r242584
8991    print >>f, "   /* todo: is the limm, limm syntax valid? (it's pointless.) */"
9092    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?) */"
9193    print >>f, "   %s" % (opexecute)
94    print >>f, "   %s" % (opwrite)   
9295    print >>f, "   "
9396    EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler)
9497    print >>f, "   return m_pc + (size >> 0);"
r242583r242584
116119        print >>f, "   COMMON32_GET_areg;"
117120    elif ignore_a == 1:
118121       print >>f, "     //COMMON32_GET_areg; // areg is reserved / not used"
122    elif ignore_a == 2:
123       print >>f, "     //COMMON32_GET_areg; // areg bits already used as opcode select"
119124   
120125    print >>f, "   "
121126   
r242583r242584
141146    print >>f, "   "
142147    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?) */"
143148    print >>f, "   %s" % (opexecute)
149    print >>f, "   %s" % (opwrite)   
144150    print >>f, "   "
145151    EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler)
146152    print >>f, "   return m_pc + (size >> 0);"
r242583r242584
149155    print >>f, ""
150156    # the mode 0x10 handler
151157    print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p10(OPS_32)" % (funcname)
152    print >>f, "{"
153    print >>f, "   int size = 4;"
154
155    if breg_is_dst_only == 0:
156        print >>f, "   UINT32 limm = 0;"
158    if ignore_a == 2:
159        print >>f, "{"
160        print >>f, "   int size = 4;"
161        print >>f, "   arcompact_fatal(\"illegal arcompact_handle%s_p10 (ares bits already used as opcode select, can't be used as s12) (%s)\\n\");"  % (funcname, opname)
162        print >>f, "   return m_pc + (size >> 0);"
163        print >>f, "}"
164    else:
165        print >>f, "{"
166        print >>f, "   int size = 4;"
167        if breg_is_dst_only == 0:
168            print >>f, "   UINT32 limm = 0;"
169       
170        print >>f, "/*   int got_limm = 0; */"
171        print >>f, "   "
172        print >>f, "   COMMON32_GET_breg;"
157173   
158    print >>f, "/*   int got_limm = 0; */"
159    print >>f, "   "
160    print >>f, "   COMMON32_GET_breg;"
161
162    if flagcondition == -1:   
163        print >>f, "   COMMON32_GET_F;"
164   
165    print >>f, "   COMMON32_GET_s12;"
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   
172    print >>f, "   "
173    print >>f, "   UINT32 c;"
174    if breg_is_dst_only == 0:
175        print >>f, "   UINT32 b;"
174        if flagcondition == -1:   
175            print >>f, "   COMMON32_GET_F;"
176       
177        print >>f, "   COMMON32_GET_s12;"
178       
179        # areg can't be used here, it's used for s12 bits
180       
176181        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   
190    print >>f, "    "
191    print >>f, "    c = (UINT32)S;"
192    print >>f, "   "
193    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?) */"
194    print >>f, "   %s" % (opexecute)
195    print >>f, "   "
196    EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler)
197    print >>f, "   return m_pc + (size >> 0);"
198    print >>f, "}"
199    print >>f, ""
200    print >>f, ""
182        print >>f, "   UINT32 c;"
183        if breg_is_dst_only == 0:
184            print >>f, "   UINT32 b;"
185            print >>f, "   "
186            print >>f, "   /* is having b as LIMM valid here? LIMM vs. fixed u6 value makes no sense */"
187            print >>f, "   if (breg == LIMM_REG)"
188            print >>f, "   {"
189            print >>f, "      GET_LIMM_32;"
190            print >>f, "      size = 8;"
191            print >>f, "/*      got_limm = 1; */"
192            print >>f, "      b = limm;"
193            print >>f, "   }"
194            print >>f, "   else"
195            print >>f, "   {"
196            print >>f, "      b = m_regs[breg];"
197            print >>f, "   }"
198       
199        print >>f, "    "
200        print >>f, "    c = (UINT32)S;"
201        print >>f, "   "
202        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?) */"
203        print >>f, "   %s" % (opexecute)
204        print >>f, "   %s" % (opwrite_alt)   
205        print >>f, "   "
206        EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler)
207        print >>f, "   return m_pc + (size >> 0);"
208        print >>f, "}"
209        print >>f, ""
210        print >>f, ""
201211    # the mode 0x11 m0 handler   
202212    print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p11_m0(OPS_32)" % (funcname)
203    print >>f, "{"
204    print >>f, "   int size = 4;"
205    print >>f, "   arcompact_fatal(\"arcompact_handle%s_p11_m0 (%s)\\n\");"  % (funcname, opname)
206    print >>f, "   return m_pc + (size >> 0);"
207    print >>f, "}"
208    print >>f, ""
209    print >>f, ""   
213    if ignore_a == 2:
214        print >>f, "{"
215        print >>f, "   int size = 4;"
216        print >>f, "   arcompact_fatal(\"illegal arcompact_handle%s_p11_m0 (ares bits already used as opcode select, can't be used as Q condition) (%s)\\n\");"  % (funcname, opname)
217        print >>f, "   return m_pc + (size >> 0);"
218        print >>f, "}"
219    else:
220        print >>f, "{"
221        print >>f, "   int size = 4;"
222        print >>f, "   arcompact_fatal(\"arcompact_handle%s_p11_m0 (%s)\\n\");"  % (funcname, opname)
223        print >>f, "   return m_pc + (size >> 0);"
224        print >>f, "}"
225        print >>f, ""
226        print >>f, ""   
210227    # the mode 0x11 m1 handler   
211228    print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p11_m1(OPS_32)" % (funcname)
212    print >>f, "{"
213    print >>f, "   int size = 4;"
214    print >>f, "   arcompact_fatal(\"arcompact_handle%s_p11_m1 (%s)\\n\");"  % (funcname, opname)
215    print >>f, "   return m_pc + (size >> 0);"
216    print >>f, "}"
217    print >>f, ""
218    print >>f, ""
229    if ignore_a == 2:
230        print >>f, "{"
231        print >>f, "   int size = 4;"
232        print >>f, "   arcompact_fatal(\"illegal arcompact_handle%s_p11_m1 (ares bits already used as opcode select, can't be used as Q condition) (%s)\\n\");"  % (funcname, opname)
233        print >>f, "   return m_pc + (size >> 0);"
234        print >>f, "}"
235    else:
236        print >>f, "{"
237        print >>f, "   int size = 4;"
238        print >>f, "   arcompact_fatal(\"arcompact_handle%s_p11_m1 (%s)\\n\");"  % (funcname, opname)
239        print >>f, "   return m_pc + (size >> 0);"
240        print >>f, "}"
241        print >>f, ""
242        print >>f, ""
219243
220244#  xxx_S b, b, u5 format opcodes
221245def EmitGroup17(f,funcname, opname, opexecute):
r242583r242584
244268    sys.exit(1)
245269
246270
247EmitGroup04(f, "04_00", "ADD", "UINT32 result = b + c; m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
271EmitGroup04(f, "04_00", "ADD", "UINT32 result = b + c;", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags )
248272
249EmitGroup04(f, "04_02", "SUB", "UINT32 result = b - c; m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags  )
273EmitGroup04(f, "04_02", "SUB", "UINT32 result = b - c;", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags  )
250274
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  )
275EmitGroup04(f, "04_04", "AND", "UINT32 result = b & c;", "if (areg != LIMM_REG) { m_regs[areg] = result; }", "if (breg != LIMM_REG) { m_regs[breg] = result; }", 0,0, -1, EmitGroup04_Handle_NZ_Flags  )
276EmitGroup04(f, "04_05", "OR",  "UINT32 result = b | c;", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags  )
277EmitGroup04(f, "04_06", "BIC", "UINT32 result = b & (~c);", "m_regs[areg] = result;", "m_regs[breg] = result;",  0,0, -1, EmitGroup04_unsupported_Flags  )
278EmitGroup04(f, "04_07", "XOR", "UINT32 result = b ^ c;", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags  )
255279
256EmitGroup04(f, "04_0a", "MOV", "UINT32 result = c; m_regs[breg] = result;", 1,1, -1, EmitGroup04_Handle_NZ_Flags  )
280EmitGroup04(f, "04_0a", "MOV", "UINT32 result = c;", "m_regs[breg] = result;", "m_regs[breg] = result;", 1,1, -1, EmitGroup04_Handle_NZ_Flags  ) # special case, result always goes to breg
257281
258EmitGroup04(f, "04_0f", "BSET", "UINT32 result = b | (1 << (c & 0x1f)); m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags  )
282EmitGroup04(f, "04_0f", "BSET", "UINT32 result = b | (1 << (c & 0x1f));", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags  )
259283
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  )
284EmitGroup04(f, "04_15", "ADD2", "UINT32 result = b + (c << 2);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags  )
285EmitGroup04(f, "04_16", "ADD3", "UINT32 result = b + (c << 3);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags  )
262286
263287
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  )
288EmitGroup04(f, "05_00", "ASL", "UINT32 result = b << (c&0x1f);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags  )
289EmitGroup04(f, "05_01", "LSR", "UINT32 result = b >> (c&0x1f);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags  )
266290
291# the 04_2f subgroup uses the same encoding, but the areg is already used as sub-opcode select, so any modes relying on areg bits for other reasons (sign, condition) (modes 10, 11m0, 11m1) are illegal.  the destination is also breg not areg
292EmitGroup04(f, "04_2f_07", "EXTB", "UINT32 result = c & 0x000000ff;", "m_regs[breg] = result;","", 2,1, -1, EmitGroup04_unsupported_Flags  ) # no alt handler (invalid path)
293
294
267295#  xxx_S b, b, u5 format opcodes
268296EmitGroup17(f, "17_00", "ASL_S",  "m_regs[breg] = m_regs[breg] << (u&0x1f);" )
269297EmitGroup17(f, "17_01", "LSR_S",  "m_regs[breg] = m_regs[breg] >> (u&0x1f);" )
trunk/src/emu/cpu/arcompact/arcompactdasm_ops.c
r242583r242584
129129   // 0000 0sss ssss sss0 SSSS SSSS SSNQ QQQQ
130130   INT32 address = (op & 0x07fe0000) >> 17;
131131   address |= ((op & 0x0000ffc0) >> 6) << 10;
132   if (address & 0x800000) address = -0x800000 + (address & 0x7fffff);
132   if (address & 0x80000) address = -0x80000 + (address & 0x7ffff);
133133   int n = (op & 0x00000020) >> 5; op &= ~0x00000020;
134134   COMMON32_GET_CONDITION
135135


Previous 199869 Revisions Next


© 1997-2024 The MAME Team