42

What are the syntax differences between the NASM and MASM assemblers?

starblue
  • 51,675
  • 14
  • 88
  • 146
joek1975
  • 3,303
  • 5
  • 36
  • 44
  • Related: [How to know if an assembly code has particular syntax (emu8086, NASM, TASM, ...)?](https://stackoverflow.com/q/44853636) shows some syntax diff examples. – Peter Cordes May 22 '21 at 21:20

2 Answers2

46

Section 2.2 of the NASM documentation is titled Quick Start for MASM Users which lists the important differences between NASM and MASM.

Greg Hewgill
  • 828,234
  • 170
  • 1,097
  • 1,237
  • 4
    in that section is stated: "NASM Is Case-Sensitive" However, MASM also can be case-sensitive, simply use: option casemap :none –  Aug 31 '16 at 20:46
-2

What an interesting question. The difference between them is, they are not compatible! But then again, nasm assemblers are not compatible amongst themselves, it seems. Learned it the hard way, while compiling libvpx. I think this single example says it all:

ml64.exe (MSVC 2019) -> throws

nasm for windows -> compiles some *.asm files, throws on some

invalid combination of opcode and operands

Huh?

yasm for windows -> works

llvm assembler (debian) -> throws:

    /usr/lib/llvm-13/bin/llvm-as

https://packages.debian.org/experimental/llvm-13

yasm (debian) -> works

nasm (debian) -> works

GNU assembler -> ???

https://manpages.debian.org/experimental/binutils-common/as.1.en.html

WRFan
  • 17
  • 2
  • 1
    GAS / llvm-as in `.intel_syntax noprefix` mode use syntax that's pretty much MASM for instructions, but with directives that are specific to them. – Peter Cordes May 22 '21 at 21:17
  • `nasm -felf64 foo.asm` should work the same way no matter what host you're building on. If you have some asm files that assemble on Linux but not Windows, it's probably because of building with different bitness (e.g. `nasm -fwin32` vs. `nasm -felf64`), or something about directives, or possibly the .asm uses `%if` conditional stuff an does something different on Windows.) Without an example of the instructions, it's not useful to say that NASM on windows errors. What, on every file in general? No, of course not. – Peter Cordes May 22 '21 at 21:19