“对齐” MIPS指令

发布于 2024-07-25 11:46:32 字数 69 浏览 2 评论 0原文

这个指令到底有什么作用? 我知道它会尝试将数据与特定数字的倍数对齐,但为什么需要这样做? 其他汇编器中是否有等效的指令?

What exactly does this instruction do? I know that it tries to align data with a multiple of a specific number but why would you need to do this? Is there an equivalent instruction in other assemblers?

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

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

发布评论

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

评论(3

(り薆情海 2024-08-01 11:46:32

您通常会对齐数据以获得更好的性能。 对于大多数处理器来说,当不访问特定字节边界时,内存访问会受到一些影响。 对于其他汇编程序,通常存在某种伪操作 .align 为此。 大多数编译器还会对齐其数据结构(尽管您可以出于调试目的禁​​用它)。

另请参阅此维基百科条目

请注意,如果您尝试访问未对齐的内存单元,非模拟 MIPS 系统甚至可能会崩溃(请参阅此处 和此处)。

You usually align data to get better performance. For most processors, memory access has some penalty when not accessing specific byte boundaries. For other assemblers, there often is some kind of pseudo-op .align for this. Most compilers also align their data structures (though you can disable it for debug purposes).

Also See this Wikipedia entry.

Note that non-emulated MIPS systems might even crash if you try to access unaligned memory cells (see here and here).

猫性小仙女 2024-08-01 11:46:32

其他汇编器中是否有等效的指令?

MASM 有一个对齐指令: http://msdn.microsoft .com/en-us/library/dwa9fwef(VS.80).aspx

Is there an equivalent instruccion in other assemblers?

MASM has an Align directive: http://msdn.microsoft.com/en-us/library/dwa9fwef(VS.80).aspx

强者自强 2024-08-01 11:46:32

它将所有内容对齐到 2 的 n 次方。 它不是一条指令,它是一个将被翻译成指令的指令

至于它的用法,例如:

mips32指令总是32位长。 因此每条指令都应该从字边界开始。 在代码开始之前添加 .align 指令,将内容对齐到 32 位。 这有很多好处,包括只需要 1 次内存访问来获取指令,并且它可能对指令缓存有利。

It aligns everything to the nth power of two. Its not an instruction, its a directive that will be translated into instructions

As for its usage,for exampe:

mips32 instructions are always 32 bits long. So each instruction should start on a word boundary. Adding an .align directive before the code starts, aligns things to 32 bits. This has many benefits, including that it only takes 1 memory access for the instruction´s fetch, and that it will probably be benefitial on the instruction cache.

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