go to previous page   go to home page   go to next page

Is there a need for an arithmetic shift left instruction?

Answer:

No. A logical shift left moves zeros into the low-order bit, which is correct for both signed and unsigned integers.

The sra Instruction

MIPS has a shift right arithmetic instruction:

sra    d,s,shft   #  $d <— s shifted right
                  #  shft bit positions.
                  #  0 ≤ shft < 31

Sometimes you need to divide by two. This instruction is faster and more convenient than the div instruction.

QUESTION 14:

Does the sra instruction give the correct results for unsigned integers?