简体   繁体   English

MIPS汇编,寄存器遍历?

[英]MIPS assembly, register traversing?

Hello and thanks in advance, 您好,谢谢!

My question is if it is possible to go through registers like having a pointer in one ($t0) and moving the pointer to another one ($t1). 我的问题是,是否有可能像在一个指针中放置一个指针($ t0),然后将指针移动到另一个指针($ t1)一样进行访问。

What i actually want to do is in one loop read 8 integers and store them in ($s0-$s7) 我真正想做的是在一个循环中读取8个整数并将其存储在($ s0- $ s7)中

You could try changing the bits in the sw opcode to point to increasing registers, but that's a terrible idea. 您可以尝试更改sw操作码中的位以指向增加的寄存器,但这是一个糟糕的主意。 I think your best bet is to just write your unrolled loop yourself: 我认为最好的办法是自己编写展开循环:

lw $s0, $t0
addi $t0, $t0, 4
lw $s1, $t0
...

Rearrange things to minimize stalls, but that's about as good as you're going to get. 重新安排东西以最大程度地减少失速,但这与您将要获得的效果差不多。

You want to have a register number be variable? 您想让注册号可变吗? I don't know MIPS inside and out, but I doubt it's possible. 我不了解MIPS,但我怀疑这是否可能。 The only ISAs I know of that have anything like that are SPARC (register windows, not usable for what you want) and IA64 ("rotating registers", could be used for what you want, but only with floating point). 我所知道的唯一具有类似功能的ISA是SPARC(寄存器窗口,不能用于您想要的东西)和IA64(“旋转寄存器”,可以用于您想要的东西,但只能使用浮点数)。

I'm not aware of an existing MIPS architecture that supports referencing a register by the contents of a register, which would allow the type of thing you suggest, like: 我不知道现有的MIPS体系结构支持通过寄存器的内容引用寄存器,这将允许您建议的类型,例如:

move  $t0, $zero
mover $t0, $s0    # $s0 = register($t0) = register(0)
addi  $t0, 1
mover $t0, $s1    # $s1 = register($t0) = register(1)
addi  $t0, 1
...

Although in any case it's not a good idea in my opinion, for a few reasons. 尽管在任何情况下,出于某些原因,我认为这都不是一个好主意。 Firstly, you're dealing with a very small number of registers anyway, so there is a small upper bound on the loop in any case, making the direct approach not much less flexible. 首先,无论如何,您要处理的寄存器数量非常少,因此在任何情况下循环的上限都很小,这使得直接方法的灵活性不会降低。

More importantly, a loop like that would be horribly inefficient. 更重要的是,这样的循环效率极低。 It would initialise, increment, perform a move and a branch check (at least) for every iteration. 它将为每个迭代初始化,递增,执行move和分支检查(至少)。 Even without taking branch stalls into account this is at least 3x slower than simply: 即使不考虑分支停顿,这也比简单慢至少三倍:

move $t0, $s0
move $t1, $s1
...
move $t8, $s8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM