Hi!
Is it better to align all data to DWORD?
Doesn?t the .use32 directive do it for you?
Is it better to align all data to DWORD?
Doesn?t the .use32 directive do it for you?
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)
Align 4 (4 bytes) (Dword)
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?
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?
sloppy,
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.
Regards,
hutch@movsd.com
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.
Regards,
hutch@movsd.com
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.
Result: remarkable speed increase ! (and that without any code change :) )
I tried the same with code alignment, but this did no effect.
Thanx for the answers, I?ll try to align as much as I can, hutch idea looks good.