Site Tools


Sidebar

Smart Card Solution

User Manual

JavaCard API Samples

Java Card Specification

Knowledge Sharing

javacard:jcvm:7.5.101_sshr

7.5.101 sshr

Arithmetic shift right short

Format

sshr

Forms

sshr = 79 (0x4f)

Stack

…, value1, value2 → …, result

Description

Both value1 and value2 must be of type short. The values are popped from the operand stack. A short result is calculated by shifting value1 right by s bit positions, with sign extension, where s is the value of the low five bits of value2. The result is pushed onto the operand stack.

Notes

The resulting value is Î(value1) / 2s°, where s is value2& 0x1f. For nonnegative value1, this is equivalent (even if overflow occurs) to truncating short division 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.

The mask value of 0x1f allows shifting beyond the range of a 16-bit short value. It is used by this instruction, however, to ensure results equal to those generated by the Java instruction ishr.

javacard/jcvm/7.5.101_sshr.txt · Last modified: 2017/05/13 04:12 (external edit)