在MIPS中的特定内存地址处声明一个数组 [英] Declaring an array at a specific memory address in MIPS
问题描述
如何在MIPS程序中的内存位置100(十进制)处声明一个数组?
How can I declare an array at memory location 100(Decimal) in a MIPS program?
推荐答案
The spim
simulator supports the optional data
directive argument as detailed here.
.data <addr>
以下数据项应存储在数据段中.如果存在可选参数addr
,则会从地址addr
开始存储项目.
The following data items should be stored in the data segment. If the optional argument addr
is present, the items are stored beginning at address addr
.
因此,使用spim
,可以将任何数据存储在准确的地址中,只要它在用户数据段的范围内即可.在spim
中,保留范围是0x10000000 - 0x10040000
.
Therefore, using spim
, you can store any data at an exact address as long as it is within the range of the user data segment. In spim
, the reserved range is 0x10000000 - 0x10040000
.
因此,例如,如果您想将数组存储在地址0x10000030
中,则应编写:
So, for example, if you wanted to store an array at address 0x10000030
you would write:
.data 0x10000030
list: .word 3, 0, 1, 2, 6, -2, 4, 9, 3, 7
但是,地址100
不在spim
模拟器的用户数据段的可接受范围内(或可能在任何其他情况下,因为它将是内存第一页的一部分).
However, address 100
is not within the acceptable range for the spim
simulator's user data segment (or probably in any other circumstance since it would be part of the first page of memory).
我在spim
中尝试了.data 100
指令,只是想看看当我尝试从中加载时会执行什么操作,而答案是Memory address out of bounds
错误.
I tried a .data 100
directive in spim
, just to see what it would do when I tried to load from it, and the answer is a Memory address out of bounds
error.
这篇关于在MIPS中的特定内存地址处声明一个数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!