3.6k views

A processor that has the carry, overflow and sign flag bits as part of its program status word (PSW) performs addition of the following two $2's$ complement numbers $01001101$ and $11101001$. After the execution of this addition operation, the status of the carry, overflow and sign flags, respectively will be:

1. $1, 1, 0$
2. $1, 0, 0$
3. $0, 1, 0$
4. $1, 0, 1$
edited | 3.6k views
0
I am not clear for the use of carry and overflow bit. What i know is that carry flag is generated in unsigned arithmetic and overflow for unsigned. So answer should be c) according to me.
Correct me if I am wrong.
0
No ,overflow flag will be 0 bcoz it is set only if two similar signed nos result in a no with  sign opposite to those of operands.

But I have a doubt regarding carry flag. It is set only for unsigned nos I guess.
+4

$Remarks:$
1.
If there is a carry in MSB and there is a carry out of MSB then there is no overflow as no overflow happening in this question.
2. If there is a carry in MSB and there is no carry out of MSB or vice-versa, there is overflow.
3. In  n bits signed number (n-1) right most bits are for magnitude and nth left most bit is for sign.
4. (n+1)th left most bit is for carry, as we have the following structure to store a binary number
[C] [n, n-1, .........1]
5. Suppose sum of two numbers is  cn-1, cn-2 cn-3 ........ c0, and then cn⊕cn-1 represents overflow if both the 2's complemented numbers having same sign either -ve or +ve otherwise no overflow. If both numbers are not of same size then this logic cn⊕cn-1 = 1 (overflow) fails. where cn-1 is sign bit of the sum and cn is carry out.
for example in this question cn⊕cn-1 = 1, using this logic overflow should occur but both the numbers are of different sign so overflow can't occur, so this logic cn⊕cn-1 = 1(overflow) failed.

0

@Manu Thakur for overflow checking operation there is no need of two numbers of same sign ,this operation can be done between two different signed numbers also, carefully check that for this question also it is satisfied.

$01001101$

$+ 11101001$

-----------------

$100110110$

Carry $= 1$

Overflow = $0$ (In $2's$ complement addition Overflow happens only when: Sign bit of two input numbers is $0$, and the result has sign bit $1$ OR Sign bit of two input numbers is $1$, and the result has sign bit $0$.)

Sign bit = $0$.

answered by Boss (34.1k points)
edited
+6
the overflow flag is usually generated by an exclusive or of the internal carry into and out of the sign bit
0
my comment is correct, need not be downvoted.
0
@Mithilesh Consider the normal meaning of carry as in mathematics. Now, overflow bit is set when carry happens for signed numbers. For unsigned numbers carry bit is set. There is no meaning for carry bit for signed numbers and for overflow bit for unsigned numbers.

In the given question we don't know if the numbers are signed/unsigned. But does it make a difference?
0
yes, but my question is for signed/unsigned not negative/positive.
0
consider our computer and C language. We use both signed and unsigned integers in C. 2's complement representation is used for both.
+1
what if there was an overflow? In that case, would the sign bit be recorded as the msb of the sum or the carry bit? (because since it is an overflow, the carry denotes the sign bit).

1  1

01001101

+11101001

-----------------

1 00110110

carry flag=1        (extra bit out of msb)

overflow flag=0 (since both in carry out carry =1 and it is addition of -ve and +ve number so                                     overflow should be equals to 0)

(overflow bit =0 if both in carry out carry =0 or1 / addition of -ve and +ve number

& overflow bit =1 if either one of them is 1 and other is 0)

Sign bit =0  (since msb bit is 0)

therefore option B.

answered by Boss (16.1k points)
0
Can u explain what carry bit is denoting here logically?
+1

in 2's complement when you add two number such that A>B then you have to discard the carry bit as you get answer as true magnitude

here A=01001101(77)

B=11101001 (-23)

0
Carry = 1 here denotes that Borrow = 0. In 2's complement addition complement of carry indicates borrow.
 Cout = 1 (Carry) Cin = 1 1 1 A 0 1 0 0 1 1 0 1 B 1 1 1 0 1 0 0 1 Result 0 (Sign Flag) 0 1 1 0 1 1 0

Carry Flag = 1

Overflow Flag = Cin XOR Cout = 1 XOR 1 = 0

Sign Flag = 0

Hence correct option - B

answered by (219 points)
edited
+1 vote
ans B)
answered by Loyal (5.3k points)
C) 010
answered by Active (2.6k points)

1
2