Site Tools


Sidebar

Smart Card Solution

User Manual

JavaCard API Samples

Java Card Specification

Knowledge Sharing

javacard:jcvm:7.5.107_sushr

7.5.107 sushr

Logical shift right short

Format

sushr

Forms

sushr = 81 (0x51)

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 sign-extending value1 to 32 bits<SUP>[13]</SUP> and shifting the result right by s bit positions, with zero extension, where s is the value of the low five bits of value2. The resulting value is then truncated to a 16-bit result. The result is pushed onto the operand stack.

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 « &#126;s). The addition of the (2 « &#126;s) term cancels out the propagated sign bit. 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 iushr.

javacard/jcvm/7.5.107_sushr.txt · Last modified: 2017/05/13 04:08 (external edit)