Shift Left Logical-MIPS SLL Instruction with Example
A Shift Left Logical instruction in MIPS assembly is used for shifting the bits to the left. The amount of shift depends on the value we give it. When we perform a shift left logical instruction the low bits at right most is replaced by zeros and the high right most bit is discarded. (Number of discarded bits depend on the amount of shift)
To understand the full logic see the below picture:
In the picture, you can see that performing sll one time on an 8-bit pattern causes the whole pattern shift by one bit.Shift logical left by one causes the number multiplied by 2.
It’s general form is as follows: sll destination, target, shift_amount
Shift Left Logical-MIPS Program
Q: Write a program in MIPS, that take an integer from the user, perform SLL and Print the output.
msg1: .asciiz "Enter the number to perform SLL: "
msg2: .asciiz "\nThe result of SLL is: "
Enter the number to perform SLL: 2
The result of SLL is: 4
That was all about MIPS SLL, questions in the comment box will be appreciated!