'Printing out hello world with assembly

I had just started to learn assembly and some lower level concepts (I have some higher level background with python, js, etc).

I am trying to print out hello world with the following assembly program:

section .data
    msg db 'Hello World'
    len equ $ - msg

section .text
    global _start

_start:
    MOV rdi, 1 ; stdin fd
    MOV rsi, msg
    MOV rdx, len
    MOV rax, 1 ; write syscall
    INT 0x80

I am running Ubuntu Linux on an x86_64 machine.

I assembled the program with nasm: nasm -f elf64 hello_world.nasm

Then I then linked with ld: ld -o hello_world hello_world.o

When I run ./hello_world nothing is printed out to the console.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source