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
1
vote
0 answers

MSVC linker cannot find entry point in object files produced by NASM

I'm experimenting with some assembly programming. Here is my very simple program : extern ExitProcess segment Main Entry: push 0 call ExitProcess For assembling I use NASM : nasm.exe -f win64 -o Entry.obj Entry.asm The code compiles…
user21907176
1
vote
1 answer

Getting absolute address of data in shellcode

Here's my shellcode: xor rax, rax xor rdi, rdi xor rsi, rsi xor rdx, rdx ; getting address of `pathname` mov rdi, [something] mov al, 59 mov rdi, rsp syscall xor rax,rax mov al, 60 xor rdi, rdi …
R-Rothrock
  • 303
  • 2
  • 14
1
vote
0 answers

"wrong variable or address: " in sasm debugger

I am learning x86-64 assembly, using SASM IDE and I have this question. %include "io64.inc" section .data string2 db "hello",0 section .text global CMAIN CMAIN: mov rbp, rsp; for correct debugging mov rsi, string2 xor rax, rax …
Rick
  • 7,007
  • 2
  • 49
  • 79
1
vote
0 answers

osdev linker "file format not recognized"

I'm trying to make a simple OS, so I wrote a small kernel that consist out of a c file an assembly file that calls the main function in the c file. but when I try to compile and link the two files together I get a file format not recognized error by…
neta cohen
  • 137
  • 11
1
vote
1 answer

Why is my assembly code not jumping to the loaded code?

I wrote a simple OS / bootloader that loads 4 additional sectors from disk and then jumps to them. But the jump isn't working and the code just hangs. This is the start.S file [BITS 16] [ORG 0x7C00] PROGRAM_SPACE equ 0x7E00 start: mov bp,…
1
vote
1 answer

Skip spaces in string during loop, Assembly palindrome

I'm trying to do a palindrome checker program and I'm stuck in skipping spaces in string. It works with single words but not with sentences. I've tried to add a skip_space1 and skip_space2 but it doesn't work with spaces. Code: call getaddr…
wojst
  • 11
  • 2
1
vote
1 answer

How to get the runtime of a NASM assembly program?

How get the Runtime of a NASM Program? This is the program that I want to get the runtime of it. It is a simple program to calculate the Fibonacci sequence using NASM assembly so, I need to get the runtime of the this program to compare the speed…
1
vote
1 answer

Why does the read macro use rax instead of rdx to store string length in this NASM code?

section .data msg db 10 "Enter string" msg_len equ $-msg smsg db 10 "Length is: " smsg_len equ $-smsg section .bss char_ans resb 2 string resb 50 string_len equ $-string count resb…
1
vote
1 answer

How can I assign values to the stack in NASM x86-64 without going out of bounds?

I would like to understand how to correctly assign values on the stack in NASM x86-64 I would like to clarify something. Imagine we have an assembler program like this, with a prologue + epilogue and a reservation of 16 bytes: push rbp mov rbp,…
kvlihidden
  • 11
  • 1
1
vote
0 answers

I am trying to pass an array of string pointers to a c funtion from NASM assembly

So I’m very new to assembly and for my class I’m supposed to pass an array of string pointers to a C function to display them you can ignore validate. As you can see when I run it in GDB I can see the string output. Is it in the wrong place? Did I…
1
vote
1 answer

How to change number of reserved bytes in assembly?

I've just started learning assembly and I want to know how to change the number of reserved bytes, if possible at all. I've created the following code that will create a right triangle of decreasing length based on the max variable at the bottom.…
12944qwerty
  • 2,001
  • 1
  • 10
  • 30
1
vote
1 answer

Get Input Result with int 0x16

I did this simple input function that finished when the user press the enter key: input: mov ah, 0x00 int 0x16 cmp al, 0x0d je enter_press jne enter_not_press enter_press: ret enter_not_press: jmp input How I can get…
1
vote
1 answer

Assembly, obtain Intel PPIN value

Each Intel processor should provide a PPIN (Protected Processor Inventory Number) value, which is unique. I've read here that this value will become available in Linux starting from kernel 5.18. However, I've not found any example to directly obtain…
BowPark
  • 1,340
  • 2
  • 21
  • 31
1
vote
1 answer

Intercalate characters from 5 strings in assembly nasm

I have to code an assembly program that intercalates characters from five different strings that the user types on the keyboard, for example, if I had: S1 : "Hello" S2 : "Bye" S3 : "Apple" S4 : "Car" S5 : "Tree" it would result:…
1
vote
1 answer

Stuck on a college Assembly project

I have been tasked with an Assembly project that contains the directions below: The task is to build a program that creates a string based on command line instructions. The instructions, listed below, will be processed accordingly: Use "A" to add…
misschiggi
  • 11
  • 1
1 2 3
99
100