Which of the following causes an overflow exception lui s0 0

Which of the following causes an overflow exception?

lui $s0, 0x7000

addu $s0, $s0, $s0

lui $s0, 0x1000

add $s0, $s0, $s0

lui $s0, 0x6000

add $s0, $s0, $s0

lui $s0, 0xFFFFF

addi $s0, $s0, 1

lui $s0, 0x7000

addu $s0, $s0, $s0

lui $s0, 0x1000

add $s0, $s0, $s0

lui $s0, 0x6000

add $s0, $s0, $s0

lui $s0, 0xFFFFF

addi $s0, $s0, 1

Solution

The last one lui $s0, 0xFFFF addi $s0, $s0, 1 causes overflow. Assumption: General purpose registers are 16 bits long. 0xFFFF in binary is 1111 1111 1111 1111 if 1 is added, it becomes 1 0000 0000 0000 0000 That is, there is a overflow as the answer is now a 17 bit value which is not fit for storage in $s0, i.e the general purpose registers. For all the other options , for example lui $s0, 0x7000 addu $s0, $s0, $s0 0x7000 + 0x7000 = 0xE000 not a overflow since it is still a 16 bit value.

Which of the following causes an overflow exception? lui $s0, 0x7000 addu $s0, $s0, $s0 lui $s0, 0x1000 add $s0, $s0, $s0 lui $s0, 0x6000 add $s0, $s0, $s0 lui

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site