关于 MIPS 代码的问题
如何将以下内容写入MIPS指令?
$t0=$t1
if ($t6<$t7) go to Label.
How to write the following into MIPS instructions?
$t0=$t1
if ($t6<$t7) go to Label.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
$t0 不保留为零。 $t0 是一个临时寄存器,可以存储任何值。寄存器 $zero 被保留/硬连接为零。如果 $t6 “小于”$t7,我们希望“分支”到“Label”,因此在小于指令 blt 上使用分支。代码如下:
添加 $t0,$zero,$t1
blt $t6,$t7,标签
$t0 is not reserved for zero. $t0 is a temporary register that can store any value. The register $zero is reserved/hard-wired to zero. We would want to "branch" to "Label" if $t6 is "less than" $t7, so use the branch on less than instruction blt. The code would look like:
add $t0,$zero,$t1
blt $t6,$t7,Label
你的以下垃圾:
将转换为 MIPS,如下所示:
your following rubbish:
would be converted to MIPS like:
假设寄存器已经加载了正确的数据。
因此,对于
$t2 = $t3
,添加$t3
来注册零并将其存储在$t2
中将起作用,所以这就是它的样子就像:add $t2,$t3,$t0
- 假设 $t0 像大多数版本的 mips 一样保留为零。对于
if $t4
,我们需要一个分支语句,不确定您想要将其与什么进行比较,但是请查看本指南 - 应该给出有关如何编写它的足够说明。Assuming that the registers are already loaded with the right data.
So for
$t2 = $t3
, adding$t3
to register zero and storing it in$t2
will work so this is how it would look like :add $t2,$t3,$t0
- assuming $t0 is reserved for zero like most versions of mips.for
if $t4
, we need a branch statement, not sure what you want to compare it to, but look at this guide - should give enough instructions about how to write it.