MIPS大会:如何否定登记册?
In question iv.
Does my first instruction successfully negate the register i? Does my second instruction complete the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,有效!
在此说明序列中,不必要使用
$ t2
,因为第一个指令可以直接将结果直接放回$ t0
中,因为$ t0
无论如何都将要更新,在此之后您只需要-i
,但不再需要i
本身的原始值。通常,减少用于这样的小型代码序列的寄存器数量是一件好事,因为在较大的上下文中,我们可以用光寄存器。
对我来说,这样做会更自然了:
当然,这确实需要第二张登记册(无法消除它),因此,在一个措施中,您的代码顺序(修改为使用
$ t0
仅修改)更最佳。Yes, that works!
The use of
$t2
is unnecessary in this instruction sequence, as the first instruction can simply put the result directly back in$t0
, since$t0
is going to be updated anyway, and you need only-i
after that point, but no longer need the original value ofi
itself.Generally, it is good to reduce the number of registers used for small code sequences like this, since there are larger contexts in which we can run out of registers.
To me it would have been more natural to do:
Of course, that does require a 2nd register (no way to eliminate it), so to one measure, your code sequence (modified to use
$t0
only) is more optimal.