On Fri, 2 Jan 2004, EECS 382 student wrote: > Prof Wolff: > > I don't know if its too late or not, but I have a few questions about > the quiz. > > In the JVM part... > > 1) for the hex instructions, should we just put the number of the > instruction itself (the 8-bit opcode) or the whole line, with the values > included?i opcodes (in hex) plus operands (if any, also in hex) The "Opcode Mnemonics by Opcode" don't list the required operands, http://java.sun.com/docs/books/vmspec/html/Mnemonics.doc.html you have to go painfully (next->next->...) through the docs: http://java.sun.com/docs/books/vmspec/html/Instructions2.doc13.html sipush Operation Push short sipush byte1 byte2 Forms sipush = 17 (0x11) Stack ... ..., value Description The immediate unsigned byte1 and byte2 values are assembled into an intermediate short where the value of the short is (byte1 << 8) | byte2. The intermediate value is then sign-extended to an int, and the resulting value is pushed onto the operand stack. > The resources on the website only list the opcodes > themselves, so I don't know the format for putting the values to be > pushed/popped, etc in the machine instruction. > > 2) what is the instruction for int2short? It's listed in the Bytecode > tutorial on javaword, but not in the spec. Don't need it for this take home. > > 3) In email 4, you mention tricking the compiler with negative numbers. > Does this mean that we hive the bipush instruction the negative > equivilent of the positive number? (what an unsigned char would be if So people wanted to use javap tool. but just treat the 8-bits as an unsigned number. Think 16-bits, bipush is thinking 8 bits not 16 or 32 bits. > it was signed, as in 200= -73?). When we use bipush twice and add two > bytes together, will they become a positive short? You are thinking 8-bit machine, if you have 16-bit instructions use them. Merge the 8-bit operations into 16 or 32. The JVM should be very few instructions. > >