'align' instruction on MIPS

Eliseo Ocampos picture Eliseo Ocampos · Jun 20, 2009 · Viewed 12.4k times · Source

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?

Answer

schnaader picture schnaader · Jun 20, 2009

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