Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Perform binary addition of the following pairs of 16-bit numbers (shown in he

ID: 669989 • Letter: 1

Question

1. Perform binary addition of the following pairs of 16-bit numbers (shown in hexadecimal) and indicate whether your result is “right” or “wrong.” First treat them as unsigned values, then as signed values (stored in two’s complement format). Thus, you will have two “right/wrong” answers for each sum. Note that the computer performs only one addition, setting both the CF(Carry Flag) and OF(Overflow Flag) according to the results of the addition.

I need help figuring out CF and OF

a) 1111 + abcd = BCDE CF = ? OF = ?

b) 0101 + 8080 = 8181 CF = ? OF = ?

c) 0f0f + 048b = 139A CF = ? OF = ?

Sample solutions from my textbook below

Explanation / Answer

Answer:

a)

1111

0001 0001 0001 0001

abcd

1010 1011 1100 1101

bcde

1011 1100 1101 1110

The answer is correct. CF = 0, OF =0

b)

0101

0000 0001 0000 0001

8080

1000 0000 1000 0000

8181

1000 0001 1000 0001

The answer is correct. CF = 0 , OF = 0

c)

0f0f

0000 1111 0000 1111

048b

0000 0100 1000 1011

139a

0001 0011 1001 1010

The answer is correct. CF = 0 , OF = 0

Adding of hexadecimal numbers using signed bit:

a)

1111

0001 0001 0001 0001

abcd

1010 1011 1100 1101

2’s complement of abcd

0101 0100 0011 0011

In abcd, the left most bit is 1, which implies, it is a negative value. So, find the 2’s complement of abcd ‘s binary value. Then add the result.

Find the 2’s complement of the obtained result.

1111

0001 0001 0001 0001

2’s complement of abcd

0101 0100 0011 0011

6544

0110 0101 0100 0100

Answer: 6544

Convert 6544 into 2’complement value is (1001 1010 1011 1100)= 9ABC

CF = 0

OF = 1

b)

0101

0000 0001 0000 0001

8080

1000 0000 1000 0000

2’s complement of 8080

0111 1111 1000 0000

In 8080, the left most bit is 1, which implies, it is a negative value. So, find the 2’s complement of 8080 ‘s binary value. Then add the result.

Find the 2’s complement of the obtained result.

0101

0000 0001 0000 0001

2’s complement of 8080

0111 1111 1000 0000

9091

1001 0000 1001 0001

Answer: 9091

CF = 0

OF = 1

Convert 9091 into 2’complement value is (0110 1111 0110 1111)= 6f6f

c)

0f0f

0000 1111 0000 1111

048b

0000 0100 1000 1011

2’s complement of 048b

1111 1011 0111 0101

In 048b, the left most bit is 1, which implies, it is a negative value. So, find the 2’s complement of 048b ‘s binary value. Then add the result.

Find the 2’s complement of the obtained result.

0f0f

0000 1111 0000 1111

2’s complement of 048b

1111 1011 0111 0101

0a84

10000 1010 1000 0100

Answer: 0a84

CF = 1

OF = 0

Convert 0a84 into 2’complement value is (1111 0101 0111 1011)= F57B

1111

0001 0001 0001 0001

abcd

1010 1011 1100 1101

bcde

1011 1100 1101 1110