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, 0+1, 1+0, 1+2, 5+5, 9+1, and 9+9.
Answer
The Ex__1_single_digit_adder.py
Python file contains the adder code:
#!/usr/bin/env python
"""Ex__1_single_digit_adder.py: Answer to Ch 1 Ex 1."""...