简体   繁体   中英

MIPS Assembly sll instruction

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM