One of the most interesting features of Java is the means by which its designers intended it to be translated into machine language. Part of the specification of Java is the specification of the Java Virtual Machine. The JVM has a simple instruction set that has many features in common with most assembly languages, including the MIPS and PDP8/E assembly languages. The JVM instructions are called bytecodes, for reasons that will be clear in a moment.
When you compile a Java program, you don't compile it directly into the machine language of a particular processor. Instead, you compile it into the JVM instruction set. The resulting bytecode "executable" doesn't run on any real machines directly. But since the bytecodes are like instructions found in most machine languages, the translation from JVM bytecodes to any particular machine language is very simple (especially if you don't sweat performance). When Java programs (applets) are shipped from Web server to Web browser, they are sent as bytecodes, which the browser translates to the machine language of the real machine on which the browser is running.
You might find it interesting in this context to know that one of the earliest implementations of Pascal--UCSD Pascal--used a scheme almost identical to Java's. Its intermediate language was called "p-code," which survived for a while until Turbo Pascal came along (this is an over-simplification of the events, but it is true that Borland, in a sense, exploited a weakness in the p-code idea). Turbo did not use p-code.
The location of the stack is not addressed in the specification of the JVM. Just as the description of the PDP8/E architecture might say "the PDP8/E has a 12-bit Accumulator, a 1-bit Link, and a Memory consisting of 4096 12-bit Words," so does the JVM description say, simply, that the JVM has a Stack. Bytecodes manipulate the Stack.
All JVM instructions consist of a one-byte op-code, followed by zero or more operands. Some operands are longer than one byte. Such operands are stored after the op-code in network byte order, also known as big-endian byte order. That is, the highest-order byte of operand comes first.
I have down-loaded the complete JVM specification, which is available in HTML form off our course Web page at www.mathcs.carleton.edu/faculty/jondich/Courses/cs207_f96/Documents/JavaVM/vmspec-1.html . Go take a look. [Actually, don't go take a look. I kept this document locally during the exam in case of network failure, but for copyright reasons I have deleted it. The final version of the JVM specification is now in print--see http://www.javasoft.com/doc/language_vm_specification.html and http://www.aw.com/cp/lindholm-yellin.html for details.]
The cover story in the November 1996 issue of Byte magazine is entitled "Inside Sun's Java Chips: How will they transform computing?" This story is a very interesting read. For reasons that remain somewhat mysterious to me, Carleton's library does not carry Byte, but our departmental library does. There is an issue of the November Byte in the Math/CS lounge. If you read it, please do not remove the magazine from the lounge.
All of this leads us to the heart of this exam.
You should include in your datapath an instruction memory, and a memory unit for the Stack. You do not need to show the circuitry required for your ALU--just describe what it does in response to its control.
Please hand in a diagram of your datapath (like Figure 5.39 on page 323 of Patterson and Hennessy), a finite-state machine describing your datapath's control (like Figure 5.47 on page 332), and a brief discussion of your design and how it works.
One thing you'll have to do to handle this question in a reasonable amount of time is to cut through the interesting but unimportant (for us) clutter in the JVM documentation. The structure you'll need to deal with for this small subset of the JVM instruction set is quite simple, so don't get bogged down in all the extra goodies in JVM. It's important to be able to read a document starting in the middle.
If your design is better than Sun's, can I have a cut?
But I'll forbear. Let's finish out the exam with: