VERY confused about the align directive in asm.

Searched the net and didn't find a lot of current info on data/code alignment for asm on current processors.

Would the following be correct?

;________________________________________________
; align data on DWORD (4b) / code on PAGE (16b) boundaries
;

.data

align 4
st_1 dd 100 dup (0)
st_2 dd 100 dup (0)

.code

align 16
Branch_1:

align 16
Branch_2 proc
Branch_2 endp

-------------------------------------------------------------------------------

1) would i need a second align 4 before st_2?
2) would it be sufficient to do
.data
align 4
...
.code
align 16
...

i.e. have only one align directive per segment
3) what if i have .data segments interspered in the .code segment?
.code
...
.data
; align 4?
...
.code
...

-----------------------

the above all assumes that we are programming for pentium processors (.586) and 32 bit programs.
Posted on 2001-11-18 13:31:45 by grv575
1) no, since you have an array of DWORDs, the data after the array
will be DWORD aligned as well.

2) not if you want to align a particular piece of data. The align
directive only takes effect where you write it.
Also, when using the simplified segment directives (.code, .data)
you cannot (afaik) do aligns larger than 4 bytes.

3) all .code is merged into one code segment, the same goes for .data. So switching to .data and back to .code doesn't disrupt
your code stream in any way.
Posted on 2001-11-18 14:47:16 by f0dder