SPRUIE9D May 2017 – May 2024 DRA74P , DRA75P , DRA76P , DRA77P
Arithmetic Shift Right by 5-Bit Unsigned Constant
SHRA ucst5, src2, dst
Functional unit = L
32 bit
31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 16 | 15 | 13 | 12 | 10 | 9 | 0 |
x | x | x | x | x | x | x | x | x | x | x | ucst5 | dst | src2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |
5 | 3 | 3 | opcode |
src2 is right shifted by a 5-bit unsigned constant (ucst5) and the result is stored to dst. The shift in value is the sign bit (bit 31) of src2.
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 = {sign extend}{src2 >> ucst5}