SPRUI30H November 2015 – May 2024 DRA745 , DRA746 , DRA750 , DRA756
Arithmetic Shift Right by Register Value
SHRA src1, src2, dst
Functional unit = L
16 bit
15 | 13 | 12 | 10 | 9 | 7 | 6 | 0 |
dst | src2 | src1 | 0 | 1 | 1 | 1 | 1 | 1 | 0 |
3 | 3 | 3 | opcode |
src2 is right shifted by an unsigned value (src1) and the result is stored to dst. The shift in value is the sign bit (bit 31) of src2 . If the src1 value is greater than 31, dst is -1.
Using DIV (integer division) and SHRA (arithmetic right shift) does not produce the same result for negative numbers. The quotient of DIV is rounded towards zero, whereas the quotient of SHRA is rounded towards negative infinity. For example, using the DIV instruction: -9/4 = -2, whereas using the SHRA instruction: -9/4 = -3.
CSR[2] EQ = (dst == 0)
dst = (src1 > 31) ? FFFF FFFFh: {sign extend}{src2 >> src1}