ProcessorTests icon indicating copy to clipboard operation
ProcessorTests copied to clipboard

8088: Thoughts on division

Open dbalsom opened this issue 2 months ago • 0 comments

A number of people who have used the 8088 tests have struggled validating division. The main issue is the division exceptions that occur, which results in the flag register with several undefined flags getting pushed to the stack.

Even my own emulator doesn't implement all the undefined flags for division, which get set based on a temporary value within the division microcode loop, so aren't easily predictable. When I validate these tests myself, I detect the flag push and mask the flags on the stack. This of course adds complexity to using the tests, and I can't expect everyone to want to do it.

As a side effect of choosing random operands, a full 75% of the division tests end up being exceptions, which seems high, and if we're skipping exceptions due to the aforementioned annoyance then we really have far fewer arithmetic tests than desired.

A few possibilities here:

  • We could weight the random operands to hold exceptions to some maximum percentage of total tests, perhaps no more than 25%
  • We could publish alternate test files for division opcodes which have no exceptions at all.
  • We could do both

Interested to hear people's thoughts.

dbalsom avatar Apr 30 '24 18:04 dbalsom