ifeq <label><label> is a label name. To define the location of the label, use the <label> name followed by a colon:
<label>:<label> then becomes associated the address of the following instruction. Labels can only be assigned one location in a method. On the other hand, a single <label> can be the target of multiple branch instructions.
Stack Before
Description After value ... ...
ifeq pops the top int off the operand stack. If the int equals zero, execution branches to the address (pc + branchoffset), where pc is the address of the ifeq opcode in the bytecode and branchoffset is a 16-bit signed integer parameter following the ifeq opcode in the bytecode. If the int on the stack does not equal zero, execution continues at the next instruction.
If you are using Jasmin, branchoffset is computed for you from the address of <label>.
Example
iload_1 ; push the int value in local variable 1 onto the stack ifeq Label ; if the value of local variable 1 is zero, jump to Label return ; return if local variable 1 is nonzero Label: ; execution continues here if local variable 1 equals zero...Bytecode
Type | Description |
u1 | ifeq opcode = 0x99 (153) |
s2 | branchoffset |
ifnull, iflt, ifle, ifne, ifnonnull, ifgt, ifge
Notes
Addresses are measured in bytes from the start of the bytecode (i.e. address 0 is the first byte in the bytecode of the currently executing method).