Shift left int
Bytecode
Type | Description |
u1 | ishl opcode = 0x78 (120) |
Stack ..., value1, value2 => ..., result
Description
Pops two ints off the stack. Shifts value2 left by the amount indicated in the five
low bits of value1. The int result is then pushed back onto the stack.
This is the same as computing the expression: x * 2s, where s is value1 and x is value2.
Both value1 and value2 must be of type int
. The values are
popped from the operand stack. An int
result is calculated by shifting
value1 left by s bit positions, where s is the value of the low
five bits of value2. The result is pushed onto the operand stack.
Example
; This is like the Java code: ; int x; ; x <<= 3; ; iload_1 ; push integer in local variable 1 onto stack iconst_3 ; push the integer 3 onto the stack ishl ; shift left istore_1 ; store the result in local variable 1
Notes
This is equivalent (even if overflow occurs) to multiplication by 2 to
the power s. The shift distance actually used is always in the range 0 to 31,
inclusive, as if value2 were subjected to a bitwise logical AND with the mask value
0x1f.