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 asm 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's 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.

4372 questions
103
votes
8 answers

How to write hello world in assembler under Windows?

I wanted to write something basic in assembly under Windows, I'm using NASM, but I can't get anything working. How to write and compile hello world without the help of C functions on Windows?
feiroox
  • 2,801
  • 7
  • 29
  • 30
99
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
  • 19,279
  • 24
  • 94
  • 151
68
votes
8 answers

What do the brackets mean in x86 asm?

Given the following code: L1 db "word", 0 mov al, [L1] mov eax, L1 What do the brackets ([L1]) represent?
joek1975
  • 3,303
  • 5
  • 36
  • 44
51
votes
5 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
  • 1,957
  • 5
  • 21
  • 35
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
  • 29,230
  • 10
  • 105
  • 195
42
votes
2 answers

MASM/NASM Differences

What are the syntax differences between the NASM and MASM assemblers?
joek1975
  • 3,303
  • 5
  • 36
  • 44
42
votes
3 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
  • 935
  • 1
  • 7
  • 15
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
  • 14,817
  • 15
  • 62
  • 88
36
votes
1 answer

Segmentation fault when popping x86 stack

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,280
  • 2
  • 10
  • 25
34
votes
2 answers

Base pointer and stack pointer

Given this piece of code: swap: push ebp ; back up the base pointer, mov ebp, esp ; push the context of the registers on the stack push eax push ebx push ecx …
yhcowboy
  • 555
  • 1
  • 4
  • 13
33
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,052
  • 6
  • 27
  • 38
32
votes
2 answers

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
  • 25,084
  • 34
  • 143
  • 278
31
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
  • 772,407
  • 210
  • 1,477
  • 1,841
30
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
  • 2,949
  • 6
  • 30
  • 43
1
2 3
99 100