IJVM Classes of Instructions (Instruction Set Architecture) Hex 0x10 0x13 0x15 0x36 0x57 0x59 0x5F
Mnemonic Basic Stack Operations BIPUSH byte LDC_W index ILOAD varnum ISTORE varnum POP DUP SWAP
Meaning Data Movement Instructions Push byte onto stack Push constant from constant pool onto stack Push local variable onto stack Pop word from stack and store in local variable Delete word on top of stack Copy top word on stack and push onto stack Swap the two top words on the stack
ALU Instructions Pop two words from stack; push their sum Pop two words from stack; push their difference Pop two words from stack; push Boolean AND Pop two words from stack; push Boolean OR Add a constant to a local variable
Flow Control Instructions Pop word from stack and branch if zero Pop word from stack and branch if less than zero Pop two words from stack; branch if equal Unconditional branch
0x00 0xC4
Misc. NOP WIDE
Other Instructions Do nothing Prefix instruction; next instruction has a 16-bit index
Special Operations 0xB6 INVOKEVIRTUAL disp 0xAC IRETURN
Subroutine/ISR Control Instructions Invoke a method Return from method with integer value
The operands byte, const, and varnum are 1 byte. The operands disp, index, and offset are 2 bytes. 1 of 20 Notes and figures are based on or taken from materials in the course textbook: A.S. Tanenbaum, Structured Computer Organization 4th ed., Prentice Hall, Upper Sable River, NJ, 1999. ISBN 0-13-095990-1.
The IJVM MAL (p. 262-264) IJVM Microinstruction 1 (MIC-1) Architecture Language (1 of 4) main1
PC = PC + 1; fetch; goto (MBR)
nop1 iadd1 iadd2 iadd3
goto main1 MAR = SP = SP-1; rd H = TOS MDR = TOS = MDR + H; wr; goto main1 MAR = SP = SP-1; rd H = TOS MDR = TOS = MDR - H; wr; goto main1 MAR = SP = SP-1; rd H = TOS MDR= TOS = MDR AND H; wr; goto main1 MAR = SP = SP-1; rd H = TOS MDR = TOS = MDR OR H; wr; goto main1 MAR = SP = SP + 1 MDR = TOS; wr; goto main1 MAR = SP = SP-1; rd
MBR holds opcode; get next byte; dispatch Do nothing Read in next-to-top word on stack H = top of stack Add top two words; write to top of stack Read in next-to-top word on stack H = top of stack Do subtraction; write to top of stack Read in next-to-top word on stack H = top of stack Do AND; write to new top of stack Read in next-to-top word on stack H = top of stack Do OR; write to new top of stack Increment SP and copy to MAR Write new stack word Read in next-to-top word on stack Wait for new TOS to be read from memory Copy new word to TOS Set MAR to SP-1; read 2nd word from stack Set MAR to top word Save TOS in H; write 2nd word to top of stack Copy old TOS to MDR Set MAR to SP-1; write as 2nd word on stack Update TOS
2 of 20 Notes and figures are based on or taken from materials in the course textbook: A.S. Tanenbaum, Structured Computer Organization 4th ed., Prentice Hall, Upper Sable River, NJ, 1999. ISBN 0-13-095990-1.
IJVM Microinstruction 1 (MIC-1) Architecture Language (2 of 4) bipush1 bipush2 bipush3 iload1 iload2
SP = MAR = SP + 1 PC = PC + 1; fetch MDR = TOS = MBR; wr; goto main1 H = LV MAR = MBRU + H; rd
iload3
MAR = SP = SP + 1
iload4
PC = PC + 1; fetch; wr
iload5 istore1 istore2
TOS = MDR; goto main1 H = LV MAR = MBRU + H
istore3 istore4 istore5 istore6 wide1 wide_iload1
MDR = TOS; wr SP = MAR = SP-1; rd PC = PC + 1; fetch TOS = MDR; goto main1 PC = PC+ 1; fetch; goto (MBR OR 0x100) PC = PC + 1; fetch