(a) 100110 (38)
+ 001000 (8)
--------------
101110 ( 46)
No overflow !
(b) 1000101 (69)
+ 0111100 (60)
-------------------
10000001 ( 1, if you consider only 7 lower bits ).
Hence, there is an overflow!
(a) 01110110 ( 118 )
+ 01100011 ( 99 )
----------------
11011001 (217) Hence, there is no overflow !!
(b) 11000101 ( 1 + 4 + 64 – 128 = -59 )
+ 00111100 ( 60 )
----------------
100000001 ( 1, if you consider only 8 lower bits )
As we have studied before, we observe that there is no overflow, when two numbers of opposite signs are added. We do have a carry, but that can be ignored and the lower 8 bits still give the right answer.
(a) 10110101
- 00110011
----------------
We can convert this subtraction into an addition operation as follows:
X – Y = X + (-Y) = X + ( Additive inverse of Y )
In this case, X = 10110101 an Y = 00110011.
Additve inverse of Y = two’s complement of Y in this case = 11001101
Hence the new operation is
10110101 ( 5 + 16 + 32 – 128 = -75)
+ 11001101 ( 5 + 8 + 64 – 128 = -51 )
----------------
110000010 (-126, if you consider only the lower 8 bits.)
There is no overflow. We do have a carry, but that can be ignored and the lower 8 bits still give the right answer.
(b) 10110110
- 01110100
----------------
This is similar to above problem.
In this case, X = 10110110 and Y = 01110100.
Additve inverse of Y = two’s complement of Y in this case = 10001100
Hence the new operation is
10110110 ( 6 + 16 + 32 – 128 = -74)
+ 10001100 ( 12 – 128 = -116)
----------------
101000010 ( +66, if you consider only the lower 8 bits ).
This is clearly an overflow. As per the rules we have studied before, by adding two negative numbers, we got a positive result. And that means there is an overflow.
Treat them as 4 bit numbers and perform sign extension before multiplying.
(a) 7 x 5
This is same as (0111 x 0101 ) in two’s complement representation.
Since both are positive numbers, sign extension is not even needed.
0111
* 0101
------------------
0111
0000
0111
------------------
0100011 ( 35 )
------------------
There is no overflow and the result is within 2 * n = 8 bits, where operands are each of n = 4 bits size.!
(b) -6 x 4
This is same as (1010 x 0100) in two’s complement representation.
After sign extension, we have, ( 11111010 x 00000100 )
11111010
* 00000100
------------------
00000000
0000000
111010
------------------------------
xxxxxxxx11101000 ( 8 + 32 + 64 – 128 = -24 )
------------------------------
There is no overflow and the result is within 2 * n = 8 lower bits, where operands are each of n = 4 bits size.! The higher 8 bits can be ignored.
5. Consider
the 8-bit quantity: 10110010
(a)
Perform a logical left shift operation on the above
number.
(b) Perform an arithmetic right shift on the above number.
(a) 01100100
(b) 11011001
6. Consider
the 8-bit quantity: 11000110
(a)
Perform a left rotate operation on the above number.
(b) Perform a right rotate operation on the above number.
(a) 10001101
(b) 01100011