We use align 16 to position especially loops at the beginning of a 16 byte area for most effective speed. Assemblers pad the space with no operation instructions, which are not usually NOP.

MASM uses for alignment padding
 0 bytes = nothing
 1 byte  = NOP {90}
 2 bytes = MOV edi, edi {8BFF}
 3 bytes = lea ecx, {8D4900}
 4 bytes = lea esp, {8D642400}
 5 bytes = add eax, 0x0 {0500000000}
 6 bytes = lea ebx, {8D9B00000000}
 7 bytes = lea esp, {8DA42400000000}
 8 bytes = 7 + 1
 9 bytes = 7 + 2
10 bytes = 7 + 3
11 bytes = 7 + 4
12 bytes = 7 + 5
13 bytes = 7 + 6
14 bytes = 7 + 7
15 bytes = 7 + 7 + 1
{16 bytes = nothing}

Of these the add instruction in #5 & #12 effectively zeroes the carry which may mess up some program results (it did for mine).

I wrote a program in HLA to demonstrate. It consists of

stc 
align 16
mov eax, 0
rcr eax, 1


However the stc is moved down, resulting in different amount of padding being needed. The result should print eax=1 each time, but it gets reset to 0 at 5 and 12 padding spaces being used.

	console.cls();
console.gotoxy(4, 15);
stdout.put ( nl "STC Test:", nl nl);

align (16);
stc;
mov (0, eax);
align (16);
rcl (1, eax);
stdout.put ( eax, " " );

align (16);
nop;
stc;
mov (0, eax);
align (16);
rcl (1, eax);
stdout.put ( eax, " " );

align (16);
nop;
nop;
stc;
mov (0, eax);
align (16);
rcl (1, eax);
stdout.put ( eax, " " );

align (16);
nop;
nop;
nop;
stc;
mov (0, eax);
align (16);
rcl (1, eax);
stdout.put ( eax, " " );

align (16);
nop;
nop;
nop;
nop;
stc;
mov (0, eax);
align (16);
rcl (1, eax);
stdout.put ( eax, " " );

align (16);
nop;
nop;
nop;
nop;
nop;
stc;
mov (0, eax);
align (16);
rcl (1, eax);
stdout.put ( eax, " " );

align (16);
nop;
nop;
nop;
nop;
nop;
nop;
stc;
mov (0, eax);
align (16);
rcl (1, eax);
stdout.put ( eax, " " );

align (16);
nop;
nop;
nop;
nop;
nop;
nop;
nop;
stc;
mov (0, eax);
align (16);
rcl (1, eax);
stdout.put ( eax, " " );

align (16);
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
stc;
mov (0, eax);
align (16);
rcl (1, eax);
stdout.put ( eax, " " );

align (16);
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
stc;
mov (0, eax);
align (16);
rcl (1, eax);
stdout.put ( eax, " " );

align (16);
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
stc;
mov (0, eax);
align (16);
rcl (1, eax);
stdout.put ( eax, " " );

align (16);
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
stc;
mov (0, eax);
align (16);
rcl (1, eax);
stdout.put ( eax, " " );

align (16);
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
stc;
mov (0, eax);
align (16);
rcl (1, eax);
stdout.put ( eax, " " );

align (16);
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
stc;
mov (0, eax);
align (16);
rcl (1, eax);
stdout.put ( eax, " " );

align (16);
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
stc;
mov (0, eax);
align (16);
rcl (1, eax);
stdout.put ( eax, " " );

align (16);
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
stc;
mov (0, eax);
align (16);
rcl (1, eax);
stdout.put ( eax, " " );

align (16);
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
stc;
mov (0, eax);
align (16);
rcl (1, eax);
stdout.put ( eax, " " );

Posted on 2005-11-03 06:17:08 by V Coder
IIRC MichaelW already reported this bug at masmforum.
Posted on 2005-11-03 07:55:18 by MazeGen
Perhaps we should have a "MASM's bugs" thread at the FAQ... what do you think? :)
Posted on 2005-11-03 09:11:46 by QvasiModo
I would appreciate that, seriously...
Posted on 2005-11-03 09:16:41 by MazeGen