Some more optimisations, up to 225Mhz now.

Reordered if statements to give "then" case "expected"
Better use of "__assume" in switch statements

Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian.Conlon 2017-06-29 21:25:58 +01:00
parent 10ed04bf90
commit 3439523865

View File

@ -778,12 +778,15 @@ int EightBit::Z80::execute(uint8_t opcode) {
auto p = decoded.p; auto p = decoded.p;
auto q = decoded.q; auto q = decoded.q;
if (m_prefixCB) auto prefixed = m_prefixCB || m_prefixED;
executeCB(x, y, z); if (!prefixed) {
else if (m_prefixED)
executeED(x, y, z, p, q);
else
executeOther(x, y, z, p, q); executeOther(x, y, z, p, q);
} else {
if (m_prefixCB)
executeCB(x, y, z);
else if (m_prefixED)
executeED(x, y, z, p, q);
}
if (cycles == 0) if (cycles == 0)
throw std::logic_error("Unhandled opcode"); throw std::logic_error("Unhandled opcode");
@ -822,20 +825,16 @@ void EightBit::Z80::executeCB(int x, int y, int z) {
adjustSZP<Z80>(f, m_displaced ? R2(z, a) = srl(f, DISPLACED()) : srl(f, R(z, a))); adjustSZP<Z80>(f, m_displaced ? R2(z, a) = srl(f, DISPLACED()) : srl(f, R(z, a)));
break; break;
} }
if (m_displaced) { if (!m_displaced) {
cycles += 23;
} else {
cycles += 8; cycles += 8;
if (z == 6) if (z == 6)
cycles += 7; cycles += 7;
} else {
cycles += 23;
} }
break; break;
case 1: // BIT y, r[z] case 1: // BIT y, r[z]
if (m_displaced) { if (!m_displaced) {
bit(f, y, DISPLACED());
adjustXY<Z80>(f, MEMPTR().high);
cycles += 20;
} else {
auto operand = bit(f, y, R(z, a)); auto operand = bit(f, y, R(z, a));
cycles += 8; cycles += 8;
if (z == 6) { if (z == 6) {
@ -844,30 +843,36 @@ void EightBit::Z80::executeCB(int x, int y, int z) {
} else { } else {
adjustXY<Z80>(f, operand); adjustXY<Z80>(f, operand);
} }
} else {
bit(f, y, DISPLACED());
adjustXY<Z80>(f, MEMPTR().high);
cycles += 20;
} }
break; break;
case 2: // RES y, r[z] case 2: // RES y, r[z]
if (m_displaced) { if (!m_displaced) {
R2(z, a) = res(y, DISPLACED());
cycles += 23;
} else {
res(y, R(z, a)); res(y, R(z, a));
cycles += 8; cycles += 8;
if (z == 6) if (z == 6)
cycles += 7; cycles += 7;
} else {
R2(z, a) = res(y, DISPLACED());
cycles += 23;
} }
break; break;
case 3: // SET y, r[z] case 3: // SET y, r[z]
if (m_displaced) { if (!m_displaced) {
R2(z, a) = set(y, DISPLACED());
cycles += 23;
} else {
set(y, R(z, a)); set(y, R(z, a));
cycles += 8; cycles += 8;
if (z == 6) if (z == 6)
cycles += 7; cycles += 7;
} else {
R2(z, a) = set(y, DISPLACED());
cycles += 23;
} }
break; break;
default:
__assume(0);
} }
} }
@ -1380,8 +1385,9 @@ void EightBit::Z80::executeOther(int x, int y, int z, int p, int q) {
default: default:
__assume(0); __assume(0);
} }
////default: break;
//// __assume(0); default:
__assume(0);
} }
break; break;
case 2: // Conditional jump case 2: // Conditional jump
@ -1462,8 +1468,9 @@ void EightBit::Z80::executeOther(int x, int y, int z, int p, int q) {
default: default:
__assume(0); __assume(0);
} }
////default: break;
//// __assume(0); default:
__assume(0);
} }
break; break;
case 6: // Operate on accumulator and immediate operand: alu[y] n case 6: // Operate on accumulator and immediate operand: alu[y] n