MIPS Assembly sll instruction

3.6k views Asked by At

I have a problem with the sll instruction. sll $t1,$a0,1 with $a0 holds the value 11 would give $t1 the value 16 (I tested it in MARS).

My suggestion for $t1 was 22, becaus a left shift of 11 aka 01011 would give me 10110, what is 22 in decimal. Where did I made a mistake?

Thanks!

1

There are 1 answers

0
Michael On BEST ANSWER

sll $t1,$a0,1 with $a0 holds the value 11 would give $t1 the value 16 (I tested it in MARS).

You're probably just mixing up decimal and hexadecimal. If you loaded $a0 with the value 11 like this li $a0,11 and shifted it one bit to the left you'd indeed get 22 as the result. The register viewer in Mars shows the values in hexadecimal, and 0x16 equals 22.