0

When I wrote mov edx, dword ptr[variable] It means pass the value of the variable to edx. However, when I wrote mov mm0, sword ptr[edx] It means pass the value pointed to by edx to mm0.

I want to know why the same code pattern have difference behaviors.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
strwake
  • 35
  • 3
  • 2
    It's not different. The symbol `variable` is a link-time-constant address, so you can use it in an addressing mode. Just like `edx` can hold a non-constant address. (BTW, MMX is basically obsolete with x86-64 which guarantees SSE2, and 32-bit pointers are also not normal for 64-bit code.) – Peter Cordes Oct 02 '21 at 03:19
  • 1
    Possibly a duplicate of [x86 Assembly pointers](https://stackoverflow.com/q/43769467) - does that answer your question? Or maybe [Why in NASM do we have to use square brackets (\[ \]) to MOV to memory location?](https://stackoverflow.com/q/49534661) - it's simpler in NASM, a symbol name like `variable` consistently works as an address, never implicitly dereferenced, just like a C `char variable[]`. MASM's design is super weird – Peter Cordes Oct 02 '21 at 03:40
  • Thank you very much for your answer. There are some concepts in your answer that I don't understand very deeply. I think I should systematically learn assembly language. – strwake Oct 02 '21 at 09:59

0 Answers0