MIPS 程序集分配 - 加载字问题

发布于 2024-07-23 02:32:23 字数 578 浏览 4 评论 0原文

指令

sllv $s0, $s1, $s2

下面的代码用于实现使用寄存器$s2中值的最低5位的 指定寄存器 $s1 应该左移的数量:

          .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

我知道大多数指令在做什么。

然而,我不明白第二个加载字如何从移位器加载某些内容,它本身是一条指令而不是一个单词。

此外,当转换为二进制时,十六进制掩码的值在至少 5 个有效位中没有零,正如问题所述,所以我不确定它将如何屏蔽至少 5 个 sig 位。

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

I know what most of those instructions are doing.

I don't however understand how the second load word is loading something from shifter which itself is an instruction and not a word.

Also the value of the mask in hex when converted to binary doesn't have zeroes in the least 5 significant places as the question says so I am not sure how it will mask the least 5 sig places.

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

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

发布评论

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

评论(1

许你一世情深 2024-07-30 02:32:23

这是一种迂回的做法。 它实际上是修改内存中的指令来执行移位! 如果您按照代码进行操作,您将看到 sll $s0,$s1,0 指令已加载,其 sa 字段已从 0 修改为> 到 $s2 然后保存回内存并执行。

That's kind of a round-about way of doing it. It's actually modifying the instruction in-memory to perform the shift! If you follow the code, you will see that the sll $s0,$s1,0 instruction is loaded, has its sa field modified from 0 to $s2 and then saved back into memory and executed.

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