I'm looking at the specification for the DCPU-16 and I'm having trouble understanding the purpose of the overflow value with the DIV instruction:
DIV a, b - sets a to a/b, sets O to ((a<<16)/b)&0xffff.
Can anybody explain the semantic meaning of O here, what it would be useful for?
It looks like O gives the fractional part of the result (as a fixed-point number). For example, consider 5 / 2:
If you consider O as the 16 binary fractional digits, then this represents the 0.5 fractional part of the result.
Another way of looking at it is the binary result in bits is:
5 / 2 is
As you can tell by inspection, that result is 5 (101 binary) shifted right by one bit into the fractional bits.