News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Variable initialisation

Started by Lonewolff, March 16, 2016, 09:18:05 AM

Previous topic - Next topic

Lonewolff

Hi Guys,

What is the difference between .data and .data?

Wouldn't it be better to initialise all data to zero in .data instead of the latter? Or does this somehow affect executable size?


; Why not do this?
.data
hWnd DWORD 0
hHeap DWORD 0
msg MSG <0>

; Instead of doing this?
.data?
;hHeap DWORD ?
;hWnd DWORD ?
;msg MSG <?>


Thanks in advance :)

jj2007

Quote from: Lonewolff on March 16, 2016, 09:18:05 AMOr does this somehow affect executable size?

It does indeed. Try yourself:
include \masm32\include\masm32rt.inc

.data
MyArray dd 250000 dup(0)

.code
start:
  MsgBox 0, str$(sizeof MyArray), "Bytes initialised:", MB_OK
  exit

end start

Lonewolff

So with '.data?' does this just allocate a space in RAM that can be filled in later on?

jj2007

Exactly. It must be one of the *Alloc functions doing that during process startup.