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
9
votes
0 answers

ld: Undefined symbols for architecture x86_64

I have made a nasm assembly hello world program like this: global start section .text start: mov rax, 0x20000004 mov rdi, 1 lea rsi, [rel msg] mov rdx, msg.len syscall mov rax, 0x20000001 mov rdi, 0 …
Jerfov2
  • 5,264
  • 5
  • 30
  • 52
9
votes
1 answer

Set video mode to 1920x1080 (HD) or higher in kernel ASM (NASM assembler)

I would like to set the video mode in a ASM kernel I'm working on to a video mode 1920x1080 or higher (or at least higher than the usual limit in VESA). Is there anyway to do that, and if so, provide sample code? I'm using NASM to code the kernel.
user237286
  • 91
  • 2
9
votes
1 answer

What is a good IDE for coding NASM?

I've been doing research online to find a good IDE for programming in NASM. The only one I found consistently mention is RadASM however, in contains no documentation on how to set it up and on top of that it is riddled with viruses/trojans…
CodyBugstein
  • 21,984
  • 61
  • 207
  • 363
9
votes
2 answers

Loading programs to RAM and executing them NASM 16b

I'm desperate for a solution to this. I'm trying to develop Assembly code allowing me to load and execute(by input of the user) 2 other Assembly .EXE programs. I'm having two problems: I don't seem to be able to assign the pathname to a valid…
8
votes
1 answer

How to link two nasm source files

I've got a file that defines very basic IO functions and I want to create another file that uses this file. Is there a way to link these two files up? prints.asm: os_return: ;some code to return to os print_AnInt: ;some code to output an…
meltuhamy
  • 3,293
  • 4
  • 23
  • 22
8
votes
5 answers

64 bit assembly, when to use smaller size registers

I understand in x86_64 assembly there is for example the (64 bit) rax register, but it can also be accessed as a 32 bit register, eax, 16 bit, ax, and 8 bit, al. In what situation would I not just use the full 64 bits, and why, what advantage would…
mk12
  • 25,873
  • 32
  • 98
  • 137
8
votes
1 answer

How syscall knows where to jump?

How does Linux determine the address of another process to execute with a syscall? Like in this example? mov rax, 59 mov rdi, progName syscall It seems there is a bit of confusion with my question, to clarify, what I was asking is how does syscall…
8
votes
2 answers

Problem switching to v8086 mode from 32-bit protected mode by setting EFLAGS.VM to 1

I'm in 32-bit protected mode running at current privilege level (CPL=0). I'm trying to enter v8086 mode by setting EFLAGS.VM (Bit 17) flag to 1 (and IOPL to 0) and doing a FAR JMP to my 16-bit real mode code. I get the current flags using PUSHF; set…
Michael Petch
  • 46,082
  • 8
  • 107
  • 198
8
votes
1 answer

Undefined reference to `WinMain' when compiling Nasm program on windows (MinGW)

I would like to compile the Hello World NASM example on windows. I've pasted the code above into a main.asm file, and compiled it into an obj file with this command: nasm -fwin32 .\main.asm -o main.obj After that I wanted to compile this obj file…
Iter Ator
  • 8,226
  • 20
  • 73
  • 164
8
votes
1 answer

What is proper way to call execve with arguments in assembly?

I am trying to execute the following with execve: /bin//nc -lnke /bin/bash -p 4444 When reading the man page for execve, I see the following requirements: int execve(const char *filename, char *const argv[], char *const…
user1529891
8
votes
1 answer

Registering Interrupt in 16 bit x86 Assembly

I am writing my own OS in 16 bit x86 Assembly, and I'm trying to register my own interrupt, something like INT 21H in MS-DOS. I couldn't find anything on the web. I'm using NASM as the assembler.
Xyz
  • 212
  • 2
  • 9
8
votes
1 answer

Compile ASM and C with ASM for debugging

I have two small files that I want to compile in CMake for debugging it with CLion and GDB main.c int my_strlen(char *); int main() { printf("Test: %d\n", my_strlen("Hello")); } and I have my ASM file that have a my_strlen file [BITS 64] …
Benjamin Sx
  • 653
  • 1
  • 7
  • 18
8
votes
1 answer

How can I create an executable from LLVM ir?

I am currently using llc to convert a .ll file to a .s using the commandline. Then I want to take this file and then use nasm to create an executable from it. While the first step seems to work fine, I can't get the second step to work. the…
lncr
  • 826
  • 8
  • 16
8
votes
3 answers

Creating a C function without compiler generated prologue/epilogue & RET instruction?

Consider this function: void foo(){ //do something } In assembly it would look something like this (not accurate): push something ;do stuff pop something ret But I don't want this generated code (RET, PUSH, POP ...). I just want a label to a…
SeeSoftware
  • 531
  • 6
  • 17
8
votes
1 answer

Is NASM inconsistent or am I just missing an obvious fact with CMP of immediate?

The "warning: signed dword immediate exceeds bounds" is the bane of my existence at the moment as it appears to be inconsistent or I am just not seeing an obvious fact. I have the following structure declared: struc FRTType .class …
Frank C.
  • 7,758
  • 4
  • 35
  • 45