From the MSDN entry for the ALIGN directive (using MASM):
ALIGN [[number]] Aligns the next variable or instruction on a byte that is a multiple of number.
This is often used to optimize the placement of the structure in memory, since all new x86 architectures have a word length of more than 8 bits (usually 32 or 64 bits). This means that you can store 4 or 8 bytes of data in one memory location.
If you used 4 or 8 as the size of the alignment byte, it would ensure that the next byte to be assembled would be placed in a byte position with several 4 or 8, which corresponds to the length of the machine word in this example (other alignment values ββare often useful depending on your application).
For example, building the following file (compiled syntax):
org $0x00 db $0x01 db $0x02 .align 4 db $0x03
This ensures that 0x03 is placed on an address that is an integer multiple of 4 (including zero!). The assembler spit out the following bytes, starting at $0x00 :
Address | Data --------------- 0x00 | 01 0x01 | 02 0x02 | XX/00 0x03 | XX/00 0x04 | 03 .... | ....
source share