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
8
votes
1 answer

run an assembly code on ubuntu

The code i am trying to run is bellow. I use nasm util to convert it into object file. When i tried to execute it says "can not execute binary file". I run the command: nasm -f elf -o helloworld.o helloworld.asm segment .data msg db "Hello,…
mehmet6parmak
  • 4,777
  • 16
  • 50
  • 71
8
votes
3 answers

Create an exe file in assembly with NASM on 32-bit Windows

I'm making a hello world program in assembly language with NASM on 32-bit Windows 7. My code is: section .text global main ;must be declared for linker (ld) main: ;tells linker entry point mov edx,len ;message length mov ecx,msg ;message…
Mohit Swami
  • 125
  • 1
  • 1
  • 11
8
votes
1 answer

Near call/jump tables don't always work in a bootloader

General Problem I've been developing a simple bootloader and have stumbled on a problem on some environments where instructions like these don't work: mov si, call_tbl ; SI=Call table pointer call [call_tbl] ; Call print_char using near…
Michael Petch
  • 46,082
  • 8
  • 107
  • 198
8
votes
1 answer

How to assemble and link .asm files to a Win32 executable?

I have NASM and Dev-Cpp installed on my system. Dev-cpp comes with the LD (GNU Linker). I am new to assembly code and the processes to create a 32-bit Windows executable from an assembler file. I tried using this: nasm -f win32 ass.asm nasm -o ass…
Lesta Crenay
  • 101
  • 1
  • 1
  • 3
8
votes
2 answers

understanding nasm assembly for outputting characters in teletype mode

I am reading this wonderful skript on operating system programming http://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures/os-dev.pdf On Page 12 there is a simple bootloader. If I understand correclty, the code shown is what you must write in…
user3813234
  • 1,580
  • 1
  • 29
  • 44
8
votes
1 answer

How do I enter 32-bit protected mode in NASM assembly?

I'm learning x86 assembly, and I'm trying to make a toy operating system in NASM, but I don't understand some things. I made a bootloader that is successfully boots my kernel: Loads 14 sectors from the diskette which contains the kernel…
Axl Zorion
  • 81
  • 1
  • 3
8
votes
2 answers

Build android ELF binary with nasm?

I'm trying to write some assemble code for Android. Usually I'd do with nasm, but it doesn't seem to support Android (ARM) at all: valid output formats for -f are (`*' denotes default): * bin flat-form binary files (e.g. DOS .COM, .SYS) …
daisy
  • 22,498
  • 29
  • 129
  • 265
8
votes
2 answers

NASM Assembly convert input to integer?

Ok, so I'm fairly new to assembly, infact, I'm very new to assembly. I wrote a piece of code which is simply meant to take numerical input from the user, multiply it by 10, and have the result expressed to the user via the programs exit status (by…
user2862492
  • 101
  • 1
  • 1
  • 2
8
votes
1 answer

How to make a Makefile for a program for assembly Language?

I've come across this task to build a Makefile for a program in assembly language I made (nothing fancy, like a hello world). The program is in Linux 32 bits and I'm using NASM assembler. So far I can only find Makefiles for programs for C, I'm…
Ale Rojas
  • 497
  • 2
  • 7
  • 17
8
votes
1 answer

How to push a 64bit int in NASM?

I'm trying to push a 64bit integer but when assembling NASM seems to want to see it as a DWORD not a QWORD. I'm using ASM to create the shellcode I need to inject a 64bit DLL into a 64bit process. The first QWORD is the old instruction pointer, the…
user2272296
  • 361
  • 2
  • 5
  • 15
8
votes
1 answer

Floating Point Exception when dividing in x86 nasm

I'm busy with learning Assembly and was looking at dividing, however I ran into a pickle with the following statement: mov edx,0x00000001 mov eax,0x00000000 mov ecx,0x00000002 idiv ecx GDB: 0x08048071 <+17>: mov edx,0x1 0x08048076…
Lucas Kauffman
  • 6,789
  • 15
  • 60
  • 86
8
votes
1 answer

Nasm Error: invalid combination of opcode and operands

In my quest to learn NASM, I am trying to create a really simple program that does a division and outputs the result. By the books, everything should run fine. I'm dividing 15 by 3, and it should automatically be stored in the AX register which I…
CodyBugstein
  • 21,984
  • 61
  • 207
  • 363
8
votes
1 answer

EBP, ESP and stack frame in assembly

I have a few questions about EBP, ESP and stack frame in following code. Why did we subtract 28 from esp? We have two local variables x and y in main. So why didn't we subtract 8? And don't we put values to stack from right (or top) to left (or…
Figen Güngör
  • 12,169
  • 14
  • 66
  • 108
8
votes
3 answers

Executing a flat binary file under Linux

Is there a way to execute a flat binary image in Linux, using a syntax something like: nasm -f bin -o foo.bin foo.asm runbinary foo.bin
nonpolynomial237
  • 2,109
  • 4
  • 27
  • 35
7
votes
2 answers

Bootloader Strange Behavior

I have been trying to design a simple OS, just the boot sector, and 16-bit real mode with interrupts. I have finally been able to make the OS / bootloader, that I tested in virtual box, and it worked. I then burned the image to a CD, and booted it…
codesmith
  • 561
  • 1
  • 3
  • 17