News:

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

Getting Started

Started by WayneSallee, April 28, 2007, 03:26:28 AM

Previous topic - Next topic

dsouza123

A snippet of code that may clear up declaring some common types of variables.

.data
   varb0 db    3                 ; both db and byte  reserve a byte  ( 8-bit)
   varb1 byte  3

   varw0 dw    3000              ; both dw and word  reserve a word  (16-bit)
   varw1 word  3000

   vard0 dd    3000000           ; both dd and dword reserve a dword (32-bit)
   vard1 dword 3000000

   varq0 dq    3000000000000000  ; both dq and qword reserve a dword (64-bit)
   varq1 qword 3000000000000000

WayneSallee

What's the 32 bit equivilant of the 16 bit "dw 0" statement?

Wayne Sallee
Wayne's Pets
Wayne@WaynesPets.com

dsouza123

#17
dd 0

To initialize a dword in the .data section with 0

   hold32 dd 0


To initialize a byte in the .data section with 0

   hold8 db 0


To initialize a word in the .data section with 0

   hold16 dw 0


To initialize a qword in the .data section with 0

   hold64 dq 0


Heading off a point of confusion:

dd means data of type double word, 32 bits

db means data of type byte, 8 bits

dw means data of type word, 16 bits

dq means data of type quad word, 64 bits

When looking at a d?  with ? == d,b,w,q ignore the leading d,
just look at the second character as the initial for the type.

Examples:
dd ignore the leading d, leaves d so the type is dword, aka double word, 32 bit
db ignore the leading d, leaves b so the type is byte, 8 bit
dw ignore the leading d, leaves w so the type is word, 16 bit
dq ignore the leading d, leaves q so the type is qword, aka quad word, 64 bit

edit: fixed dq  had qw in error

WayneSallee

Thanks dsouza123 !

That's what I needed to know.

note: at one point you typed "qw" instead of "dq".
I just though I would point that out in case someone else was wanting to learn from the post.

Thanks,

Wayne Sallee
Wayne's Pets
Wayne@WaynesPets.com

japheth

Quote from: WayneSallee on April 29, 2007, 12:56:53 PM
So why did you not answer my question? Were you affraid that you might give me a wrong answer, and that someone else would tell you that you were wrong?

No. I wanted to give you a chance to find the error yourself, which probably would have been more satisfying for you.

WayneSallee

Quote from: japheth on April 29, 2007, 07:29:24 PM

No. I wanted to give you a chance to find the error yourself, which probably would have been more satisfying for you.


No it would not have been more satisfying to me. I already have enough self confidence, thank you :-)

Wayne Sallee
Wayne's Pets
Wayne@WaynesPets.com