'align' instruction on MIPS

12,910

Solution 1

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

Solution 2

Is there an equivalent instruccion in other assemblers?

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

Share:
12,910
Eliseo Ocampos
Author by

Eliseo Ocampos

"Learn to unlearn"

Updated on June 09, 2022

Comments

  • Eliseo Ocampos
    Eliseo Ocampos almost 2 years

    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?

  • Eliseo Ocampos
    Eliseo Ocampos almost 15 years
    Thanks for the additional clarifications in external links!
  • Vikram Dattu
    Vikram Dattu about 7 years
    How about storing double float on stack? It needs 8 byte alignment right?
  • Tom
    Tom about 7 years
    Yes, doubles align to 64 bits