News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Alignment

Started by Posit, May 14, 2005, 11:01:10 AM

Previous topic - Next topic

Mark_Larson


  The bigger the data size the worse the penalty for mis-aligned data.  I did some code to show the alignment problems with an MMX version of a string copy routine.

http://www.masmforum.com/simple/index.php?topic=1589.45  - search for "alignment".  The orignal code ran in 87 cycles accessing 8 bytes at a time ( MMX registers).  The misaligned code caused it to run in about 250-280 cycles depending on how unaligned it was.  Other than the misaligned data, there are no other changes to the code.
BIOS programmers do it fastest, hehe.  ;)

My Optimization webpage
htttp://www.website.masmforum.com/mark/index.htm

Randall Hyde

Quote from: hutch-- on May 15, 2005, 01:58:13 AM

BYTE data can be any single byte.

WORD data should be "01" or "23"

DWORD data should only be "0123".



Intel's documentation (for the PIV) claims that word access of the form "12" are also fine. Also, most of the time you only get a big hit if the data object crosses a cache line.
Cheers,
Randy Hyde

James Ladd

ok, so now I know how to align my data and procedures.
But am I right in thinking I can align the code within a procedure using an align statement as well ?
If I use this align keyword, with masm put NOPs in the code to make it pad out ?

MichaelW

QuoteIf I use this align keyword, with masm put NOPs in the code to make it pad out ?

We beat that subject to death here:

http://www.masmforum.com/simple/index.php?topic=1622.0
eschew obfuscation

James Ladd

Michael, Thanks for beating it one more time :)