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
1
vote
1 answer

x86-64 ELF initial stack layout when calling glibc

Basically, I read through parts of http://www.nasm.us/links/unix64abi and at page 29, it shows the initial process stack of a C program. My question is: I'm trying to interface with glibc from x86-64 nasm and based on what the above shows, argc…
yanhan
  • 3,269
  • 3
  • 24
  • 37
1
vote
0 answers

Why is there no output even if the system call is sys_write?

I am learning x86_64 assembly and writing a simple code to print individual letters of a string. I know how to print the whole string but why is there no output when trying to display individual letters? Code: global _start section .data msg db…
sh.3.ll
  • 775
  • 4
  • 15
1
vote
1 answer

nasm assembly: Can't find valid values for all labels after 1004 passes

I am trying to write an x86 assembly code for NASM assembler, which will convert a hexadecimal number into a string and print it. For simplicity I have assumed that my hexadecimal number will only contain digits(eg. 0x1234). Here is the…
Ashfaqur Rahman
  • 623
  • 1
  • 5
  • 20
1
vote
1 answer

nasm assembly: string is printed twice

I have written following x86 assembly code for NASM assembler. hello.asm [org 0x7c00] mov bx, HELLO_MSG call print_string mov bx, GOODBYE_MSG call print_string jmp $ %include "print_string.asm" HELLO_MSG: db 'hello, world',0 GOODBYE_MSG: …
Ashfaqur Rahman
  • 623
  • 1
  • 5
  • 20
1
vote
2 answers

x86_64 assembly string manipulation causes segmentation fault

I am trying to write a "strcat" function in assembly and can't get the values in the memory I pass it to change. My tests are crashing and I don't understand why. I can't seem to find any good documentation on x86_64 assembly in an easy to digest…
1
vote
1 answer

Nasm - "real" randomness via uninitialized variables?

I'm trying to build a number generator in Nasm. For this purpose I'd like to declare a few "variables" (I know Nasm only has labels, not variables) but not define them. The problem is when declaring variables in .bss they are automatically null…
MenNotAtWork
  • 125
  • 6
1
vote
1 answer

Assembly(Intel x86) function to find the length of a string, why am I getting extra characters?

I am a beginner in assembly and I have this homework where I have to create a strlen function to find the length of any string. I tried subtracting 4 from edx because I am seeing 4 extra characters at the end, but that did not fix anything. They are…
Jeemong
  • 11
  • 3
1
vote
1 answer

Why does calling 'pop' in this piece of assembly code cause a segmentation fault?

I'm playing around with x86-64 assembly on Mac OS (using NASM 2.09 and 2.13, to catch bugs caused by NASM issues). I'm trying to implement function calls at the moment, and tried using the push and pop instructions, but the pop always seems to cause…
96nsns
  • 13
  • 3
1
vote
2 answers

What is the use of Mov ah,10 in int 21h

What is the use of mov ah,10 in int 21h Mostly we use like mov ah,0a for string input but why mov ah,10? nter db 'enter you name:$' nam db 50,0,50 dup('$') ;num is 50, num + 1 is 0, num + 2 is 50 lfcr db 10,13,'$' ;line feed carrier…
Tnek
  • 11
  • 3
1
vote
0 answers

How to display date using x86 NASM?

Trying to display the date and it tells me I need a coma after the operand in line 16 section .text global _start ;must be declared for using gcc _start: ;tell linker entry point mov edx, len ;message length …
1
vote
1 answer

C function not callable

I am writing some simple c code that i try to call from assembly (nasm). However before actually using the code in assembly there are already errors i do not understand. This is the code: void start(); void print(); void start() { …
Erukaron
  • 39
  • 5
1
vote
1 answer

Printing character from register

I'm using the NASM assembler. The value returned to the eax register is supposed to be a character, when I attempt to print the integer representation its a value that looks like a memory address. I was expecting the decimal representation of the…
Mark
  • 81
  • 1
  • 4
1
vote
1 answer

What does REP INSW do?

I need to read some 16-bit values from the port and save them to the buffer. Tutorial which I'm using suggest using REP INSW instruction, but I don't know how to use it and even how it works... Is this instruction equivalent to two IN instructions?
1
vote
2 answers

Instructions after a ;\ comment don't execute? What's special about backslash in comments in NASM?

I was programming an ASCII to decimal converter in ASM and after an edit, it just didn't add to rax, this caused an infinite loop. GDB says that rax wasn't accepting ANY numbers, even when moved from memory and other registers. I have tried moving…
Clinery
  • 33
  • 4
1
vote
1 answer

How can I reprogram my shellcode snippet to avoid null bytes?

I have programmed a piece of x64 linux assembly. All it does is just prints a line "Hello world", that's all. However what I want to do is copy the bytes from it's object file by objdump, so that I can make my own shellcode for my buffer overflow…
nltc
  • 77
  • 6
1 2 3
99
100