Declaring an array at a specific memory address in MIPS

旧巷老猫 提交于 2019-12-02 15:12:19

问题


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 address addr.

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.



来源:https://stackoverflow.com/questions/35651548/declaring-an-array-at-a-specific-memory-address-in-mips

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!