Questions tagged [nasm]

NASM is the Netwide Assembler, an open-source x86/x64 assembler. It aims at being portable, modular and at having a simple syntax.

NASM is the Netwide Assembler, an open-source x86/x64 assembler. It aims at being portable, modular and at having a simpler syntax than the most commonly used open-source assembler gas. It supports a whole range of output formats (including ELF, PE/COFF), plain binary (a.out) and supports Intel 64, 32, 16 and 8 bit syntaxes.

For x86 assembly info in general, see the many links to reference manuals/docs, optimization/performance guides, tools, and debugging tips in the x86 tag wiki

See also:

  • The NASM homepage

  • The NASM manual

  • An older version of the NASM Appendix A that has text descriptions with every instruction entry, along with the CPU they were introduced in (8086, 186, 386, etc.) But it only includes MMX and older; the current version of the appendix stripped the text because SSE2/AVX/etc. have so many instructions.

  • https://yasm.tortall.net/ YASM is a NASM-compatible assembler with some nice features (e.g. long NOPs by default), but development has stalled and it doesn't support AVX512.

  • x264 has a very large set of NASM macros that attempt to abstract the calling conventions of x86_32, win64, linux64, and also do CPU feature-level checking. (e.g. to declare a function/block as SSSE3, and catch accidental usage of an SSE4.1 instruction).

    It is very intrusive and makes your source code look significantly different from normal x86 asm (macros for register names). It's licensed separately (ISC, not GPL) so it can be used in other projects.

    One copy of it can be found in the libvpx (VP8/9 video codec) source tree. x264 itself also has a copy, and see those projects for DSP functions using it.

5046 questions
121
votes
9 answers

How to write hello world in assembly under Windows?

I wanted to write something basic in assembly under Windows. I'm using NASM, but I can't get anything working. How do I write and compile a hello world program without the help of C functions on Windows?
feiroox
  • 3,069
  • 8
  • 31
  • 31
107
votes
7 answers

Is it worthwile to learn assembly language?

Is it still worthwhile to learn ASM? I know a little of it, but I haven't really used it or learned it properly because everything I learn to do in assembler I can do in 1/10th the time with some language like C or C++. So, should I really learn…
ApprenticeHacker
  • 21,351
  • 27
  • 103
  • 153
75
votes
9 answers

What do the brackets mean in NASM syntax for x86 asm?

Given the following code: L1 db "word", 0 mov al, [L1] mov eax, L1 What do the brackets in [L1] represent? This question is specifically about NASM. The other major flavour of Intel-syntax assembly is MASM style, where…
joek1975
  • 3,573
  • 5
  • 40
  • 44
61
votes
7 answers

What does ORG Assembly Instruction do?

can anyone give me a comprehensive description about ORG directive? When and why is it used in assembly written applications? Using Nasm on x86 or AMD64.
sepisoad
  • 2,201
  • 5
  • 26
  • 37
59
votes
5 answers

NASM Vs GAS (Practical differences)

I'm not trying to prompt an Intel vs AT&T war (moot point anyway, now that they both support Intel syntax) or ask which one is "better" per se, I just want to know the practical differences in choosing one or the other. Basically, when I was picking…
Elliott
  • 1,127
  • 1
  • 9
  • 16
56
votes
2 answers

MASM/NASM Differences

What are the syntax differences between the NASM and MASM assemblers?
joek1975
  • 3,573
  • 5
  • 40
  • 44
47
votes
1 answer

Obtaining peak bandwidth on Haswell in the L1 cache: only getting 62%

I'm attempting to obtain full bandwidth in the L1 cache for the following function on Intel processors float triad(float *x, float *y, float *z, const int n) { float k = 3.14159f; for(int i=0; i
Z boson
  • 32,619
  • 11
  • 123
  • 226
41
votes
3 answers

What's the difference between equ and db in NASM?

len: equ 2 len: db 2 Are they the same, producing a label that can be used instead of 2? If not, then what is the advantage or disadvantage of each declaration form? Can they be used interchangeably?
paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
41
votes
4 answers

What is global _start in assembly language?

This is my assembly level code ... section .text global _start _start: mov eax, 4 mov ebx, 1 mov ecx, mesg mov edx, size int 0x80 exit: mov eax, 1 int 0x80 section .data mesg db 'KingKong',0xa size …
vikkyhacks
  • 3,190
  • 9
  • 32
  • 47
40
votes
2 answers

What are the sizes of tword, oword and yword operands?

What are the sizes of tword, oword and yword operands, as used in the NASM/YASM manual? And on a related note, is there a trick or underlying idea to these names? Is there a way by which bigger word sizes are given logical names? I know that while…
Daniel A.A. Pelsmaeker
  • 47,471
  • 20
  • 111
  • 157
38
votes
7 answers

Basic yet thorough assembly tutorial (linux)?

I want to learn some practical assembly language having just learned the basic concepts in class. Are there any decent books or tutorials (nasm, etc) that would be recommended?
not-too-smatr
  • 599
  • 2
  • 7
  • 10
38
votes
5 answers

A good NASM/FASM tutorial?

Does anyone know any good NASM or FASM tutorials? I am trying to learn assembler but I can't seem to find any good resources on it.
Callum Rogers
  • 15,630
  • 17
  • 67
  • 90
37
votes
1 answer

Segmentation fault when popping x86 stack to access function arg

I'm trying to link x86 assembly and C. My C program: extern int plus_10(int); # include int main() { int x = plus_10(40); printf("%d\n", x); return 0; } My assembly program: [bits 32] section .text global plus_10 plus_10: …
Susmit Agrawal
  • 3,649
  • 2
  • 13
  • 29
37
votes
1 answer

ASM: MASM, NASM, FASM?

I have done ARM assembly programming and I would like to learn the Intel Assembler. I keep hearing all these different F/M/N/ASMs mentioned- but I am unsure how they related to what I wish to achieve? Could somebody please help me identify what I…
user997112
  • 29,025
  • 43
  • 182
  • 361
36
votes
4 answers

Basic use of immediates vs. square brackets in YASM/NASM x86 assembly

Suppose I have the following declared: section .bss buffer resb 1 And these instructions follow in section .text: mov al, 5 ; mov-immediate mov [buffer], al ; store mov bl, [buffer] ;…
InvalidBrainException
  • 2,312
  • 8
  • 32
  • 41
1
2 3
99 100