2.5

[15] <§2.5> Consider the following code used to implement the instruction sllv $s0, $s1, $s2

which uses the least significant 5 bits of the value in register $s2

to specify the amount register $s1 should be shifted left:

.data

mask: .word 0xfffff83f

.text

start: lw $t0, mask

lw $s0, shifter

and $s0,$s0,$t0

andi $s2,$s2,0x1f

sll $s2,$s2,6

or $s0,$s0,$s2

sw $s0, shifter

shifter: sll $s0,$s1,0

Add comments to the code and write a paragraph describing how it works. Note

that the two lw instructions are pseudoinstructions that use a label to specify a

memory address that contains the word of data to be loaded. Why do you suppose

that writing ˇ°self-modifying codeˇ± such as this is a bad idea (and oftentimes not

actually allowed)?