trunk/src/emu/cpu/arcompact/arcompact_execute.c
| r242513 | r242514 | |
| 1229 | 1229 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle03(OPS_32) |
| 1230 | 1230 | { |
| 1231 | 1231 | int size = 4; |
| 1232 | | //UINT32 limm = 0; |
| 1232 | UINT32 limm = 0; |
| 1233 | 1233 | int got_limm = 0; |
| 1234 | | int S = (op & 0x00008000) >> 15;// op &= ~0x00008000; |
| 1235 | | int s = (op & 0x00ff0000) >> 16;// op &= ~0x00ff0000; |
| 1234 | int S = (op & 0x00008000) >> 15; |
| 1235 | int s = (op & 0x00ff0000) >> 16; |
| 1236 | 1236 | |
| 1237 | 1237 | COMMON32_GET_breg; |
| 1238 | 1238 | COMMON32_GET_creg; |
| 1239 | 1239 | |
| 1240 | 1240 | if (S) s = -0x100 + s; |
| 1241 | 1241 | |
| 1242 | | // int R = (op & 0x00000001) >> 0; op &= ~0x00000001; // bit 0 is reserved |
| 1243 | | int Z = (op & 0x00000006) >> 1; op &= ~0x00000006; |
| 1244 | | int a = (op & 0x00000018) >> 3; op &= ~0x00000018; |
| 1245 | | // int D = (op & 0x00000020) >> 5; op &= ~0x00000020; // we don't use the data cache currently |
| 1242 | // int R = (op & 0x00000001) >> 0; // bit 0 is reserved |
| 1243 | int Z = (op & 0x00000006) >> 1; |
| 1244 | int a = (op & 0x00000018) >> 3; |
| 1245 | // int D = (op & 0x00000020) >> 5; // we don't use the data cache currently |
| 1246 | 1246 | |
| 1247 | |
| 1248 | UINT32 address = m_regs[breg]; |
| 1249 | |
| 1247 | 1250 | if (breg == LIMM_REG) |
| 1248 | 1251 | { |
| 1249 | | //GET_LIMM_32; |
| 1252 | GET_LIMM_32; |
| 1250 | 1253 | size = 8; |
| 1251 | 1254 | got_limm = 1; |
| 1255 | |
| 1256 | address = limm; |
| 1252 | 1257 | } |
| 1253 | 1258 | |
| 1259 | UINT32 writedata = m_regs[creg]; |
| 1260 | |
| 1254 | 1261 | if (creg == LIMM_REG) |
| 1255 | 1262 | { |
| 1256 | 1263 | if (!got_limm) |
| 1257 | 1264 | { |
| 1258 | | //GET_LIMM_32; |
| 1265 | GET_LIMM_32; |
| 1259 | 1266 | size = 8; |
| 1260 | 1267 | } |
| 1268 | |
| 1269 | writedata = limm; |
| 1261 | 1270 | } |
| 1262 | | else |
| 1271 | |
| 1272 | // are LIMM addresses with 's' offset non-0 ('a' mode 0 / 3) legal? |
| 1273 | // not mentioned in docs.. |
| 1274 | |
| 1275 | // address manipulation |
| 1276 | if ((a == 0) || (a == 1)) |
| 1263 | 1277 | { |
| 1264 | | |
| 1278 | address = address + s; |
| 1265 | 1279 | } |
| 1280 | else if (a == 2) |
| 1281 | { |
| 1282 | //address = address; |
| 1283 | } |
| 1284 | else if (a == 3) |
| 1285 | { |
| 1286 | if (Z == 0) |
| 1287 | address = address + (s << 2); |
| 1288 | else if (Z==2) |
| 1289 | address = address + (s << 1); |
| 1290 | else // Z == 1 and Z == 3 are invalid here |
| 1291 | arcompact_fatal("illegal ST %08x (data size %d mode %d)", op, Z, a); |
| 1292 | } |
| 1266 | 1293 | |
| 1294 | // write data |
| 1267 | 1295 | if (Z == 0) |
| 1268 | 1296 | { |
| 1269 | | UINT32 address = m_regs[breg] + s; |
| 1270 | | |
| 1271 | | WRITE32(address>>2, m_regs[creg]); |
| 1297 | WRITE32(address >> 2, writedata); |
| 1272 | 1298 | } |
| 1273 | 1299 | else if (Z == 1) |
| 1274 | 1300 | { |
| 1275 | | arcompact_fatal("illegal ST %08x (data size %d mode %d)", op, Z, a); |
| 1301 | WRITE8(address >> 0, writedata); |
| 1276 | 1302 | } |
| 1277 | 1303 | else if (Z == 2) |
| 1278 | 1304 | { |
| 1305 | WRITE16(address >> 1, writedata); |
| 1306 | } |
| 1307 | else if (Z == 3) |
| 1308 | { // Z == 3 is always illegal |
| 1279 | 1309 | arcompact_fatal("illegal ST %08x (data size %d mode %d)", op, Z, a); |
| 1280 | 1310 | } |
| 1281 | | else |
| 1311 | |
| 1312 | // writeback / increment |
| 1313 | if ((a == 1) || (a == 2)) |
| 1282 | 1314 | { |
| 1283 | | arcompact_fatal("illegal ST %08x (data size %d mode %d)", op, Z, a); |
| 1315 | if (breg==limm) |
| 1316 | arcompact_fatal("illegal ST %08x (data size %d mode %d)", op, Z, a); // using the LIMM as the base register and an increment mode is illegal |
| 1317 | |
| 1318 | m_regs[breg] = m_regs[breg] + s; |
| 1284 | 1319 | } |
| 1285 | 1320 | |
| 1286 | | // todo, handle 'a' increment modes |
| 1287 | | |
| 1288 | 1321 | return m_pc + (size>>0); |
| 1289 | 1322 | |
| 1290 | 1323 | } |
| r242513 | r242514 | |
| 2112 | 2145 | |
| 2113 | 2146 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle0c_helper(OPS_16, const char* optext) |
| 2114 | 2147 | { |
| 2115 | | arcompact_log("unimplemented %s %04x", optext, op); |
| 2148 | arcompact_log("unimplemented %s %04x (0x0c group)", optext, op); |
| 2116 | 2149 | return m_pc + (2 >> 0);; |
| 2117 | 2150 | } |
| 2118 | 2151 | |
| r242513 | r242514 | |
| 2315 | 2348 | |
| 2316 | 2349 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle_ld_helper(OPS_16, const char* optext, int shift, int swap) |
| 2317 | 2350 | { |
| 2318 | | arcompact_log("unimplemented %s %04x", optext, op); |
| 2351 | arcompact_log("unimplemented %s %04x (ld/st group %d %d)", optext, op, shift, swap); |
| 2319 | 2352 | return m_pc + (2 >> 0);; |
| 2320 | 2353 | } |
| 2321 | 2354 | |
| 2322 | 2355 | |
| 2323 | 2356 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle10(OPS_16) |
| 2324 | | { |
| 2325 | | return arcompact_handle_ld_helper(PARAMS, "LD_S", 2, 0); |
| 2357 | { // LD_S c, [b, u7] |
| 2358 | int breg, creg, u; |
| 2359 | |
| 2360 | COMMON16_GET_breg; |
| 2361 | COMMON16_GET_creg; |
| 2362 | COMMON16_GET_u5; |
| 2363 | |
| 2364 | REG_16BIT_RANGE(breg); |
| 2365 | REG_16BIT_RANGE(creg); |
| 2366 | |
| 2367 | u <<= 2; // check |
| 2368 | m_regs[creg] = READ32((m_regs[breg] + u) >> 2); |
| 2369 | |
| 2370 | return m_pc + (2 >> 0); |
| 2326 | 2371 | } |
| 2327 | 2372 | |
| 2328 | 2373 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle11(OPS_16) |
| 2329 | 2374 | { |
| 2330 | | return arcompact_handle_ld_helper(PARAMS, "LDB_S", 0, 0); |
| 2375 | // LDB_S c, [b, u5] |
| 2376 | int breg, creg, u; |
| 2377 | |
| 2378 | COMMON16_GET_breg; |
| 2379 | COMMON16_GET_creg; |
| 2380 | COMMON16_GET_u5; |
| 2381 | |
| 2382 | REG_16BIT_RANGE(breg); |
| 2383 | REG_16BIT_RANGE(creg); |
| 2384 | |
| 2385 | // u <<= 0; // check |
| 2386 | m_regs[creg] = READ8((m_regs[breg] + u) >> 0); |
| 2387 | |
| 2388 | return m_pc + (2 >> 0); |
| 2331 | 2389 | } |
| 2332 | 2390 | |
| 2333 | 2391 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle12(OPS_16) |
| r242513 | r242514 | |
| 2404 | 2462 | |
| 2405 | 2463 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle18_0x_helper(OPS_16, const char* optext, int st) |
| 2406 | 2464 | { |
| 2407 | | arcompact_log("unimplemented %s %04x", optext, op); |
| 2465 | arcompact_log("unimplemented %s %04x (0x18_0x group)", optext, op); |
| 2408 | 2466 | return m_pc + (2 >> 0);; |
| 2409 | 2467 | } |
| 2410 | 2468 | |
| r242513 | r242514 | |
| 2488 | 2546 | |
| 2489 | 2547 | ARCOMPACT_RETTYPE arcompact_device::arcompact_handle19_0x_helper(OPS_16, const char* optext, int shift, int format) |
| 2490 | 2548 | { |
| 2491 | | arcompact_log("unimplemented %s %04x", optext, op); |
| 2549 | arcompact_log("unimplemented %s %04x (0x19_0x group)", optext, op); |
| 2492 | 2550 | return m_pc + (2 >> 0);; |
| 2493 | 2551 | } |
| 2494 | 2552 | |