ChatGPT解决这个技术问题 Extra ChatGPT

What does `dword ptr` mean?

Could someone explain what this means? (Intel Syntax, x86, Windows)

and     dword ptr [ebp-4], 0

E
Evan Carroll

The dword ptr part is called a size directive. This page explains them, but it wasn't possible to direct-link to the correct section.

Basically, it means "the size of the target operand is 32 bits", so this will bitwise-AND the 32-bit value at the address computed by taking the contents of the ebp register and subtracting four with 0.


The "d" in "dword" stands for "double". A word is 16 bits.
Why is the PTR part needed? Isn't dword enough to encode the size? NASM does not use ptr AFAIK.
@JeremyP Word mean is changing according to processors. After reading this article can you say again word is 16 bits or you are only defining the simple meaning of word which means two bytes? Modern processors, including embedded systems, usually have a word size of 8, 16, 24, 32, or 64 bits, while modern general purpose computers usually use 32 or 64 bits. en.wikipedia.org/wiki/Word_(computer_architecture)
@uzay95 The question is tagged "x86" so we are talking specifically about the Intel x86 architecture, in which a word is 16 bits wide. According to your article, even the x86_64 has a word size of 16 bits.
@CiroSantilli新疆再教育营六四事件法轮功郝海东 Did you figure out why PTR is needed?
C
Community

Consider the figure enclosed in this other question. ebp-4 is your first local variable and, seen as a dword pointer, it is the address of a 32 bit integer that has to be cleared. Maybe your source starts with

Object x = null;

L
L4m0r

It is a 32bit declaration. If you type at the top of an assembly file the statement [bits 32], then you don't need to type DWORD PTR. So for example:

[bits 32]
.
.
and  [ebp-4], 0