isub 0x64
Subtracts two ints on top of the stack; pushes the result.
- Opcode
0x64(100)- Family
- Arithmetic and bitwise
- Operands
- none
- Length
- 1 byte
- Operand stack
…, value1 (int), value2 (int) → …, result (int)- Can throw
- nothing at run time (beyond linking errors)
What it does
a - b on two ints: pops b, then a, and pushes the result.
Overflow wraps around silently, as in Java. Math.subtractExact is the version that throws.
Adding a small constant to a local variable uses iinc instead, which needs no stack at all.
How often javac uses it
In JDK 25.0.5's java.base module, isub appears 6,194 times in 1,056 of its 7,391 classes: 0.32% of all instructions, the 56th most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedInputStream.fill, java.io.BufferedOutputStream.write, java.io.BufferedReader.fill, java.io.BufferedWriter.write.
Example
From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; isub is highlighted.
static int ints(int a, int b) in Tour, compiled by javac 25Related instructions
lsub Subtracts two longs on top of the stack; pushes the result.fsub Subtracts two floats on top of the stack; pushes the result.dsub Subtracts two doubles on top of the stack; pushes the result.
Specification: JVMS §6.5, isub (Java SE 25).