MIPS加载字[地址和内容混乱] [英] MIPS Load Word [Address and Content Confusion]

查看:113
本文介绍了MIPS加载字[地址和内容混乱]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我要使用加载单词命令

If I were to use the load word command

  lw $t0, 4($t0)

和这张桌子

  Address   Content
    100       120
    112       108
    132       136
    136       112

    #s1 is initialised to 0
    #t0 is initialised to 112

我的困惑是,如果我将4($ t0)的值赋给$ t0,原来的地址$ t0会发生什么?并且如果问题是说它被初始化为112,那么它是指地址还是值?

The confusion I have is that if I were to assignment the value of 4($t0) to $t0, what would happen to the original address of $t0? and that if the question were to say it is initialized to 112, will it be referring to the address or value?

推荐答案

在执行lw $t0, 4($t0)之前,预期寄存器$t0包含基地址.

Before the execution of lw $t0, 4($t0) the register $t0 is expected to contain a base address.

然后,该指令将位于地址$t0+4的字加载到寄存器$t0中.执行后,$ t0保留存储在该地址中的值($ t0 + 4),而先前的值是丢失"(即,它被读取的内存覆盖).

The instruction then loads the word located at the address $t0+4 into register $t0. After the execution, $t0 holds the value stored in that address ($t0+4), and the previous value is "lost" (that is, it is overwritten by the memory read).

任何值都可以解释为一个地址,任何地址都可以解释为一个值(即它们只是32位值).由您的代码决定是否赋予这些值含义.似乎$t0旨在作为指令之前的数组的基地址,并在之后包含一些值(如果我们假设$t0持有数组的基地址,则该数组的索引1的内容)指令已执行.

Any value can be interpreted as an address and any address can be interpreted as a value (i.e. they are just 32bit values). It is up to your code to give meaning to those values. It seems like $t0 is meant to be the base address of an array prior to the instruction and to contain some value (the contents of index 1 of the array if we suppose $t0 was holding the base address of the array) after the instruction is executed.

这篇关于MIPS加载字[地址和内容混乱]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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