What is the purpose of "SLL" in this code?

188 views Asked by At
#switch ( a [ j * 2 + 1 ] ) {
switch01_test:
la $t0 , j               # $t0 <− address of j
lw $t1 , 0( $t0 )        # $t1 <− j
addiu $t2 , $zero , 2    # $t2 <− 2
mul $t3 , $t1 , $t2      # $t3 <− j * 2
addiu $t4 , $t3 , 1      # $t4 <− j * 2 + 1
sll $t5 , $t4 , 2        # $t5 <− 4 *(j*2+1) 
la $t6 , a               # $t6 <− base address of a
addu $t7 , $t6 , $t5     # $t7 <− address of a [j*2+1]
lw $t8 , 0( $t7 )        # $t8 <− a[j*2+1]
#Check if a[j*2+1] = 1
addiu $t9 , $zero , 1    # $t9 <− 1
beq $t9 , $t8 , switch01_code_1#if a[j*2+1]=1 execute case 1:
#Check if a[j*2+1] = 3
addiu $t9 , $zero , 3    # $t9 <− 3
beq $t9 , $t8 , switch01_code_3#if a[j*2+1]=3 execute case 3:
#Check if a[j*2+1] = 5
addiu $t9 , $zero , 5    # $t9 <− 5
beq $t9 , $t8 , switch01_code_5#if a[j*2+1]=5 execute case 5:
#a[j*2+1] not equal 1,3 or 5
j switch01_end # switch01 exit

What does sll do in the code and why is it necessary?

I understood all the code except the "sll" part

0

There are 0 answers