How can I declare an array at memory location 100(Decimal) in a MIPS program?
问题:
回答1:
The spim
simulator supports the optional data
directive argument as detailed 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 addressaddr
.
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
.
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
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).
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.