Hardware Reference
In-Depth Information
if cmpeq3
Z = TOS
MDR; rd
Why is this not done?
10. How long does a 2.5-GHz Mic-1 take to execute the following Java statement
i=j+k;
Give your answer in nanoseconds.
11. Repeat the previous question, only now for a 2.5-GHz Mic-2. Based on this calcula-
tion, how long would a program that runs for 100 sec on the Mic-1 take on the Mic-2?
12. Write microcode for the Mic-1 to implement the JVM POPTWO instruction. This in-
struction removes two words from the top of the stack.
13. On the full JVM machine, there are special 1-byte opcodes for loading locals 0 through
3 onto the stack instead of using the general ILOAD instruction. How should IJVM be
modified to make the best use of these instructions?
14. The instruction ISHR (arithmetic shift right integer) exists in JVM but not in IJVM. It
uses the top two values on the stack, replacing them with a single value, the result.
The second-from-top word of the stack is the operand to be shifted. Its content is
shifted right by a value between 0 and 31, inclusive, depending on the value of the 5
least significant bits of the top word on the stack (the other 27 bits of the top word are
ignored). The sign bit is replicated to the right for as many bits as the shift count. The
opcode for ISHR is 122 (0x7A).
a. What is the arithmetic operation equivalent to left shift with a count of 2?
b. Extend the microcode to include this instruction as a part of IJVM.
15. The instruction ISHL (shift left integer) exists in JVM but not in IJVM. It uses the top
two values on the stack, replacing the two with a single value, the result. The sec-
ond-from-top word of the stack is the operand to be shifted. Its content is shifted left
by a value between 0 and 31, inclusive, depending on the value of the 5 least signifi-
cant bits of the top word on the stack (the other 27 bits of the top word are ignored).
Zeros are shifted in from the right for as many bits as the shift count. The opcode for
ISHL is 120 (0x78).
a. What is the arithmetic operation equivalent to shifting left with a count of 2?
b. Extend the microcode to include this instruction as a part of IJVM.
16. The JVM INVOKEVIRTUAL instruction needs to know how many parameters it has.
Why?
17. Implement the JVM DLOAD instruction for the Mic-2. It has a 1-byte index and pushes
the local variable at this position onto the stack. Then it pushes the next higher word
onto the stack as well.
18. Draw a finite-state machine for tennis scoring. The rules of tennis are as follows. To
win, you need at least four points and you must have at least two points more than your
opponent. Start with a state (0, 0) indicating that no one has scored yet. Then add a
state (1, 0) meaning that A has scored. Label the arc from (0, 0) to (1, 0) with an A .
Now add a state (0, 1) indicating that B has scored, and label the arc from (0, 0) with a
B . Continue adding states and arcs until all the possible states have been included.
Search WWH ::




Custom Search