在 MIPS 中的特定内存地址处声明数组

Declaring an array at a specific memory address in MIPS

如何在 MIPS 程序中的内存位置 100(十进制)声明一个数组?

spim 模拟器支持可选的 data 指令参数,详见 here

.data <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.

因此,例如,如果您想在地址 0x10000030 处存储一个数组,您可以这样写:

.data 0x10000030
list: .word 3, 0, 1, 2, 6, -2, 4, 9, 3, 7

但是,地址 100 不在 spim 模拟器用户数据段的可接受范围内(或者可能在任何其他情况下,因为它是内存第一页的一部分)。

我在 spim 中尝试了一个 .data 100 指令,只是想看看当我尝试从它加载时它会做什么,答案是 Memory address out of bounds 错误。