1

In NASM, these two instructions do the same thing:

mov WORD PTR [myVariable], 0xAA

mov WORD [myVariable], 0xAA

Is it necessary to include the "PTR"?

user247763
  • 191
  • 5
  • 15
  • 1
    Some assemblers (e.g., MASM, TASM) use `WORD PTR`, while other assemblers (e.g., NASM) use only `WORD`. It's necessary to include whatever your assembler expects you to include. Consult the documentation for details. – Cody Gray - on strike Jul 08 '17 at 19:04
  • 2
    My version of nasm (v2.10.01) gives an error for `PTR`. – Jester Jul 08 '17 at 19:06
  • assembly language is defined by the assembler, the program that reads it, if your tests show that with or without it produces then same result then that is your answer. If you want to try another assembler then you have to repeat the exercise... – old_timer Jul 08 '17 at 19:15
  • 1
    @old_timer It turned out that `mov WORD PTR [myVariable], 0xAA` does not work in NASM, I thought it did because I thought that the tutorial I am reading is using NASM, while in fact it is using MASM (I didn't test it in NASM because I don't have it installed on my current machine). – user247763 Jul 08 '17 at 19:21
  • masm and nasm are two different assemblers and although may claim to be compatible, doesnt mean the assembly languages actually are. so just install nasm and try it if you want to know what it does. – old_timer Jul 08 '17 at 22:03
  • @old_timer: NASM doesn't claim to be compatible with MASM. [That's a feature, not a bug](http://www.nasm.us/doc/nasmdoc2.html#section-2.2.2), as documented in the *Quick Start for MASM users* section of the manual. They on purpose designed a new syntax to be cleaner and with less "magic" going on. – Peter Cordes Jul 15 '17 at 02:48

0 Answers0