Isn't a 16-bit quotient of +65535 actually an arithmetic overflow, as DIV is doing signed division?DIV has implementation-specific results when the result overflows, but the custom divide10 code specifically never overflows, it either divides &0000nnnn by 10, which will never overflow the maximum being 6553, or it divides up to a maximum of &0009FFFF by 10, the maximum remainder from dividing by 10, which is 655359, so will never overflow the maximum result being 65535.
The emulation code tests for quotients in the range -32768 -> +32767
Code:
if (quo < -0x8000 || quo > 0x7fff) { cpu.PS |= FLAGV; // J11,11/70 compat
In this case, the R[n], R[n|1] register value are undefined, and actually remain unchanged.
Do you see an error here?
Dave
Statistics: Posted by hoglet — Mon Oct 28, 2024 10:21 pm