Contents Prev Next Up


3.11 Control Transfer Instructions

ifeq

Branch if equal
 
ifeq = 153
branchbyte1
branchbyte2
to 0

Stack: ..., value => ...

value must be an integer. It is popped from the stack. If value is zero, branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the address of this instruction. Otherwise execution proceeds at the instruction following the ifeq.

ifnull

Branch if null
 
ifnull = 198
branchbyte1
branchbyte2

Stack: ..., value => ...

value must be a reference to an object. It is popped from the stack. If value is null, branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the address of this instruction. Otherwise execution proceeds at the instruction following the ifnull.

iflt

Branch if less than
 
iflt = 155
branchbyte1
branchbyte2
0

Stack: ..., value => ...

value must 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 address of this instruction. Otherwise execution proceeds at the instruction following the iflt.

ifle

Branch if less than or equal
 
ifle = 158
branchbyte1
branchbyte2
to 0

Stack: ..., value => ...

value must 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 address of this instruction. Otherwise execution proceeds at the instruction following the ifle.

ifne

Branch if not equal
 
ifne = 154
branchbyte1
branchbyte2
to 0

Stack: ..., value => ...

value must be an integer. 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 address of this instruction. Otherwise execution proceeds at the instruction following the ifne.

ifnonnull

Branch if not null
 
ifnonnull = 199
branchbyte1
branchbyte2

Stack: ..., value => ...

value must be a reference to an object. It is popped from the stack. If value is not null, branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the address of this instruction. Otherwise execution proceeds at the instruction following the ifnonnull.

ifgt

Branch if greater than
 
ifgt = 157
branchbyte1
branchbyte2
0

Stack: ..., value => ...

value must 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 address of this instruction. Otherwise execution proceeds at the instruction following the ifgt.

ifge

Branch if greater than or equal
 
ifge = 156
branchbyte1
branchbyte2
to 0

Stack: ..., value => ...

value must 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 address of this instruction. Otherwise execution proceeds at the instruction following the ifge.

if_icmpeq

Branch if integers equal
 
if_icmpeq = 159
branchbyte1
branchbyte2

Stack: ..., value1, value2 => ...

value1 and value2 must 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 address of this instruction. Otherwise execution proceeds at the instruction following the if_icmpeq.

if_icmpne

Branch if integers not equal
 
if_icmpne = 160
branchbyte1
branchbyte2

Stack: ..., value1, value2 => ...

value1 and value2 must 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 address of this instruction. Otherwise execution proceeds at the instruction following the if_icmpne.

if_icmplt

Branch if integer less than
 
if_icmplt = 161
branchbyte1
branchbyte2

Stack: ..., value1, value2 => ...

value1 and value2 must 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 address of this instruction. Otherwise execution proceeds at the instruction following the if_icmplt.

if_icmpgt

Branch if integer greater than
 
if_icmpgt = 163
branchbyte1
branchbyte2

Stack: ..., value1, value2 => ...

value1 and value2 must be integers. They are both popped from the stack. If value1 is greater than value2, branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the address of this instruction. Otherwise execution proceeds at the instruction following the if_icmpgt.

if_icmple

Branch if integer less than or equal to
 
if_icmple = 164
branchbyte1
branchbyte2

Stack: ..., value1, value2 => ...

value1 and value2 must 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 address of this instruction. Otherwise execution proceeds at the instruction following the if_icmple.

if_icmpge

Branch if integer greater than or equal to
 
if_icmpge = 162
branchbyte1
branchbyte2

Stack: ..., value1, value2 => ...

value1 and value2 must 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 address of this instruction. Otherwise execution proceeds at the instruction following the if_icmpge.

lcmp

Long integer compare
 
lcmp = 148

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

value1 and value2 must 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 NaN
 
fcmpl = 149
)

Stack: ..., value1, value2 => ..., result

value1 and value2 must 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 NaN
 
fcmpg = 150
)

Stack: ..., value1, value2 => ..., result

value1 and value2 must 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 NaN
 
dcmpl = 151
)

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

value1 and value2 must 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 NaN
 
dcmpg = 152
)

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

value1 and value2 must 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 object references are equal
 
if_acmpeq = 165
branchbyte1
branchbyte2

Stack: ..., value1, value2 => ...

value1 and value2 must be references to objects. They are both popped from the stack. If the objects refrerenced are not the same, branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the Address of this instruction. Otherwise execution proceeds at the instruction following the if_acmpeq.

if_acmpne

Branch if object references not equal
 
if_acmpne = 166
branchbyte1
branchbyte2

Stack: ..., value1, value2 => ...

value1 and value2 must be references to objects. They are both popped from the stack. If the objecs referenced are not the same, branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset. Execution proceeds at that offset from the address of this instruction. Otherwise execution proceeds at the instruction following the if_acmpne.

goto

Branch
 
goto = 167
branchbyte1
branchbyte2
always

Stack: no change

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

goto_w

Branch always (wide index)
 
goto_w = 200
branchbyte1
branchbyte2
branchbyte3
branchbyte4

Stack: no change

branchbyte1, branchbyte2, branchbyte3, and branchbyte4 are used to construct a signed 32-bit offset. Execution proceeds at that offset from the address of this instruction.

jsr

Jump subroutine
 
jsr = 168
branchbyte1
branchbyte2

Stack: ... => ..., 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 address of this instruction.

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

jsr_w

Jump subroutine (wide index)
 
jsr_w = 201
branchbyte1
branchbyte2
branchbyte3
branchbyte4

Stack: ... => ..., return-address

branchbyte1, branchbyte2, branchbyte3, and branchbyte4 are used to construct a signed 32-bit offset. The address of the instruction immediately following the jsr_w is pushed onto the stack. Execution proceeds at the offset from the address of this instruction.

ret

Return from subroutine
 
ret = 169
vindex

Stack: no change

Local variable vindex in the current Java frame must 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.

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

ret_w

Return from subroutine (wide index)
 
ret_w = 209
vindexbyte1
vindexbyte2

Stack: no change

vindexbyte1 and vindexbyte2 are assembled into an unsigned 16-bit index to a local variable in the current Java frame. That local variable must contain a return address. The contents of the local variable are written into the pc. See the ret instruction for more information.


Contents Prev Next Up