The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: elmo on October 23, 2010, 04:59:06 AM

Title: is there any way to convert db to dd?
Post by: elmo on October 23, 2010, 04:59:06 AM
;DWORD=DATA WORD
   ;DD=DATA DOUBLEWORD (DEFINE DOUBLEWORD)
   ;DB=DEFINE BYTE
   ;DW=DEFINE WORD
   ;DQ=DEFINE QUADWORD


I declare:
   hButton1            dd ?
   h               db 32 dup(?)


is there any way to convert db to dd?

So, if I do:
      invoke SetWindowText,hButton1,ADDR Caption
will give the same result with:
      invoke SetWindowText,h,ADDR Caption
where h contain the value of hButton1( after converted to dd).

I had try CWD (convert Word to double word) that return value in dx. But it still fail.
      CWD
      invoke SetWindowText,dx,ADDR Caption

http://www.masm32.com/board/index.php?PHPSESSID=45161102b7e9b36e503418a4d40f36ce&topic=3501.0
http://webster.cs.ucr.edu/Page_TechDocs/MASMDoc/ProgrammersGuide/Chap_04.htm

Don't multiple post in this forum.
Title: Re: is there any way to convert db to dd?
Post by: japheth on October 23, 2010, 06:02:17 AM

You are seriously confused and your questions gave me the impression that you don't have the faintest idea of what you're doing.

To get a useful response you'll have to tell what you want to do - on a "higher" level!
Title: Re: is there any way to convert db to dd?
Post by: Neil on October 23, 2010, 08:08:05 AM
Your data definitions are 2 completely different things.

   hButton1            dd ?     Undefined 4 byte (dd) variable.


   h               db 32 dup(?) 32 bit address pointer to undefined 32 byte buffer.
Title: Re: is there any way to convert db to dd?
Post by: someone on October 31, 2010, 07:49:17 PM

invoke SetWindowText,dword ptr h,ADDR Caption

or

mov ecx, dword ptr h
invoke SetWindowText,ecx,ADDR Caption

all memory is in the end just bits (grouped into bytes), all that matters is how it is defined
that is to say whether the compiler sees it as a combination of bytes, or a group of 4 bytes (aka dword)
Title: Re: is there any way to convert db to dd?
Post by: dedndave on October 31, 2010, 09:11:06 PM
you can create multiple labels to reference the same data with different sizes

DdRef   LABEL   DWORD
DwRef   LABEL   WORD
DbRef   DB      1,2,3,4

        mov     eax,DdRef        ;loads 4030201h into EAX
        mov     bl,DbRef         ;loads 1 into BL
        mov     cx,DwRef         ;loads 201h into CX
        mov     cx,DwRef[2]      ;loads 403h into DX


or, you can use the PTR operator to override the defined size

DbRef   DB      1,2,3,4

        mov     eax,dword ptr DbRef ;loads 4030201h into EAX