我正在做一些涉及 MIPS
的工作汇编,我不断遇到这四个浮点加载/存储伪指令:l.s
, l.d
, s.s
, s.d
.我在网上找到了一些文档,发现有四个“实际”指令似乎在做同样的事情:lwc1
, ldc1
, swc1
, 和 sdc1
.
我唯一的问题是,有什么区别?据我所知,这两组指令做的事情完全一样。是否存在伪代码只是因为它们更容易阅读?
提前感谢您的任何见解。
最佳答案
My only question is, what's the difference? As far as I can tell, both sets of instructions do exactly the same thing.
你是对的。唯一可能出现的区别是当一个伪指令被翻译成多个“真实”指令时。
Do the pseudos maybe exist just because they're easier to read?
再次,是的。那是 为什么他们存在。它们给人一种更具表现力的指令集的错觉。报价Computer organization and design / Patterson & Hennessy :
... the assembler can also treat common variations of machine language instructions as if they were instructions in their own right. The hardware need not implement these instructions; however, their appearance in aassembly language simplifies translation and programming. ...
鉴于您的示例,更“清楚”地说:
l.s $f2, 24(t1) # Load Single contained in 24(t1) to $f2
比
lwc1 $f2, 24(t1) # Load Word into Coprocessor 1 from 24(t1) to $f2
以及你可以更好地理解:
move $7, $18 # move contents of $18 to $7
比
add $7, $18, $0
对我来说,只有借助助记符才能获得更清晰易读的代码。
关于assembly - MIPS float : swc1 vs. s.s,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1165807/