gpt4 book ai didi

谁能用更简单的方式解释一下?

转载 作者:太空宇宙 更新时间:2023-11-04 01:27:04 24 4
gpt4 key购买 nike

一年前我参加了计算机组织类(class),现在我将其作为“计算机体系结构”进行跟进,我正在使用 John Hennessy 的书“计算机体系结构的定量方法”的第 3 版,我经历了MIPS ISA 但仍然需要一些帮助,你能更详细地解释这行代码吗

源代码:

for(i=1000; i>0; i--)
x[i] = x[i] + s;

汇编代码:

   Loop:      L.D         F0, 0(R1)          ; F0 = array element
ADD.D F4, F0, F2 ; add scalar
S.D F4, 0(R1) ; store result
DADDUI R1, R1,# -8 ; decrement address pointer
BNE R1, R2, Loop ; branch if R1 != R2

这是作为循环展开以利用 ILP 的示例给出的,我有一些疑问。我确实知道数组从 Mem[0+R1] 开始并向后移动直到 Mem[R+8](如文中所示),这是什么原因,或者他们只是随机占据了这个位置?

另外,为什么在我们添加有符号数 (-8) 时使用 DADDUI(无符号)?

请对此进行详细概述,以便我可以跟进其余主题。谢谢

最佳答案

内存访问是按照源代码中循环指定的顺序对地址执行的。

daddiu 指令足以执行此类地址运算。 “负”值完成二进制补码中的减法。地址既不是负面的也不是正面的;它们只是位模式。请参阅 ISA reference了解有关 MIPS 和指令的更多信息。

The 16-bit signed immediate is added to the 64-bit value in GPR rs andthe 64-bit arithmetic result is placed into GPR rt . No IntegerOverflow exception occurs under any circumstances.

The term “unsigned” in the instruction name is a misnomer; this operation is 64-bit modulo arithmetic that does nottrap on overflow. It is appropriate for unsigned arithmetic such as address arithmetic, or integer arithmetic environments that ignore overflow, such as C language arithmetic.

示例未优化或展开。这只是源代码的直译。

关于谁能用更简单的方式解释一下?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29327043/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com