Inaccuracies in DAA exact behavior documentation
Closed this issue · 0 comments
In v0.9.0 documentation, there are a couple of problems in the DAA explanation.
The first problem is the carry flag output. For both addition and subtraction, the carry output should always be based on the condition in step 3 (set if $60 is added to the adjustment, reset otherwise). Incidentally, for subtraction, this means it always preserves the carry flag, which might be worth mentioning.
The second problem is in the condition in step 3 for addition. "If the carry flag is set or A > $9F" should be "If the carry flag is set or A > $99". Comparing to $9F would only be valid if the adjustment value from step 2 was already added to A and the carry-out from that was also OR'd into the carry flag. Comparing to $99, on the other hand, handles this case cleanly because values between $9A and $9F always have an adjustment of $6 in step 2, and if it were added to A it would then be greater than $9F.