cpu/decoder - Unify code for ALU n ops
This commit is contained in:
parent
9bc6f935ac
commit
a8edf40b96
1 changed files with 6 additions and 16 deletions
|
@ -97,6 +97,12 @@ void Cpu::executeInstruction()
|
|||
|
||||
aluop8(aluop, rhs);
|
||||
}
|
||||
else if((op & 0xC7) == 0xC6) // ADD n, ADC n, SUB n, SBC n, AND n, XOR n, OR n, CP n
|
||||
{
|
||||
AluOp aluop = (AluOp)((op >> 3) & 0x3);
|
||||
aluop8(aluop, readPC8());
|
||||
mcycles = 2;
|
||||
}
|
||||
else if((op & 0xC6) == 0x04) // INC r; INC [HL]; DEC r; DEC [HL];
|
||||
{
|
||||
AluOp aluop = (op & 0x1) ? SUB : ADD;
|
||||
|
@ -387,22 +393,6 @@ void Cpu::executeInstruction()
|
|||
bus->write16(readPC16(), state.SP); mcycles = 5; break;
|
||||
case 0xF9: // LD SP, HL
|
||||
state.SP = state.HL; mcycles = 2; break;
|
||||
case 0xC6: // ADD n
|
||||
aluop8(ADD, readPC8()); mcycles = 2; break;
|
||||
case 0xD6: // SUB n
|
||||
aluop8(SUB, readPC8()); mcycles = 2; break;
|
||||
case 0xE6: // AND n
|
||||
aluop8(AND, readPC8()); mcycles = 2; break;
|
||||
case 0xF6: // OR n
|
||||
aluop8(OR, readPC8()); mcycles = 2; break;
|
||||
case 0xCE: // ADC n
|
||||
aluop8(ADC, readPC8()); mcycles = 2; break;
|
||||
case 0xDE: // SBC n
|
||||
aluop8(SBC, readPC8()); mcycles = 2; break;
|
||||
case 0xEE: // XOR n
|
||||
aluop8(XOR, readPC8()); mcycles = 2; break;
|
||||
case 0xFE: // CP n
|
||||
aluop8(CP, readPC8()); mcycles = 2; break;
|
||||
case 0x3F: // CCF complement carry flag
|
||||
state.carry = !state.carry;
|
||||
state.subtract = false;
|
||||
|
|
Loading…
Reference in a new issue