sra

Shift right arithmetic

Sets $t1 to $t2 shifted right by a fixed amount of 0 to 31 bits, filling vacated bits with copies of the sign bit.

Used in

Forms

  • sra , ,

Operands

$t1
Any general-purpose register, $0 to $31, using its numeric or named spelling, such as $8 or $t0 ($zero is $0; $ra is $31).
$t2
A general-purpose register. It may be the same register as $t1.
imm5
An unsigned 5-bit immediate, 0 to 31, used for values such as a shift count.

Vacated bits on the left are filled with copies of the sign bit, preserving the sign of negative numbers. Shifting right by n is equivalent to signed division by 2^n rounding toward negative infinity.

# Shift or rotate an initialized word; inspect $t2: 0xFFFFFFFC.
li $t0, -8
sra $t2, $t0, 1