如何分配一个数组,使其从内存中的某个位置开始?

发布于 2024-08-07 19:20:42 字数 211 浏览 5 评论 0原文

如何分配一个数组,使其从内存中的某个位置开始?例如,

    .data
array: 
    .space 400

将创建一个包含 100 个字的数组,但我希望让数组从内存中的 5000 个字开始。我该怎么做? (我记得在intel asm中它非常简单)

编辑:我在linux中使用spim。顺便说一句,这真的很重要吗?

How do you allocate an array so it starts at certain place in memory? For example

    .data
array: 
    .space 400

would make an array with 100 words, but I wish to let array start at, for example, 5000 in the memory. How can I do this? ( I remember in intel asm it being really easy)

edit: I am using spim in linux. btw does this really matter?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱的十字路口 2024-08-14 19:20:42

您使用的汇编程序很重要,因为您要求的语法不是 MIPS 指令集的一部分,它是汇编程序指令,因此是特定于汇编程序的。

来自 SPIM 文档

.data< /strong>:后续项存储在数据段中。如果存在可选参数 addr,则后续项目将从地址 addr 开始存储。

.space n 在当前段(必须是SPIM中的数据段)分配n个字节的空间。

因此,

    .data 5000
array: 
    .space 400

应该做你想做的事。

What assembler you are using matters because the syntax you are asking for is not part of the MIPS instruction set, it is assembler directives, and thus assembler specific.

From the SPIM documentation:

.data <addr>: Subsequent items are stored in the data segment. If the optional argument addr is present, subsequent items are stored starting at address addr.

.space n Allocate n bytes of space in the current segment (which must be the data segment in SPIM).

Thus,

    .data 5000
array: 
    .space 400

should do what you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文