---
spec: JVMS
title: "The Java Virtual Machine Specification"
edition: "Java SE 14 Edition"
java_version: 14
chapter: "Chapter 6. The Java Virtual Machine Instruction Set"
section: "6.5.if_acmp_cond"
heading: "if_acmp<cond>"
parent: "6.5. Instructions"
source: https://docs.oracle.com/javase/specs/jvms/se14/html/jvms-6.html#jvms-6.5.if_acmp_cond
id: "6.5.if_acmp_cond"
url: https://jvm.obfuscated.software/jvms/se14/6.5.if_acmp_cond.html
raw: https://jvm.obfuscated.software/jvms/se14/6.5.if_acmp_cond.md
---

# if_acmp\<cond>

## Operation

Branch if `reference` comparison succeeds

## Format

```
if_acmp<cond>
branchbyte1
branchbyte2
```

## Forms

*if_acmpeq* = 165 (0xa5)

*if_acmpne* = 166 (0xa6)

## Operand Stack

..., *value1*, *value2* →

...

## Description

Both *value1* and *value2* must be of type `reference`. They are both popped from the operand stack and compared. The results of the comparison are as follows:

- *if_acmpeq* succeeds if and only if *value1* = *value2*
- *if_acmpne* succeeds if and only if *value1* ≠ *value2*

If the comparison succeeds, the unsigned *branchbyte1* and *branchbyte2* are used to construct a signed 16-bit offset, where the offset is calculated to be (*branchbyte1* `<<` 8) | *branchbyte2*. Execution then proceeds at that offset from the address of the opcode of this *if_acmp\<cond>* instruction. The target address must be that of an opcode of an instruction within the method that contains this *if_acmp\<cond>* instruction.

Otherwise, if the comparison fails, execution proceeds at the address of the instruction following this *if_acmp\<cond>* instruction.
