m8pple / arch2-2019-cw

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Should division by 0 result in an arithmetic exception?

alexander3605 opened this issue · comments

By looking at this MIPS guide by Cornell University it seems that no exception should occur when dividing by zero
screenshot-2017-11-15 logo_blk eps - mips_vol2 pdf

Yes, it should definitely not report an exception, but what happens instead is pretty
much up to you. What would you prefer it to do?

See also #15

@m8pple
From reading your Exceptions and Errors section of the specification, you mention:
"Arithmetic exception (-10) : Any kind of arithmetic problem, such as overflow, divide by zero, ..."
Should this therefore be corrected as this sort of implies divide by zero would be an arithmetic exception?

Thanks

Any response to this yet?

Divide by zero is a kind of arithmetic exception that can occur, so if it
does occur then it would be given the code -10.

As @alexander3605 points out above, div should not cause an
arithmetic exception.

However, integers are not the only kind of number that MIPS-1 supports.
So if someone decided to support div.s or div.d, then there are situations
where they would need to report an exception due to divide by zero, and
it would be classed as an arithmetic exception because it is a divide-by-zero.

But as our simulator does not support div.s or div.d, dividing by zero should not cause an exception?

Yes - assuming you only support div (which I assume is true of everyone, unless
they got really excited), then there would be no situation in which you return a
divide by zero exception.