src/emu/cpu/f8/f8.c
| r15686 | r15687 | |
| 1159 | 1159 | ***************************************************/ |
| 1160 | 1160 | static void f8_amd(f8_Regs *cpustate) |
| 1161 | 1161 | { |
| 1162 | | UINT8 tmp = cpustate->a - 0x66, adj = 0x00; |
| 1163 | | int sum; |
| 1162 | |
| 1163 | /*SKR from F8 Guide To programming description of AMD |
| 1164 | |
| 1165 | binary add the addend to the binary sum of the augend and $66 |
| 1166 | *NOTE* the binary addition of the augend to $66 is done before AMD is called |
| 1167 | record the status of the carry and intermediate carry |
| 1168 | add a factor to the sum based on the carry and intermediate carry: |
| 1169 | no carry, no intermediate carry, add $AA |
| 1170 | no carry, intermediate carry, add $A0 |
| 1171 | carry, no intermediate carry, add $0A |
| 1172 | carry, intermediate carry, add $00 |
| 1173 | any carry from the low-order digit is suppressed |
| 1174 | *NOTE* status flags are updated prior to the factor being added |
| 1175 | */ |
| 1176 | |
| 1177 | UINT8 augend=cpustate->a; |
| 1164 | 1178 | ROMC_02(cpustate); |
| 1165 | | sum = (tmp & 0x0f) + (cpustate->dbus & 0x0f); |
| 1166 | | if (sum > 0x09) |
| 1167 | | adj += 0x06; |
| 1168 | | sum = tmp + cpustate->dbus + adj; |
| 1169 | | if (sum > 0x99) |
| 1170 | | adj += 0x60; |
| 1171 | | tmp += adj; |
| 1179 | UINT8 addend=cpustate->dbus; |
| 1180 | UINT8 tmp=addend+augend; |
| 1181 | |
| 1182 | UINT8 c=0; /* high order carry */ |
| 1183 | UINT8 ic=0; /* low order carry */ |
| 1184 | if(((augend+addend)&0xff0)>0xf0) |
| 1185 | c=1; |
| 1186 | if((augend&0x0f)+(addend&0x0f)>0x0F) |
| 1187 | ic=1; |
| 1188 | |
| 1172 | 1189 | CLR_OZCS; |
| 1173 | | SET_OC(tmp,cpustate->dbus); |
| 1174 | | cpustate->a = tmp + cpustate->dbus; |
| 1175 | | SET_SZ(cpustate->a); |
| 1190 | SET_OC(augend,addend); |
| 1191 | SET_SZ(tmp); |
| 1192 | |
| 1193 | if(c==0&&ic==0) |
| 1194 | tmp=((tmp+0xa0)&0xf0)+((tmp+0x0a)&0x0f); |
| 1195 | if(c==0&&ic==1) |
| 1196 | tmp=((tmp+0xa0)&0xf0)+(tmp&0x0f); |
| 1197 | if(c==1&&ic==0) |
| 1198 | tmp=(tmp&0xf0)+((tmp+0x0a)&0x0f); |
| 1199 | |
| 1200 | cpustate->a = tmp; |
| 1176 | 1201 | } |
| 1177 | 1202 | |
| 1178 | 1203 | /*************************************************** |
| r15686 | r15687 | |
| 1364 | 1389 | ***************************************************/ |
| 1365 | 1390 | static void f8_asd(f8_Regs *cpustate, int r) |
| 1366 | 1391 | { |
| 1367 | | UINT8 tmp = cpustate->a - 0x66, adj = 0x00; |
| 1368 | | int sum; |
| 1369 | | ROMC_1C(cpustate, cS); |
| 1370 | | sum = (tmp & 0x0f) + (cpustate->r[r] & 0x0f); |
| 1371 | | if (sum > 0x09) |
| 1372 | | adj += 0x06; |
| 1373 | | sum = tmp + cpustate->r[r] + adj; |
| 1374 | | if (sum > 0x99) |
| 1375 | | adj += 0x60; |
| 1376 | | tmp += adj; |
| 1377 | | CLR_OZCS; |
| 1378 | | SET_OC(tmp, cpustate->r[r]); |
| 1379 | | cpustate->a = tmp + cpustate->r[r]; |
| 1380 | | SET_SZ(cpustate->a); |
| 1392 | /*SKR from F8 Guide To programming description of AMD */ |
| 1393 | UINT8 augend=cpustate->a; |
| 1394 | ROMC_1C(cpustate, cS); |
| 1395 | UINT8 addend=cpustate->r[r]; |
| 1396 | UINT8 tmp=augend+addend; |
| 1397 | |
| 1398 | UINT8 c=0; |
| 1399 | UINT8 ic=0; |
| 1400 | if(((augend+addend)&0xff0)>0xf0) |
| 1401 | c=1; |
| 1402 | if((augend&0x0f)+(addend&0x0f)>0x0F) |
| 1403 | ic=1; |
| 1404 | |
| 1405 | CLR_OZCS; |
| 1406 | SET_OC(augend,addend); |
| 1407 | SET_SZ(tmp); |
| 1408 | |
| 1409 | if(c==0&&ic==0) |
| 1410 | tmp=((tmp+0xa0)&0xf0)+((tmp+0x0a)&0x0f); |
| 1411 | if(c==0&&ic==1) |
| 1412 | tmp=((tmp+0xa0)&0xf0)+(tmp&0x0f); |
| 1413 | if(c==1&&ic==0) |
| 1414 | tmp=(tmp&0xf0)+((tmp+0x0a)&0x0f); |
| 1415 | |
| 1416 | cpustate->a = tmp; |
| 1381 | 1417 | } |
| 1382 | 1418 | |
| 1383 | 1419 | /*************************************************** |
| r15686 | r15687 | |
| 1386 | 1422 | ***************************************************/ |
| 1387 | 1423 | static void f8_asd_isar(f8_Regs *cpustate) |
| 1388 | 1424 | { |
| 1389 | | UINT8 tmp = cpustate->a - 0x66, adj = 0x00; |
| 1390 | | int sum; |
| 1391 | | ROMC_1C(cpustate, cS); |
| 1392 | | sum = (tmp & 0x0f) + (cpustate->r[cpustate->is] & 0x0f); |
| 1393 | | if (sum > 0x09) |
| 1394 | | adj += 0x06; |
| 1395 | | sum = tmp + cpustate->r[cpustate->is] + adj; |
| 1396 | | if (sum > 0x99) |
| 1397 | | adj += 0x60; |
| 1398 | | tmp += adj; |
| 1399 | | CLR_OZCS; |
| 1400 | | SET_OC(tmp, cpustate->r[cpustate->is]); |
| 1401 | | cpustate->a = tmp + cpustate->r[cpustate->is]; |
| 1402 | | SET_SZ(cpustate->a); |
| 1425 | /*SKR from F8 Guide To programming description of AMD */ |
| 1426 | UINT8 augend=cpustate->a; |
| 1427 | ROMC_1C(cpustate, cS); |
| 1428 | UINT8 addend=cpustate->r[cpustate->is]; |
| 1429 | UINT8 tmp=augend+addend; |
| 1430 | |
| 1431 | UINT8 c=0; |
| 1432 | UINT8 ic=0; |
| 1433 | if(((augend+addend)&0xff0)>0xf0) |
| 1434 | c=1; |
| 1435 | if((augend&0x0f)+(addend&0x0f)>0x0F) |
| 1436 | ic=1; |
| 1437 | |
| 1438 | CLR_OZCS; |
| 1439 | SET_OC(augend,addend); |
| 1440 | SET_SZ(tmp); |
| 1441 | |
| 1442 | if(c==0&&ic==0) |
| 1443 | tmp=((tmp+0xa0)&0xf0)+((tmp+0x0a)&0x0f); |
| 1444 | if(c==0&&ic==1) |
| 1445 | tmp=((tmp+0xa0)&0xf0)+(tmp&0x0f); |
| 1446 | if(c==1&&ic==0) |
| 1447 | tmp=(tmp&0xf0)+((tmp+0x0a)&0x0f); |
| 1448 | |
| 1449 | cpustate->a = tmp; |
| 1403 | 1450 | } |
| 1404 | 1451 | |
| 1405 | 1452 | /*************************************************** |
| r15686 | r15687 | |
| 1408 | 1455 | ***************************************************/ |
| 1409 | 1456 | static void f8_asd_isar_i(f8_Regs *cpustate) |
| 1410 | 1457 | { |
| 1411 | | UINT8 tmp = cpustate->a - 0x66, adj = 0x00; |
| 1412 | | int sum; |
| 1413 | | ROMC_1C(cpustate, cS); |
| 1414 | | sum = (tmp & 0x0f) + (cpustate->r[cpustate->is] & 0x0f); |
| 1415 | | if (sum > 0x09) |
| 1416 | | adj += 0x06; |
| 1417 | | sum = tmp + cpustate->r[cpustate->is] + adj; |
| 1418 | | if (sum > 0x99) |
| 1419 | | adj += 0x60; |
| 1420 | | tmp += adj; |
| 1421 | | CLR_OZCS; |
| 1422 | | SET_OC(tmp, cpustate->r[cpustate->is]); |
| 1423 | | cpustate->a = tmp + cpustate->r[cpustate->is]; |
| 1424 | | SET_SZ(cpustate->a); |
| 1425 | | cpustate->is = (cpustate->is & 0x38) | ((cpustate->is + 1) & 0x07); |
| 1458 | /*SKR from F8 Guide To programming description of AMD */ |
| 1459 | UINT8 augend=cpustate->a; |
| 1460 | ROMC_1C(cpustate, cS); |
| 1461 | UINT8 addend=cpustate->r[cpustate->is]; |
| 1462 | UINT8 tmp=augend+addend; |
| 1463 | |
| 1464 | UINT8 c=0; |
| 1465 | UINT8 ic=0; |
| 1466 | if(((augend+addend)&0xff0)>0xf0) |
| 1467 | c=1; |
| 1468 | if((augend&0x0f)+(addend&0x0f)>0x0F) |
| 1469 | ic=1; |
| 1470 | |
| 1471 | CLR_OZCS; |
| 1472 | SET_OC(augend,addend); |
| 1473 | SET_SZ(tmp); |
| 1474 | |
| 1475 | if(c==0&&ic==0) |
| 1476 | tmp=((tmp+0xa0)&0xf0)+((tmp+0x0a)&0x0f); |
| 1477 | if(c==0&&ic==1) |
| 1478 | tmp=((tmp+0xa0)&0xf0)+(tmp&0x0f); |
| 1479 | if(c==1&&ic==0) |
| 1480 | tmp=(tmp&0xf0)+((tmp+0x0a)&0x0f); |
| 1481 | |
| 1482 | cpustate->a = tmp; |
| 1483 | cpustate->is = (cpustate->is & 0x38) | ((cpustate->is + 1) & 0x07); |
| 1426 | 1484 | } |
| 1427 | 1485 | |
| 1428 | 1486 | /*************************************************** |
| r15686 | r15687 | |
| 1431 | 1489 | ***************************************************/ |
| 1432 | 1490 | static void f8_asd_isar_d(f8_Regs *cpustate) |
| 1433 | 1491 | { |
| 1434 | | UINT8 tmp = cpustate->a - 0x66, adj = 0x00; |
| 1435 | | int sum; |
| 1436 | | ROMC_1C(cpustate, cS); |
| 1437 | | sum = (tmp & 0x0f) + (cpustate->r[cpustate->is] & 0x0f); |
| 1438 | | if (sum > 0x09) |
| 1439 | | adj += 0x06; |
| 1440 | | sum = tmp + cpustate->r[cpustate->is] + adj; |
| 1441 | | if (sum > 0x99) |
| 1442 | | adj += 0x60; |
| 1443 | | tmp += adj; |
| 1444 | | CLR_OZCS; |
| 1445 | | SET_OC(tmp, cpustate->r[cpustate->is]); |
| 1446 | | cpustate->a = tmp + cpustate->r[cpustate->is]; |
| 1447 | | SET_SZ(cpustate->a); |
| 1448 | | cpustate->is = (cpustate->is & 0x38) | ((cpustate->is - 1) & 0x07); |
| 1492 | /*SKR from F8 Guide To programming description of AMD */ |
| 1493 | UINT8 augend=cpustate->a; |
| 1494 | ROMC_1C(cpustate, cS); |
| 1495 | UINT8 addend=cpustate->r[cpustate->is]; |
| 1496 | UINT8 tmp=augend+addend; |
| 1497 | |
| 1498 | UINT8 c=0; |
| 1499 | UINT8 ic=0; |
| 1500 | if(((augend+addend)&0xff0)>0xf0) |
| 1501 | c=1; |
| 1502 | if((augend&0x0f)+(addend&0x0f)>0x0F) |
| 1503 | ic=1; |
| 1504 | |
| 1505 | CLR_OZCS; |
| 1506 | SET_OC(augend,addend); |
| 1507 | SET_SZ(tmp); |
| 1508 | |
| 1509 | if(c==0&&ic==0) |
| 1510 | tmp=((tmp+0xa0)&0xf0)+((tmp+0x0a)&0x0f); |
| 1511 | if(c==0&&ic==1) |
| 1512 | tmp=((tmp+0xa0)&0xf0)+(tmp&0x0f); |
| 1513 | if(c==1&&ic==0) |
| 1514 | tmp=(tmp&0xf0)+((tmp+0x0a)&0x0f); |
| 1515 | |
| 1516 | cpustate->a = tmp; |
| 1517 | cpustate->is = (cpustate->is & 0x38) | ((cpustate->is - 1) & 0x07); |
| 1449 | 1518 | } |
| 1450 | 1519 | |
| 1451 | 1520 | /*************************************************** |