The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: elmo on October 23, 2010, 04:50:26 AM

Title: is there a way to convert db to dd?
Post by: elmo on October 23, 2010, 04:50:26 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 a way to convert db to dd?
Post by: dedndave on October 23, 2010, 03:30:04 PM
        mov     al,ByteVal
        cbw     ;extend into AX
        cwde    ;extend into EAX
Title: Re: is there a way to convert db to dd?
Post by: vanjast on October 28, 2010, 06:17:16 PM
Then save it, if you need it later.
Title: Re: is there a way to convert db to dd?
Post by: dedndave on October 28, 2010, 06:54:13 PM
oh - i forgot to mention the obvious ones, too   :bg
        movsx   eax,byte ptr ByteVal
or
        movsx   eax,al
those instructions sign-extend the byte into EAX

if you want to zero-extend it...
        movzx   eax,byte ptr ByteVal
or
        movzx   eax,al