1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[Q] dword ptr ds:

Discussion in 'Programming' started by Ation, Sep 5, 2010.

  1. Ation

    Ation s. mod Moderator Donor

    Could someone explain me what is this "dword ptr ds:" and in which cases it must be used?
    For example we've a part of BP GM AA script converted to C++ here:
    Code (Text):
    1.         call [BPGMCall]
    2.         [COLOR="Red"]mov    eax,dword ptr ds:[0x00ADAAD4][/COLOR]
    3.         [COLOR="RoyalBlue"]mov  eax,[eax+0x18][/COLOR]
    4. [COLOR="Red"]       sub eax,dword ptr ds:[Delay]
    5.         cmp eax,dword ptr ds:[NextGo][/COLOR]
    6.         jbe Exit
    7.         [COLOR="Red"]mov    eax,dword ptr ds:[0x00ADAAD4][/COLOR]
    8.         [COLOR="RoyalBlue"]mov  eax,[eax+0x18][/COLOR]
    9.         [COLOR="Red"]add    eax,dword ptr ds:[Delay][/COLOR]
    10.         [COLOR="RoyalBlue"]mov  [NextGo],eax[/COLOR]
    11.         jmp Exit2
    Why it's used in red lines of the script, and not used in blue lines? The rest is clear to me.
     
  2. DarkSpace

    DarkSpace Well-Known Member Coder

    i have been coding for a while but what i came to notice is that
    if you dont use dword ptr, its gonna treat it as a byte when looking at a CE memory view.

    so mov eax, [0x00ADAAD4]
    would move what ever value is stored there as a single byte 0x00
    but when i put dword ptr it changes that byte to a 4 byte array. 0x00 00 00 or 0x000000

    but thats just from what i have noticed.
     
  3. Ation

    Ation s. mod Moderator Donor

    Alright, thanks.
    I guess I understand it now. :)
     
  4. fag

    fag Banned Banned

    Most compilers should be able to infer the size of the pointer you're derefencing. The size shouldn't need to be explicitly stated, unless it is unclear.
     

Share This Page