Although it seems undoable, I will still give it a shot. Suppose you perform an addition operation whose result is too big to be represented by the 32 bits of the given register. In order words, an overflow has occurred. As such, there will be a runtime exception. So my question is: is there a way to avoid this runtime exception from taking place? The reason I think it is impossible to avoid an exception is because upon overflow the "overflow flag" of the ALU is automatically set. This is seen as an indicator by the exception handler, and, consequently, an exception is thrown. Any way, how can I have it not throw the exception?
You have to write your code so that overflows does not take place. If you use unsigned integers you will not get exceptions because unsigned integers does not overflow.