News:

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

align?

Started by JHER VON ARBANEL, November 20, 2005, 05:46:30 PM

Previous topic - Next topic

JHER VON ARBANEL

 hi me again ... when and where i have to use align ? :bdg thx bye

madMASM

do you mean stack align? i've not heard or used align much, but I'm pretty sure ive heard it before

MichaelW

AFAIK outside of SSE/SSE2 data and a few API/Windows-related things, you don't have to use align, but you can as an optimization. For more information:

http://www.agner.org/assem/#optimize

http://www.visionx.com/markl/optimization_tips.htm

eschew obfuscation

hutch--

JHER,

Align is a directive to the assembler that makes the following instruction or piece of data line up with a specified byte count from the begining of the file. The normal alignments are 2 4 8 and 16. This is done for a reason especially with data. Modern processors natively read data at a 4 byte boundary and with larger data types it can be either 8 or 16 byte boundaries. If the data that has to be read is not aligned to the required boundary, the processor must make 2 reads to get the same piece of data which is a lot slower.

Try this example, its crude but it should make sense. The following line is a character representation of data in memory.

1111222233334444555566667777888899990000

Numbers are grouped in lots of 4 for the example. If for example you read 3333 you get it in one read by the processor where if you try and read 1222 the processor will get the 1st "1" from the block 1111 and the last 3 twos "222" from the block "2222". The start of each number block is a block of 4 from the start. This data in each block is 4 BYTE aligned.

In code rather than data, if you ae chasing speed, you often align a label or the start of a procedure so if it is being called at high speed and sometimes it makes a speed difference.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

JHER VON ARBANEL

thx hutch and michelw,, ur post help me alot.... ,... but u must do something with those lamers that post msgs whitout sense... and just try to increase their post ranking :bdg

thx ...