News:

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

dd or dword ?

Started by G`HOST, December 23, 2005, 06:45:59 PM

Previous topic - Next topic

G`HOST

Well,Whats the difference,as far as my knowledge goes,
dword==data word   &
dd == data doubleword.
if i m right then why replacing dword with dd at some places doesnt have any effect on the program.
But this thing doesnt work while declaring local variables.

for example in global variables replacing hMenu DWORD ? with
hMenu dd ? works.
But if replaced in LOCAL hMenu:DWORD with hMenu:dd it gives following error :
error A2008: syntax error : dd

MusicalMike

Yes. Heres the long and short of it.

When declairing global variables, you can do the following

labelname db 0 ; define byte
labelname dw 0 ; define word
labelname dd 0  ; define double word
labelname dq 0 ; define quad word

You can also do do this if you want to reserve but not define locations in memory

labelname label byte
labelname label word
labelname label dword
labelname label qword

What you must realize though is, db, dw, dd, and dq are NOT real assembly language mnumonics. These are sort of like keywords. When an exe file is loaded into memory for execution, there are no instructions defined by the x86 microprocessor that reserves memory, instead what happens is, the loader looks at the data defined in the exe files various sections and copies them to their respective offsets in memory. This is one of the reasons why you are not allowed to use the dd, dw, db, etc to create local variables. Tecnically speaking. the LOCAL keyword is also not really part of the x86 archetecture, on the real low level, local variables are created by pushing data onto the stack and addressing it by using inderect addressing on the esp register, however until you get more experience at this, I would not recomend trying it. The words byte, word, dword , and qword are size dirrectives defined internally by masm. The LOCAL macro expects to see one of those, or atleast an API type. Even if you could do LOCAL hMenu:dd, it would for all intents and purposes mean the same thing as LOCAL hMenu:DWORD. dd stands for Define Double Dword. I guess what I am saying is, what are you trying to do where it would make a difference?

MichaelW

G`HOST,

DD and DWORD both specify a 32-bit doubleword, but DD is an initializer and DWORD is a qualified type, that starting with MASM 6.0 can also be used as an initializer. LOCAL (and PROC and PROTO) expect a qualified type rather than an initilaizer.

See DataTypes here:

http://webster.cs.ucr.edu/Page_TechDocs/MASMDoc/ProgrammersGuide/Chap_01.htm

Declaring Integer Variables here:

http://webster.cs.ucr.edu/Page_TechDocs/MASMDoc/ProgrammersGuide/Chap_04.htm

And start at Defining Procedures here:

http://webster.cs.ucr.edu/Page_TechDocs/MASMDoc/ProgrammersGuide/Chap_07.htm

eschew obfuscation