Contents Prev Next Up


The Virtual Machine Instruction Set


Control Transfer Instructions

ifeq
iflt
ifle
ifne
ifgt
ifge
if_icmpeq
if_icmpne
if_icmplt
if_icmpgt
if_icmple
if_icmpge
lcmp
fcmpl
fcmpg
dcmpl
dcmpg
if_acmpeq
if_acmpne
goto
jsr
ret

ifeq

Branch if equal

to 0

..., value => ...

value should be an integer or a handle to an object or to an array. It is popped from the stack. If value is equal to zero, branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the pc. Otherwise execution proceeds at the instruction following the ifeq.

iflt

Branch if less than

0

..., value => ...

value should be an integer. It is popped from the stack. If value is less than zero, branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the pc. Otherwise execution proceeds at the instruction following the iflt.

ifle

Branch if less than or equal

to 0

..., value => ...

value should be an integer. It is popped from the stack. If value is less than or equal to zero, branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the pc. Otherwise execution proceeds at the instruction following the ifle.

ifne

Branch if not equal

to 0

..., value => ...

value should be an integer or a handle to an object or to an array. It is popped from the stack. If value is not equal to zero, branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the pc. Otherwise execution proceeds at the instruction following the ifne.

ifgt

Branch if greater than

0

..., value => ...

value should be an integer. It is popped from the stack. If value is greater than zero, branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the pc. Otherwise execution proceeds at the instruction following the ifgt.

ifge

Branch if greater than or equal

to 0

..., value => ...

value should be an integer. It is popped from the stack. If value is greater than or equal to zero, branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the pc. Otherwise execution proceeds at the instruction following the ifge.

if_icmpeq

Branch if integers equal

..., value1, value2 => ...

value1 and value2 should be integers. They are both popped from the stack. If value1 is equal to value2, branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the pc. Otherwise execution proceeds at the instruction following the if_icmpeq.

if_icmpne

Branch if integers not equal

..., value1, value2 => ...

value1 and value2 should be integers. They are both popped from the stack. If value1 is not equal to value2, branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the pc. Otherwise execution proceeds at the instruction following the if_icmpne.

if_icmplt

Branch if integer less than

..., value1, value2 => ...

value1 and value2 should be integers. They are both popped from the stack. If value1 is less than value2, branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the pc. Otherwise execution proceeds at the instruction following the if_icmplt.

if_icmpgt

Branch if integer greater than

..., value1, value2 => ...

value1 and value2 should be integers. They are both popped from the stack. If value1 is greater than value2 (C's >), branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the pc. Otherwise execution proceeds at the instruction following the if_icmpgt.

if_icmple

Branch if integer less than or equal to

..., value1, value2 => ...

value1 and value2 should be integers. They are both popped from the stack. If value1 is less than or equal to value2, branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the pc. Otherwise execution proceeds at the instruction following the if_icmple.

if_icmpge

Branch if integer greater than or equal to

..., value1, value2 => ...

value1 and value2 should be integers. They are both popped from the stack. If value1 is greater than or equal to value2, branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the pc. Otherwise execution proceeds at the instruction following the if_icmpge.

lcmp

Long integer compare

..., value1-word1, value1-word2, value2-word1, value2-word1 => ..., result

value1 and value2 should be long integers. They are both popped from the stack and compared. If value1 is greater than value2, the integer value 1 is pushed onto the stack. If value1 is equal to value2, the value 0 is pushed onto the stack. If value1 is less than value2, the value -1 is pushed onto the stack.

fcmpl

Single float compare (-1 on incomparable

)

..., value1, value2 => ..., result

value1 and value2 should be single precision floating point numbers. They are both popped from the stack and compared. If value1 is greater than value2, the integer value 1 is pushed onto the stack. If value1 is equal to value2, the value 0 is pushed onto the stack. If value1 is less than value2, the value -1 is pushed onto the stack.

If either value1 or value2 is NaN, the value -1 is pushed onto the stack.

fcmpg

Single float compare (1 on incomparable

)

..., value1, value2 => ..., result

value1 and value2 should be single precision floating point numbers. They are both popped from the stack and compared. If value1 is greater than value2, the integer value 1 is pushed onto the stack. If value1 is equal to value2, the value 0 is pushed onto the stack. If value1 is less than value2, the value -1 is pushed onto the stack.

If either value1 or value2 is NaN, the value 1 is pushed onto the stack.

dcmpl

Double float compare (-1 on incomparable

)

..., value1-word1, value1-word2, value2-word1, value2-word1 => ..., result

value1 and value2 should be double precision floating point numbers. They are both popped from the stack and compared. If value1 is greater than value2, the integer value 1 is pushed onto the stack. If value1 is equal to value2, the value 0 is pushed onto the stack. If value1 is less than value2, the value -1 is pushed onto the stack.

If either value1 or value2 is NaN, the value -1 is pushed onto the stack.

dcmpg

Double float compare (1 on incomparable

)

..., value1-word1, value1-word2, value2-word1, value2-word1 => ..., result

value1 and value2 should be double precision floating point numbers. They are both popped from the stack and compared. If value1 is greater than value2, the integer value 1 is pushed onto the stack. If value1 is equal to value2, the value 0 is pushed onto the stack. If value1 is less than value2, the value -1 is pushed onto the stack.

If either value1 or value2 is NaN, the value 1 is pushed onto the stack.

if_acmpeq

Branch if objects same

..., value1, value2 => ...

value1 and value2 should be handles to objects or arrays. They are both popped from the stack. If value1 is equal to value2, branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the pc. Otherwise execution proceeds at the instruction following the if_acmpeq.

if_acmpne

Branch if objects not same

..., value1, value2 => ...

value1 and value2 should be handles to objects or arrays. They are both popped from the stack. If value1 is not equal to value2, branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the pc. Otherwise execution proceeds at the instruction following the if_acmpne.

goto

Branch

always

no change

branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the pc.

jsr

Jump subroutine

... => ..., return-address

branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. The address of the instruction immediately following the jsr is pushed onto the stack. Execution proceeds at the offset from the current pc.

The jsr instruction is used in the implementation of Java's finally keyword.

ret

Return from subroutine

no change

Local variable vindex in the current Java frame should contain a return address. The contents of the local variable are written into the pc.

Note that jsr pushes the address onto the stack, and ret gets it out of a local variable. This asymmetry is intentional.

The ret instruction is used in the implementation of Java's finally keyword.


Contents Prev Next Up

Generated with CERN WebMaker