Is it better to align all data to DWORD?
Doesn?t the .use32 directive do it for you?
Posted on 2002-08-22 12:55:03 by slop
I think it would be a good idea to align on DWord boundary when using MASM32 since i believe it uses the flat memory model by default. But if your data is byte sized then align on a byte.

Align 4 (4 bytes) (Dword)
Posted on 2002-08-22 19:52:48 by IwasTitan
Thanx, Youweretitan ;)

Then the flat model is byte aligned?
So then what for the .use32 directive, just to tell the assembler to use 32-bits registers and opcodes?
Posted on 2002-08-23 08:38:54 by slop

A couple of things, most memory as you allocate it is at least 4 byte aligned, some on larger boundaries so unless you are starting from an uneven position in memory, the alignment should be OK.

Most stuff in win32 IS 4 byte aligned or larger and most assemblers/compilers do this with the stack as well so your procs are aligned at start as well but it is worth setting up variables on the stack at 4 byte size first, then 2 byte if you use them and BYTE data last. One of the tricks with byte data is to allocate it in sizes divisible by 4 so that it does not mess up the alignment of the following data.


Posted on 2002-08-23 08:50:41 by hutch--
sometimes ago I redesigned my whole software project from unaligned data to dword aligned.
Result: remarkable speed increase ! (and that without any code change :) )

I tried the same with code alignment, but this did no effect.
Posted on 2002-08-23 09:59:56 by beaster
Thanx for the answers, I?ll try to align as much as I can, hutch idea looks good.
Posted on 2002-08-23 10:13:48 by slop