**MASTER OF COMPUTER APPLICATIONS**

Course Code : MCS-012

Course Title : Computer Organisation and Assembly Language Programming

Assignment Number : MCA(I)/012/Assignment/15-16

Maximum Marks : 100

Weightage : 25%

**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 **8 bits **including the sign bit. (Please note that the numbers given here are in decimal notation)

i) Add – 128 and 120

ii) Subtract 124 from –99

iii) Add 64 and 61

Please indicate the overflow if it is occurs. Also write how you have identified the overflow.

**ii) Subtract 124 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 7 -bits

0 / 1 |

Now, Binary value of the given number

99 – 1100011

124 – 1111100

** -99 :-**

Sign bit 7 -bits

NA |
1 |
0 |
0 |
1 |
1 |
1 |
0 |
1 |

** +124 :-**

Sign bit 7 -bits

NA |
0 |
1 |
1 |
1 |
1 |
1 |
0 |
0 |

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:-

** -124 :-**

Sign bit 7 -bits

NA |
1 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |

Now, covert it to signed 2’s complement notation:-

** -99 :-**

Sign bit 7 -bits

NA |
1 |
0 |
0 |
1 |
1 |
1 |
0 |
1 |

** -124 :-**

Sign bit 7 -bits

NA |
1 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |

Simple trick to convert any binary value to its signed 2’s complement notation is **Check** for the first *one (i.e. 1)* in the magnitude of the number from **Right to Left** when you find it, Keep the number unchanged till *one (i.e. 1)* and remaining number reverse it by changing value from 0 to 1 and vice-verse.

** -99 :-**

Sign bit 7 -bits

NA |
1 |
0 |
0 |
1 |
1 |
1 |
0 |
1 |

** -124 :-**

NA |
1 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |

** -223 :-**

Carry bit

NA |
1 |
0 |
0 |
1 |
0 |
0 |
0 |
0 |
1 |

** **

**Overflow condition occured.**

The magnitude has been overflowed into carry the given 8-bits are not sufficient for the result of the magnitude.