Hardware Reference
In-Depth Information
16. How many registers does the machine whose instruction formats are given in Fig. 5-24
have?
17. In Fig. 5-24, bit 23 is used to distinguish the use of format 1 from format 2. No bit is
provided to distinguish the use of format 3. How does the hardware know to use it?
18. It is common in programming for a program to need to determine where a variable X is
with respect to the interval A to B . If a three-address instruction were available with
operands A , B , and X , how many condition code bits would have to be set by this in-
struction?
19. Describe one advantage and one disadvantage of program-counter-relative addressing.
20. The Core i7 has a condition code bit that keeps track of the carry out of bit 3 after an
arithmetic operation. What good is it?
21. One of your friends has just come bursting into your room at 3 A.M. , out of breath, to
tell you about his brilliant new idea: an instruction with two opcodes. Should you send
your friend off to the patent office or back to the drawing board?
22. Tests of the form
if (k == 0) ...
if (a > b) ...
if (k < 5) ...
are common in programming. Devise an instruction to perform these tests efficiently.
What fields are present in your instruction?
23. For the 16-bit binary number 1001 0101 1100 0011, show the effect of:
a. A right shift of 4 bits with zero fill.
b. A right shift of 4 bits with sign extension.
c. A left shift of 4 bits.
d. A left rotate of 4 bits.
e. A right rotate of 4 bits.
24. How can you clear a memory word on a machine with no CLR instruction?
25. Compute the Boolean expression ( A AND B )OR C for
A = 1101 0000 1010 0011
B = 1111 1111 0000 1111
C = 0000 0000 0010 0000
26. Devise a way to interchange two variables A and B without using a third variable or
register. Hint : Think about the EXCLUSIVE OR instruction.
27. On a certain computer it is possible to move a number from one register to another,
shift each of them left by different amounts, and add the results in less time than a mul-
tiplication takes. Under what condition is this instruction sequence useful for comput-
ing ''constant
variable''?
28. Different machines have different instruction densities (number of bytes required to
perform a certain computation). For the following Java code fragments, translate each
×
Search WWH ::




Custom Search