## Section 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”.

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

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

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

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

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

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

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`

).

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

\(\hex{55 + aa}\)

\(\hex{55 + f0}\)

\(\hex{80 + 7b}\)

\(\hex{63 + 7b}\)

\(\hex{0f + ff}\)

\(\hex{80 + 80}\)

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.

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

\(\hex{1234 + edcc}\)

\(\hex{1234 + fedc}\)

\(\hex{8000 + 8000}\)

\(\hex{0400 + ffff}\)

\(\hex{07d0 + 782f}\)

\(\hex{8000 + ffff}\)

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.

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 |