16.

prev next contents
if_acmpeq

jump if two object references are equal

Jasmin Syntax
     if_acmpeq <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

After
value1
...
value2

...

Description

if_acmpeq pops the top two object references off the stack and compares them. If the two object references are equal (i.e. if they both refer to the same object), execution branches to the address (pc + branchoffset), where pc is the address of the if_acmpeq opcode in the bytecode and branchoffset is a 16-bit signed integer parameter following the if_acmpeq opcode in the bytecode. If the object references refer to different objects, execution continues at the next instruction.

If you are using Jasmin, branchoffset is computed for you from the address of <label>.

Example

     aload_1         ; push the object reference in local variable 1 onto stack     aload_2         ; push the object reference in local variable 2 onto stack     if_acmpeq Label ; if the two references on the stack are identical, jump to Label     return          ; return if not equal Label:     ; execution continues here if local variables 1 and 2 refer to the same object 
Bytecode

Type

Description
u1
if_acmpeq opcode = 0xA5 (165)
s2
branchoffset
See Also

if_acmpne

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).


prev next contents
Java Virtual Machine, by Jon Meyer and Troy Downing, O'Reilly Associates


Java Virtual Machine
Java Virtual Machine (Java Series)
ISBN: 1565921941
EAN: 2147483647
Year: 1996
Pages: 171

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net