[英]MARS MIPS Bit Shifting using SRA
So when shifting -34 by 2 bits using SRA, I get an output of -9 using the code below.因此,当使用 SRA 将 -34 移动 2 位时,我使用下面的代码得到 -9 的 output。 I can not figure out why it is giving me -9 and not another number我不知道为什么它给了我-9而不是另一个数字
addi $t0, $zero, -34
sra $s0, $t0, 2
addi $v0, $zero, 4
la $a0, result1
syscall
addi $v0, $zero, 1
move $a0, $s0
syscall
-34 in (two's complement) binary is: -34(二进制补码)二进制是:
11111111 11111111 11111111 11011110
^ ^
bit 31 bit 0
Shift that arithmetically 2 bits to the right and you get:在算术上向右移动 2 位,你得到:
11111111 11111111 11111111 11110111
Which is -9这是-9
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.