添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams Note that the example here is almost never what you actually want. To zero memory, use mov dword ptr [ebp-4], 0 . Using and saves 3 bytes of machine-code size, using an 8-bit immediate instead of 32-bit, at the cost of performance (load/AND/store for a memory destination AND instead of just a pure store.) Peter Cordes Jan 14 at 11:20

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.

Why is the PTR part needed? Isn't dword enough to encode the size? NASM does not use ptr AFAIK. Ciro Santilli OurBigBook.com Jun 20, 2015 at 16:55 @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 Dec 25, 2016 at 21:35 @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. JeremyP Dec 27, 2016 at 11:27

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;

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