- FLAG_ASSIGN (BIT_V, 0x80 & ((regs.A & operand & ~result)
- | (~regs.A & ~operand & result)));
- FLAG_ASSIGN (BIT_H, 0x10 & ((regs.A & operand)
- | (operand & ~result)
- | (~result & regs.A)));
- FLAG_ASSIGN (BIT_C, 0x80 & ((regs.A & operand)
- | (operand & ~result)
- | (~result & regs.A)));
- regs.A = result;
+ FLAG_ASSIGN (BIT_V, 0x80 & (operand1 ^ operand2 ^ result ^ (result >>1)));
+ FLAG_ASSIGN (BIT_C, 0x100 & result);
+ FLAG_ASSIGN (BIT_H, 0x10 & (operand1 ^ operand2 ^ result));
+
+ regs.A = result & 0xff;