Information Technology Reference
In-Depth Information
EXERCISES
1. Write a program using the addressing modes and the instruction types pre-
sented in Sections 2.2 and 2.3 to reverse the bits stored in a 16-bit register R 0 .
2. Consider a computer that has a number of registers such that the three reg-
isters R 0 ¼
1000. Show the effective address
of memory and the registers' contents in each of the following instructions
(assume that all numbers are decimal).
(a) ADD (R 0 )
1500, R 1 ¼
4500, and R 2 ¼
, R 2
(b) SUBTRACT 2
þ
(R 1 ), R 2
(c) MOVE 500(R 0 ), R 2
(d) LOAD #5000, R 2
(e) STORE R 0 , 100(R 2 )
3. Assume that the top of the stack in a program is pointed to by the register SP.
You are required to write program segments to perform each of the following
tasks (assume that only the following addressing modes are available:
indexed, autoincrement, and autodecrement).
(a) Pop the top three elements of the stack, add them, and push the result
back onto the stack.
(b) Pop the top two elements of the stack, subtract them, and push the results
back onto the stack.
(c) Push five elements (one at a time) onto the stack.
(d) Remove the top five elements from the top of the stack.
(e) Copy the third element from the top of the stack into register R 0 .
4. You are required to write a program segment that can perform the operation
C A þ B where each of A and B represents a set of 100 memory locations
each storing a value such that the set of values represented by A are stored
starting at memory location 1000 and those represented by B are stored start-
ing at memory location 2000. The results should be stored starting at memory
location 3000. The above operation is to be performed using each of the
following instruction classes.
(a) A machine with one-address instructions
(b) A machine with one-and-half instructions
(c) A machine with two-address instructions
(d) A machine with three-address instructions
(e) A machine with zero-address instructions
5. Write program segments that perform the operation C C þ A B using
each of the instruction classes indicated in Exercise 4 above. Assume that
A, B, and C are memory addresses.
6. Assume that a series of five tests has been offered to a class consisting of 50
students. The score obtained by students in each of the five tests are stored
sequentially in memory locations starting respectively at memory locations
1000, 2000, 3000, 4000, and 5000. You are required to write a program
Search WWH ::




Custom Search