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
12
votes
2 answers

What does double dollar sign mean in x86 assembly (NASM)

The expression is: times 512-($-$$) db 0 I know what the dollar sign means but I don't know what it means when it's double. What does the double dollar sign mean?
Grevak
  • 533
  • 5
  • 17
12
votes
1 answer

What are the return values of system calls in Assembly?

When I try to research about return values of system calls of the kernel, I find tables that describe them and what do I need to put in the different registers to let them work. However, I don't find any documentation where it states what is that…
Pichi Wuana
  • 732
  • 2
  • 9
  • 35
12
votes
2 answers

Creating a bootable ISO image with custom bootloader

I am trying to convert a bootloader I wrote in Assembly Language to an ISO image file. The following is the code from MikeOS bootloader. Here is my bootloader code: BITS 16 start: mov ax, 07C0h ; Set up 4K stack space after this…
Mahmoud Abdel-Rahman
  • 497
  • 2
  • 10
  • 27
12
votes
1 answer

How to write to screen with video memory address 0xb8000 from real mode?

I created simple code to load second sector from hard drive, and then write to whole screen, with spaces with red background. The problem is that always instead of spaces I got @ signs. This is the code: org 0x7C00 bits 16 xor ax,ax mov ds,ax mov…
vakus
  • 732
  • 1
  • 10
  • 24
12
votes
1 answer

Linking C with NASM

I have a NASM file and a C file. How do I call a function in the C file from the NASM file? How do I call a NASM function from the C file? Many Thanks DD
user3883624
  • 261
  • 1
  • 3
  • 7
12
votes
2 answers

Can't include a file in NASM

I try to include a file into my boot.asm file using %include "input.asm" But every time i try to compile it i get an error saying that nasm can't open the include file. input.inc IS in the same directory as boot.asm I was looking here and on…
themorfeus
  • 277
  • 1
  • 3
  • 17
12
votes
2 answers

What values can the carry flag hold, and how to check its status in x86 assembly?

What values can the carry flag hold? Is it just 0x00 and 0x01 (boolean) or is it 16 (or 32/64) bits like the rest of the CPU registers? How do I check its status? Do I just use it like a normal CPU register like cmp cf, 0x00 then jg
codesmith
  • 561
  • 1
  • 3
  • 17
11
votes
3 answers

NASM (Intel) versus AT&T Syntax: what are the advantages?

I'm going through the Intel processor documentation and writing some basic assembly code at the same time. I have both nasm and as (GAS) on my server and I understand the basic differences of both assemblers. In the long run: Focusing on which of…
user613857
11
votes
2 answers

Division of two numbers in NASM

Starting to teach myself assembly (NASM) I wanted to know how to divide 2 numbers (For instance on Windows). My code looks like this but it crashes. global _main extern _printf section .text _main: mov eax, 250 mov ebx, 25 div ebx push ebx push…
Karen
  • 111
  • 1
  • 1
  • 3
11
votes
5 answers

What is the best resource for learning (N)ASM?

I've been wanting to learn assembly for a while now, and although I've tried a few times before, I haven't really been able to get past "Hello, world". Are there any good introductory tutorials to assembly (preferably using NASM, as I use Windows…
Lucas Jones
  • 19,767
  • 8
  • 75
  • 88
11
votes
2 answers

Why does the sys_read system call end when it detects a new line?

I'm a beginner in assembly (using nasm). I'm learning assembly through a college course. I'm trying to understand the behavior of the sys_read linux system call when it's invoked. Specifically, sys_read stops when it reads a new line or line feed.…
Mercado
  • 606
  • 6
  • 20
11
votes
3 answers

Reading from a file in assembly

I'm trying to learn assembly -- x86 in a Linux environment. The most useful tutorial I can find is Writing A Useful Program With NASM. The task I'm setting myself is simple: read a file and write it to stdout. This is what I have: section .text …
jameshfisher
  • 34,029
  • 31
  • 121
  • 167
11
votes
5 answers

problem in understanding mul & imul instructions of Assembly language

I'm learning 80386 from PC Assembly by paul caurter mul source If the operand is byte sized, it is multiplied by the byte in the AL register and the result is stored in the 16 bits of AX. fine. If the source is 16-bit, it is multiplied…
claws
  • 52,236
  • 58
  • 146
  • 195
11
votes
3 answers

Converting C to nasm assembly

I try to covert my c code to assembly by GCC (by typing gcc -S -masm=intel or pg.c or gcc -S prog.c) but it gives me MASM code although I need NASM one. I wonder if you could help me to convert my c to NASM assembly.
Abtin
  • 301
  • 2
  • 3
  • 7
11
votes
5 answers

How to load a kernel from disk with BIOS int 13h in NASM assembly?

I've been stuck with this for weeks now and have no idea where I'm going wrong because NASM hasn't given me any errors. The code is pretty self explanatory because of the comments. this is the code that is loaded from the BIOS …
user188025