I have written my first assembly program
; ----------------------------------------------------------------------------------------
; Writes "Hello, World" to the console using only system calls. Runs on 64-bit Linux only.
; To assemble and run:
;
; nasm -felf64 hello.asm && ld hello.o && .a.out
; ----------------------------------------------------------------------------------------
global _start
section .text
_start mov rax, 1 ; system call for write
mov rdi, 1 ; file handle 1 is stdout
mov rsi, message ; address of string to output
mov rdx, 13 ; number of bytes
syscall ; invoke operating system to do the write
mov rax, 60 ; system all for exit
xor rdi, rdi ; exit code 0
section .data
message: db "Hello, world", 10 ; note the newline at the end
using gedit text editor in Ubuntu studio 20.04 64bits system. I ran the program using Xfce terminal using command nasm -felf64 hello.asm && ld hello.o && ./a.out and received the output on two lines:
Hello, world
Segmentation fault (core dumped)
I got the source code from nasm tuitorial webpage. So where in this program is the segmentation fault