Appendix
Answers to Exercises
Chapter 1: Introducing Computer Architecture
Exercise 1
Using your favorite programming language, develop a simulation of a single-digit decimal adder that operates in the same manner as in Babbage’s Analytical Engine. First, prompt the user for two digits in the range 0-9: the addend and the accumulator. Display the addend, the accumulator, and the carry, which is initially zero. Perform a series of cycles as follows:
- If the addend is zero, display the values of the addend, accumulator, and carry and terminate the program
- Decrement the addend by one and increment the accumulator by one
- If the accumulator incremented from nine to zero, increment the carry
- Go back to step 1
Test your code with these sums: 0+0, ...
Get Modern Computer Architecture and Organization - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.