Course Title
Assignment Number
Maximum Marks
Weightage
Last Dates for Submission
: MCS-012
: Computer Organisation and Assembly Language Programming
: MCA(1)/012/Assign/2014-15
: 100
: 25%
: 15th October, 2014 (For July 2014 Session)
15th April, 2015 (For January 2015 Session)
Perform the following arithmetic operations :Using binary signed 2’s complement notation for integers. You may assume that the maximum size of integers is of 9 bits including the sign bit. (Please note that the numbers given here are in decimal notation). i)
Add – 256 and 206 ii) Subtract 224 from –99 iii) Add 124 and 132
Please indicate the overflow if it occurs. Also write how you identify overflow.
i) Add – 256 and 206
First, we have to represent the number in binary notation
The sign of a binary number is represented by 0 as plus and 1 as minus
Sign bit
8 -bits
0/1
Now, Binary value of the given number
206 – 11001110
256 – 100000000
This number value is of more than 8-bits (i.e.9-bits) in signed 2’s complement notation also the value remains the same. Hence this number cannot fit inside it.
To add this numbers we will need one more bit, hence Addition not possible. ii) Subtract 224 from –99
First, we have to represent the number in binary notation
The sign of a binary number is represented by 0 as plus and 1 as minus
Sign bit
8 -bits
0/1
Now, Binary value of the given number
99 – 01100011
224 – 11100000
-99 :Sign bit
8 -bits
1
+224 :Sign bit
0
1
1
0
0
0
1
1
1
1
0
0
0
0
0
8 -bits
0
1
In Binary, Subtraction is not done directly it is done by taking a MINUS sign for a positive number.
For subtraction changing +224 to -224:-224 :Sign bit
8 -bits
1
1
1
1
0
0
0
0
0
1
1
1
0
1
Now, covert it to signed 2’s complement notation:-99 :Sign bit
8 -bits
1
-224 :-
1
0
0
Sign bit
8 -bits
1
0
0
1
0
0
0
0
0
Simple trick to convert any binary value to its signed 2’s complement notation is Check for the firstone
(i.e. 1) in the magnitude of