MIPS(好奇心)清除寄存器的更快方法? [英] MIPS (curiosity) faster way of clearing a register?

查看:85
本文介绍了MIPS(好奇心)清除寄存器的更快方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 MIPS 程序集中清除寄存器 (=0) 的最快方法是什么?

What is the fastest way of clearing a register (=0) in MIPS assembly?

一些例子:

xor    $t0, $t0, $t0
and    $t0, $t0, $0
move   $t0, $0
li     $t0, 0
add    $t0, $0, $0

哪个最有效?

推荐答案

在许多 MIPS 实现中,这些操作都会编译为相同的指令,因为通常 'mov $a, $b' 是 或$a, $b, $0li $r, xori $r, $0, x 的简写:

In many MIPS implementations, these ops will both compile to the same instruction, because typically 'mov $a, $b' is an idiom for or $a, $b, $0 and li $r, x is shorthand for ori $r, $0, x:

move $t0, $0
li $t0, 0

并且这些都将发生在同一个管道上,在架构上是等效的:

and these will both take place on the same pipeline, being architecturally equivalent:

xor $t0, $t0, $t0
and $t0, $t0, $0

并且在我曾经使用过的每个 RISC 实现中,add 与 xor/and/nor/etc 在同一管道上.

and in every RISC implementation I've ever worked with, add is on the same pipe as xor/and/nor/etc.

基本上,这都是特定芯片的实现所特有的,但它们都应该是单时钟.如果芯片出现故障,li 和 x, $0, $0 可能 最快,因为它们最大限度地减少了对其他寄存器的错误依赖.

Basically, this is all particular to the implementation of a particular chip, but they all ought to be single clock. If the chip is out of order, li or and x, $0, $0 might be fastest because they minimize false dependencies on other registers.

这篇关于MIPS(好奇心)清除寄存器的更快方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆