What changes when using the instruction sra and the srl one? I can't understand the difference between the two. The language in use is MIPS assembly.
sll $t1,$t0,2
sra $t2,$t0,2
sll $t1,$t0,2
srl $t2,$t0,2
What changes when using the instruction sra and the srl one? I can't understand the difference between the two. The language in use is MIPS assembly.
sll $t1,$t0,2
sra $t2,$t0,2
sll $t1,$t0,2
srl $t2,$t0,2
SLR is a typo and should be SRL instead. SRA does an arithmetic shift and SRL does a logical one. So SRL will shift zeros in whereas SRA shifts the sign bit in. For example shifting 0xFFFF1234 right logically gives 0x3FFFC48D and arithmetically gives 0xFFFFC48D because the sign bit is 1 (assuming this is MIPS32). For more information read