In the following two cases find out whether there will be an

In the following two cases, find out whether there will be an overflow exception after the instruction add $t0, $t1, $t2 Explain why.

1) The numbers in $t1 and $t2 are 0xA0000002 and 0xA0000002, respectively.

2) The numbers in $t1 and $t2 are 0xA0000002 and 0x7FFFFFF2, respectively.

Solution

If the machine is 32-bit, the maximum value is: 231 - 1= 214748364710 = 7FFFFFFF16. Therefore, any additions which results in a number larger than this, will throw an overflow exception.

1) The numbers in $t1 and $t2 are 0xA0000002 and 0xA0000002, respectively.

add $t0, $t1, $t2 is equal to $t0 = $t1 + $t2; An as the values of $t1, and $t2 are giventhe summation is:

$t0 = 0xA0000002 + 0xA0000002 = 0x140000004. As this value is beyond the limit we concluded, this causes an overflow exception.

2) The numbers in $t1 and $t2 are 0xA0000002 and 0x7FFFFFF2, respectively.

$t0 = 0xA0000002 + 0x7FFFFFF2 = 0x11FFFFFF4. As this value is also beyond the limit we concluded, this also causes an overflow exception.

In the following two cases, find out whether there will be an overflow exception after the instruction add $t0, $t1, $t2 Explain why. 1) The numbers in $t1 and

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site