assemblymipscpu-architecturemachine-codeinstruction-encoding

In shift left instruction, why is rt used as source register instead of rs?


R-type format

In a shift left / shift right instruction, the rt is used as source register. Is there any reason why rt is used as source register, instead of rs ?

I saw some similar question answered "It is to maintain consistency between instructions, because rs is often used in instructions requiring two source registers." But in instructions requiring two source registers, rs and rt both are used, and this doesn't seem to explain why rt is used over rs.


Solution

  • Since only one register source field is needed, it would seem to be rather arbitrary as to which of the two fields is used for shift by immediate.

    However let's note that shift by variable amount, which requires two register source fields, sllv, is done as R[rd] = R[rt] << R[rs] — so the two kinds of shift (immediate and variable) take the same rt register source field and shift its contents.

    For sllv, we could also ask why shifting rt by rs instead of rs by rt?  I don't think we'll get a good answer without one of the original authors/designers, yet at the same time I don't see how it makes much of a difference.