Integer logical shift right
Bytecode
Type | Description |
u1 | iushr opcode = 0x7C (124) |
Stack ..., value1, value2 => ..., result
Description
Pops two ints off the operand stack. Shifts value1 right by the amount indicated in
the five low bits of value2. The int result is then pushed back onto the stack.
value1 is shifted logically (ignoring the sign extension - useful for unsigned values).
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 right by s bit positions, with zero
extension, 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 ; load local variable 1 onto stack iconst_3 ; push the integer 3 onto the stack iushr ; logical shift right istore_1 ; store the result in local variable 1
Notes
If value1 is positive and s
is value2
& 0x1f, the result is the same as that of value1 \>\> s
; if value1
is negative, the result is equal to the value of the expression (value1 \>\> s
)
+ (2 << ~s). The addition of the (2 << ~
s) term cancels out the propagated sign bit. The shift
distance actually used is always in the range 0 to 31, inclusive.