cpu/decoder - Implement DAA
This is a best effort implementation, possible quirks of the actual hardware have not been considered.
This commit is contained in:
parent
2d4daf821e
commit
3d244d1ec0
1 changed files with 15 additions and 1 deletions
|
@ -427,7 +427,21 @@ void Cpu::executeInstruction()
|
|||
state.halfcarry = false;
|
||||
break;
|
||||
|
||||
// TODO: case 0x27: break; // DAA
|
||||
case 0x27: // DAA
|
||||
{
|
||||
u16 corr = 0;
|
||||
if (state.halfcarry || ((state.A & 0x0F) > 0x9))
|
||||
corr |= 0x06;
|
||||
if ((state.A & 0xF0) > 0x90)
|
||||
corr |= 0x06;
|
||||
|
||||
u32 res16 = (u16)state.A + (state.subtract ? (-corr) : corr);
|
||||
state.A = (u8)res16;
|
||||
state.halfcarry = false;
|
||||
state.zero = (state.A == 0);
|
||||
state.carry = (res16 & 0x100);
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x2F: // CPL Complement accumulator
|
||||
state.A = ~state.A;
|
||||
|
|
Loading…
Reference in a new issue