emu8051
emu8051 copied to clipboard
Incorrect setting of AC flag
https://github.com/jarikomppa/emu8051/blob/5dc681275151c4a5d7b85ec9ff4ceb1b25abd5a8/opcodes.c#L138
From my understanding of the datasheet, it is incorrect. AC is set when there is a carry from low nibble to high nibble. I propose to rewrite this line in the following way:
bool auxcarry = ((value1 & 15) + (value2 & 15) + carryin) >> 4;