Hello.

Is there an option in MASM to keep a specified data-alignment
until a different alignment is forced?

It's just because I have to write "align dword" again and again
for each variable.

Thx for help!


aweX <-
Posted on 2003-01-23 06:08:53 by aweX
I'm not sure what you're asking, but the only time you need to use ALIGN is when you're not at the desired boundary. For example all of the following will be dword aligned since they all generate 4 bytes of data:

  align 4

hInst dd 0
hMain dd 0
hTB dd 0
hView dd 0
tbHght dd 0

If you insert something in the middle that isn't dword aligned, then you'ld need another align statement. For example:

  align 4

hInst dd 0
hMain dd 0
myText db "some text",0 ; 10 bytes of text
align 4
hTB dd 0
hView dd 0
tbHght dd 0

You can use the .LST file to help determine when to use align. For dwords if the location ends with 0 4 8 or C it's already aligned.

:)
Posted on 2003-01-23 09:59:59 by S/390
Well, since I also use word and byte datatypes, it wouldn't be too bad to
have one command available to let MASM do all the aligning.

I tend to write user-friendly apps, so I always have a bunch of strings and
each of them needs a seperate align statement.

...
Posted on 2003-01-24 05:01:58 by aweX
The only reason I could see to align strings is if you intend to do extensive manipulations 2 or 4 bytes at a time. From your description, this does not seem to be your case and aligning strings would serve no purpose.

Just take the habit of putting all your strings together at the end of your data section so they don't interfere with the alignment of the other data.

Raymond
Posted on 2003-01-24 22:16:20 by Raymond
I agree, string processing usually dosn't gain much from alignment. I guess the 1 big exception would be the special case for REP MOVSD. But it needs to move at least 64 bytes, and the operands need to be align 8 for it to kick in.

There are special cases, but in general just keep all your strings together at the end and don't worry about their alignment. Try to keep all your DWs together, and DDs together.

By the way, you should try to avoid using DW in 32 bit mode, as much as possible. Most 16 bit operands use an instruction prefix that slows things down.

:)
Posted on 2003-01-25 12:03:18 by S/390