First post, by superfury
I've noticed, when running the test386.asm testsuite, that the BCD instructions have some very odd behaviour, comparing to 86box (808x: https://github.com/86Box/86Box/blob/master/src/cpu/808x.c , 286: https://github.com/86Box/86Box/blob/master/sr … u/x86_ops_bcd.h ).
It seems like various oddly mismatched things occur in the real BCD handling (according to getting the testsuite not to fail):
DAA/DAS: Only check for AL>99, never 9F. Carry cleared before and or-ed during the first correction case(borrow or carry during the add/substract). High correction case (>99h) doesn't clear carry flag.
AAA/AAS: really substracting/adding 0x106 on 286, just 6 on 808x (simulated on 286+). 808x adds 1 to AH after this operation. sign/zero/carry/overflow is from 8-bit addition/substraction operation. The resulting AX register is like it's performed the 0x106 addition/substraction instead of what the flags indicate (which seem to report what the AL+/-6 operation did).
Is this odd behaviour somehow correct on 286+ machines? Doesn't that mean that since on 808x no carry from the low byte substracting 6 into the high byte occurs, the result in AX is different on a 808x?
Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io