NASM

From OSDev Wiki
Jump to navigation Jump to search

The Netwide Assembler (NASM) is a popular assembler for the x86/x64 architecture. NASM is open source software and is freely available from their official website.

NASM is available for many operating systems, including (but not limited to) Windows, GNU/Linux, BSD and Solaris. Because it is Open Source, NASM can be made to run on pretty much any operating system, and is a common choice for a first port to a hobby OS.

Comparison to GAS

Those preferring it over gas claim its easy syntax and powerful macro capabilities are a plus. On the other hand, other users claim gas is better integrated into the GNU Compiler Collection (GCC) and has more cross-platform capabilities. Similar to editor and browser discussions, this is likely to remain an unresolved debate.

Tips

  • Use "-w+orphan-labels". Often, labels without colons were not really intended to be labels, and are actually misspellings or typos. This flag will cause NASM to warn you if there are labels without colons.
  • Explicitly define your sections. While NASM defaults to .text, it doesn't put labels declared as globals in .text correctly, unless the label is preceded by a section directive at some point.

See also

Articles

External Links