3 ms·
The rationale probably is that you can easily check for division by zero before doing the actual division, whereas checking for an overflowing division requires
by layer8 4y ago
The rationale probably is that you can easily check for division by zero before doing the actual division, whereas checking for an overflowing division requires to actually perform the division. The DIVU instruction thus allows to check for overflow without the overhead of raising an exception.
It certainly is a bit of a footgun, because one normally doesn’t expect overflow on integer division. On the other hand, the other basic arithmetic operations all require overflow checks as well, or equivalent operand value analysis. And this is assembly we’re talking about, where you’re supposed to know what you’re doing.