csci 10 :: book learning challenge 4 (due mon, feb 22)

Complete this exercise on your own.

Fill in all of the "Answer" boxes, then print the answer grid that you see after you press "Prepare for printing".

Staple all pages together and submit to the instructor on the date listed above.

Questions:

Read AoA V1 2.7, V1 2.8, V3 10.2 and answer the following:

1. In section 2.7 of your text, the author states that "Registers are a middleman in nearly every calculation." Briefly explain what he means in the context of adding two variables together and storing the sum in a third variable.
2. Write the assembly add instruction that would map to the following high level language statement.
destination = destination + source;
3. Write the assembly sub instruction that would map to the following high level language statement.
destination = destination - source;
5. Translate the following high level expression into assembly code. You do not need to declare variables -- assume x has been properly declared as an uns8 variable.
x = x + 10;
6. Translate the following high level expression into assembly code. You do not need to declare variables -- assume x and y have both been properly declared as uns16 variables.
x = x + y;
7. Translate the following high level expression into assembly code. You do not need to declare variables -- assume x has been properly declared as an int16 variable.
x = x + 999;
8. Translate the following high level expression into assembly code. You do not need to declare variables -- assume x and y have both been properly declared as int32 variables.
x = x - y;
9. Translate the following high level expression into assembly code. You do not need to declare variables -- assume x and y have both been properly declared as int16 variables.
x = x - y;
10. Translate the following high level expression into assembly code. You do not need to declare variables -- assume x has been properly declared as an uns32 variable.
x = x * 5;
11. Translate the following high level expression into assembly code. You do not need to declare variables -- assume x and y have both been properly declared as uns16 variables.
x = x * y;
12. Translate the following high level expression into assembly code. You do not need to declare variables -- assume x has been properly declared as an int8 variable.
x = x * 5;