gpt4 book ai didi

assembly - MIPS 中的内存访问

转载 作者:行者123 更新时间:2023-12-04 06:13:12 24 4
gpt4 key购买 nike

我们正在学习周二的计算机组织和设计期中考试,但我们没有人理解以下问题:

procedure:
addi $sp, $sp, -4
sw $ra, 0($sp)
... Some unknown work is done ...
addi $sp, $sp, 4
lw $ra, -4($sp)
jr $ra

(1-H) 再次考虑上面的代码,并假设它有效。如果在执行过程中,“未知”
work' 部分导致从内存中读取 100 个单词,将从中读取多少个单词
整个过程执行过程中的内存? (考虑所有内存访问。

答案如下: 106. 未知工作的 100 次内存读取,加上 5 次内存读取以读取显示的指令,加上“lw”指令期间的 1 次内存读取。

如果有人能帮助我们准确了解这 6 次内存读取中的每一次发生的位置,我们将不胜感激!

最佳答案

让我们从显而易见的开始:在“未知工作”部分执行了 100 次读取,剩下 6 次读取。一读是针对 lw指令( lw $ra, -4($sp) ),从内存中读取一个字。最后 5 次读取由 CPU 在指令提取阶段隐式完成。

addi $sp, $sp, -4                   # 1 read (CPU reads the instruction word)
sw $ra, 0($sp) # 1 read -------------- ## --------------
... Some unknown work is done ... # 100 reads (given in question)
addi $sp, $sp, 4 # 1 read (CPU reads the instruction word)
lw $ra, -4($sp) # 2 reads (CPU reads the instruction word, lw instruction also reads)
jr $ra # 1 read (CPU reads the instruction word)

关于assembly - MIPS 中的内存访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7547739/

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