News:

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

is there any way to convert db to dd?

Started by elmo, October 23, 2010, 04:59:06 AM

Previous topic - Next topic

elmo

;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.
be the king of accounting programmer world!

japheth


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!

Neil

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.

someone


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)

dedndave

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