如何通过将 MSB 填充 1 来移位二进制数?

发布于 2024-08-27 22:56:05 字数 75 浏览 4 评论 0原文

在MIPS中,有没有办法通过每次用1填充其MSB(1000,下一次1100,下一次1110,依此类推...)来移动二进制数(0000)?

In MIPS, is there a way to shift a binary number (0000) by filling its MSB with 1 (1000 and next time 1100 and next time 1110 so on...) each time?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡看悲欢离合 2024-09-03 22:56:05

如果设置了符号位,则算术右移将在左侧移入 1(可能用于符号扩展)

sra 将算术右移恒定位数

srav将算术右移可变位数

“sra 和 srav 的行为类似于 sll 和 sllv,但向右移动而不是向左移动。符号位从最高有效端移入,位从最低有效端移出。”

http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Mips/bitshift。 html

If the sign bit is set, the Arithmetic Shift Right will shift in 1's on the left (for sign-extension presumably)

sra Shift right arithmetic by a constant number of bits

srav Shift right arithmetic by a variable number of bits

"sra and srav behave like sll and sllv but shift right instead of left. The sign bit is shifted in from the most significant end, and bits fall off the least significant end. "

http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Mips/bitshift.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文