Chapter3 1
Chapter3 1
Note that the sum of a number x and its inverted representation x’ always
equals a string of 1s (-1).
x + x’ = -1
x’ + 1 = -x … hence, can compute the negative of a number by
-x = x’ + 1 inverting all bits and adding 1
12
Example
13
Signed / Unsigned
15
MIPS Instructions
16
Sign Extension
18
Addition and Subtraction
19
Overflows
• For an unsigned number, overflow happens when the last carry (1)
cannot be accommodated
• For a signed number, overflow happens when the most significant bit
is not the same as every bit to its left
when the sum of two positive numbers is a negative result
when the sum of two negative numbers is a positive result
The sum of a positive and negative number will never overflow
• MIPS allows addu and subu instructions that work with unsigned
integers and never flag an overflow – to detect the overflow, other
instructions will have to be executed
20