News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

aligning

Started by ochazuke, December 27, 2004, 03:34:46 AM

Previous topic - Next topic

ochazuke

can data be aligned in the .data? section?

hutch--

It surely can. As long as you set the processor model at the start of the file to .486 or higher, you can align data by up to 16 bytes. On DWORD size data you normally require alignment by 4 bytes.

align 2    ; old WORD alignment
align 4    ; normal DWORD alignment
align 8
align 16

With SSE/2 and other specialised circumstances where you need alignment by 32 bytes you allocate memory and write the data to an aligned location in the memory buffer.

You normally place the "align" directive before the item that needs to be aligned in the .DATA section like as follows.

  .data?
    align 4
    myitem dd ?
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ochazuke

Thanks for the reply!  I wonder though, how is data in the .data? section allocated?  In my project I have to allocate about 600kb, and when I had it in the .data section, not only did the assembling take forever but my application size increased by about 600 kb  :eek.

donkey

The .data? section is uninitialized data, it does not add to the size of your executable. The .data section however does add to the size of the executable. Generally you can rely on uninitialized data being filled with 0 so if you are just creating empty data put it in the .data? section as there is no need to initialize it to zero.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable