IJVM is an instruction set architecture created by Andrew Tanenbaum for his MIC-1 architecture. It is used to teach assembly basics in his book Structured Computer Organization.
IJVM is mostly a subset of the JVM assembly language that is used in the Java platform. This instruction set is so simple that it's difficult to write complex programs in it (for example, no shift instructions are provided).
IJVM instructions MnemonicOperandsDescriptionBIPUSHbytePush a byte onto stackDUPN/ACopy top word on stack and push onto stackERRN/APrint an error message and halt the simulatorGOTOlabel nameUnconditional jumpHALTN/AHalt the simulatorIADDN/APop two words from stack; push their sumIANDN/APop two words from stack; push Boolean ANDIFEQlabel namePop word from stack and branch if it is zeroIFLTlabel namePop word from stack and branch if it is less than zeroIF_ICMPEQlabel namePop two words from stack and branch if they are equalIINCvariable name, byteAdd a constant value to a local variableILOADvariable namePush local variable onto stackINN/AReads a character from the keyboard buffer and pushes it onto the stack. If no character is available, 0 is pushedINVOKEVIRTUALmethod nameInvoke a method, pops object reference and optionally pops arguments from stack.IORN/APop two words from stack; push Boolean ORIRETURNN/AReturn from method with integer valueISTOREvariable namePop word from stack and store in local variableISUBN/APop two words from stack; subtract the top word from the second to top word, push the difference;LDC_Wconstant namePush constant from constant pool onto stackNOPN/ADo nothingOUTN/APop word off stack and print it to standard outPOPN/ADelete word from top of stackSWAPN/ASwap the two top words on the stackWIDEN/APrefix instruction; next instruction has a 16-bit index
There's also a set of special ARRAY instructions. Instruction Stack before* Stack after Description NEWARRAY count arrayrefCreate new array on the heap. The count must be of type int. It is popped off the operand stack. The count represents the number of elements in the array to be created. Based on the Sun JVM-spec. The atype parameter is omitted. IALOAD index. arrayref value Load from int array. The arrayref must be of type reference and must refer to an array whose components are of type int. The index must be of type int. Both arrayref and index are popped from the operand stack. The int value in the component of the array at index is retrieved and pushed onto the operand stack. Part of the Sun JVM Spec. IASTORE value, index, arrayref ... Store into int array. The arrayref must be of type reference and must refer to an array whose components are of type int. Both index and value must be of type int. The arrayref, index, and value are popped from the operand stack. The int value is stored as the component of the array indexed by index. Part of the Sun JVM Spec. W_OUT value ... Pop the value from the stack and write a decimal representation of it to the display. For debugging purposes. Not part of the JVM Spec. *where the first value was pushed on the stack first, so the top of the stack is the operand at the bottom of the lists shown above.
Operand descriptions byte: A numeric literal, in octal (032 - leading zero), decimal (26 - no leading digits), or hexadecimal (0x1A - leading zero-x) format. Character literals ('M - leading single quote) are also allowed. Compiled to a 1-byte constant. label name: The string name of a label. Compiled to a 2-byte offset. variable name: The string name of a local variable. Compiled to a 1-byte value, indicating an offset into the local variable frame. method name: The string name of a method. When compiled, the address of the method is calculated and put into the constant pool. This operand is then replaced with the 2-byte index (in the constant pool) of the address. constant name: The string name of a constant. Compiled to a 2-byte index. N/A: This instruction takes no operands.
External links mic1 Free and open source MIC-1 microarchitecture simulator and IJVM assembler. emuIJVM Open source and free, with a stack animation IJVM simulator developed by students at the University of Catania (for Windows, Mac, Linux) A Vrije Universiteit Amsterdam course assignment on implementing an interpreter/ emulator for the IJVM instruction set