Skip to main content

Exercises 3.7 Exercises

1.

Use the “Decoder Ring” in Figure 3.6.2 to perform the following arithmetic. Indicate whether the result is “right” or “wrong”.

  1. Unsigned integers: \(\hex{1 + 3}\)

  2. Unsigned integers: \(\hex{3 + 4}\)

  3. Unsigned integers: \(\hex{5 + 6}\)

  4. Signed integers: \(\hex{(+1) + (+3)}\)

  5. Signed integers: \(\hex{(-3) - (+3)}\)

  6. Signed integers: \(\hex{(+3) - (+4)}\)

Hint

For unsigned arithmetic, use the two inner rings and pay attention to passing over the top (C). For signed arithmetic, use the outer and inner rings and pay attention to passing over the bottom (V).

Answer
  1. Start at the tic mark for \(1\text{,}\) move \(3\) tic marks CW, giving \(4 = \binary{100}_{2}\text{.}\) We did not pass the tic mark at the top, so C = \(\binary{0}\text{,}\) and the result is correct.

  2. Start at the tic mark for \(3\text{,}\) move \(4\) tic marks CW, giving \(7 = \binary{111}_{2}\text{.}\) We did not pass the tic mark at the top, so C = \(\binary{0}\text{,}\) and the result is correct.

  3. Start at the tic mark for \(5\text{,}\) move \(6\) tic marks CW, giving \(3 = \binary{011}_{2}\text{.}\) We passed the tic mark at the top, so C = \(\binary{1}\text{,}\) and the result is wrong.

  4. Start at the tic mark for \(+1\text{,}\) move \(3\) tic marks CW, giving \(-4 = \binary{100}_{2}\text{.}\) We passed the tic mark at the bottom, so V = \(\binary{1}\text{,}\) and the result is wrong.

  5. Start at the tic mark for \(-3\text{,}\) move \(3\) tic marks CCW, giving \(+2 = \binary{010}_{2}\text{.}\) We passed the tic mark at the bottom, so V = \(\binary{1}\text{,}\) and the result is wrong.

  6. Start at the tic mark for \(+3\text{,}\) move \(4\) tic marks CCW, giving \(-1 = \binary{111}_{2}\text{.}\) We did not pass the tic mark at the bottom, so V = \(\binary{0}\text{,}\) and the result is correct.

2.

Add the following pairs of 8-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).

  1. \(\displaystyle \hex{55 + aa}\)

  2. \(\displaystyle \hex{55 + f0}\)

  3. \(\displaystyle \hex{80 + 7b}\)

  4. \(\displaystyle \hex{63 + 7b}\)

  5. \(\displaystyle \hex{0f + ff}\)

  6. \(\displaystyle \hex{80 + 80}\)

Hint

You will have two “right/wrong” answers for each sum. The computer performs only one addition, setting both C and V according to the results of the addition. It is up to the program to test the appropriate flag depending on whether the numbers are being considered as unsigned or signed in the program.

Answer
sum signed unsigned
a. \(\hex{ff}\) right right
b. \(\hex{45}\) right wrong
c. \(\hex{fb}\) right right
sum signed unsigned
d. \(\hex{de}\) wrong right
e. \(\hex{0e}\) right wrong
f. \(\hex{00}\) wrong wrong
3.

Add 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).

  1. \(\displaystyle \hex{1234 + edcc}\)

  2. \(\displaystyle \hex{1234 + fedc}\)

  3. \(\displaystyle \hex{8000 + 8000}\)

  4. \(\displaystyle \hex{0400 + ffff}\)

  5. \(\displaystyle \hex{07d0 + 782f}\)

  6. \(\displaystyle \hex{8000 + ffff}\)

Hint

You will have two “right/wrong” answers for each sum. The computer performs only one addition, setting both C and V according to the results of the addition. It is up to the program to test the appropriate flag depending on whether the numbers are being considered as unsigned or signed in the program.

Answer
sum signed unsigned
a. \(\hex{0000}\) right wrong
b. \(\hex{1110}\) right wrong
c. \(\hex{0000}\) wrong wrong
sum signed unsigned
d. \(\hex{03ff}\) right wrong
e. \(\hex{7fff}\) right right
f. \(\hex{7fff}\) wrong wrong