News:

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

[q]forcing data/code alignment

Started by Jeff, June 30, 2005, 01:20:30 AM

Previous topic - Next topic

Jeff

i (somewhat) understand the pros/cons to having data and code aligned on certain boundaries like having them start at even addresses to increase the speed and such.  so i want to make sure i align data at 4 byte boundaries and code on even (2 byte boundaries).  this brings me to my questions:

is there a (simple) way to make data/code to be aligned at these boundaries within its segment instead of manually placing NOP/ALIGN/EVEN/etc... throughout my code?

also

what is the range of values to be used with the ALIGN directive?  cant put 8 or 16, that overkill?
[edit]
ok got it, use the .486 and above model to go beyond 4

hutch--

Wth data alignment its speed. Trick is to align by at least the data size so that the processor reads the piece of data in one read, not 2. Code alignment varies from processor to processor but may respond well to aligning a label that gets hit a lot of times.

Place the ALIGN keyword before the data you must align in the DATA section. Set it to the size of the data you want to align and with code labels, try a minimum of 4 bytes. The ALIGN directive expects powers of two.



  .data
  align 4
  var dd 1234
  ...........

  align 4
  label:

Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php