in Digital Logic
7,002 views
7 votes
7 votes

Two eight bit bytes $1100  0011$ and $0100  1100$ are added. What are the values of the overflow, carry and zero flags respectively, if the arithmetic unit of the CPU uses $2$'s complement form?

  1. $0, 1, 1'$
  2. $1, 1, 0$
  3. $1, 0, 1$
  4. $0, 1, 0$
in Digital Logic
7.0k views

1 comment

Zero flag is set to 1(True), if result is 0.

Zero flag is set to 0(False), if result is non-zero.
2
2

6 Answers

17 votes
17 votes
Best answer
I think it is D

      11000011

      01001100

    ………………...

 (1) 00001111 with Carry =1 (specified in bracket )

The zero flags will be set if the result is 0 . but here the result is not 0 so the zero flag is set to 0

For overflow, we have a condition of  $C=C_{out} \oplus C_{in}$

where Carry out  is carry from MSB (bit 8 )   // taking byte as from bit1 to bit 8

Carry in carry from bit 7

So carry out = 1

carry in 1

so the exor of both of them is 0 --- which will carry a flag

So option d

carry flag - 1sum -- 0  overflow is 0
edited by

4 Comments

What is the use of this line? 

if the arithmetic unit of the CPU uses 2's complement form.

1
1

@bhuv   from this we can conclude that first number is negative and second no is positive . now addition of these can not overflow (try to understand the reason )

so we can directly say that overflow flag is 0

0
0

@Gurdeep Saini It is given that condition for overflow is Cout exor Cin = 1. But if Cin=1 and Cout=0 then how can we say overflow is there? Please explain this I am having serious doubt in this concept

0
0
So here my doubt is, there is no need to change into 2 s complement before solving ? Bcoz of this line " CPU uses 2 s complement "
0
0
5 votes
5 votes

Cout = 1 Carry)

Cin = 1

         A

1

1

0

0

0

0

1

1

         B

0

1

0

0

1

1

0

0

      Result

0 (Sign Flag)

0

1

0

1

1

1

1

Carry Flag = 1

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

Sign Flag = 0

1 comment

if cpu uses 2’s complement then why first number convert into 2’complement bcz it is negative
0
0
4 votes
4 votes

 1   1

      11000011

      01001100

 1   00001111     

 

zero flag=0 (final answer is non zero)

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) 

carry flag=1(extra bit out of msb)

1 vote
1 vote

   11000011

   01001100


1  00001111

so finally we have result as 00001111


now herre discard the carry in red digit becoz we are using two's complement method therefore  we have 

zero flag=0 

overflow flag=1

carry flag=0

1 comment

there is no such option. and overflow should be reset(0) as both input and output carry is 1.
0
0