Mail Archives: djgpp/1997/07/31/13:17:40
You wrote:
>Maybe I didn't ask the right question :-)
>
>I Wanted to know if I can find documentation on WHY it is important to
>align data...
On a 386-class machine, the only reason is for performance. The 386 has a
32-bit bus. If you try to access, say, a 32-bit operand, and it isn't
aligned on a 32-bit boundary, it will require two bus cycles instead of one
to do the access. The on-chip cache also works better with certain
alignments, but I don't know all the details. Looking at GCC's assembly
output may give you some ideas about what kind of alignments are a good idea.
On some RISC processors, alignment is required, and not having it will cause
an exception.
Nate Eldredge
eldredge AT ap DOT net
- Raw text -