---
search:
  exclude: true
---
# Assembly x86_64 - Hello World!

## Assembly Code 

We're going to use vim to write our code
    
    
    [ 192.168.0.18/24 ] [ /dev/pts/88 ] [~/binexp/asm]
    → vim 0.asm
    
    
    
    
    section .data
            text db "Hello, World!",10
    
    section .text
            global _start
    
    _start:
            mov rax, 1
            mov rdi, 1
            mov rsi, text
            mov rdx, 14
            syscall
    
            mov rax, 60
            mov rdi, 0
            syscall
    
    

## Compiling 

Here we're going to use nasm to compile our assembly code: 
    
    
    [ 192.168.0.18/24 ] [ /dev/pts/89 ] [~/binexp/asm]
    → nasm -f elf64 0.asm -o 0.o
    
    [ 192.168.0.18/24 ] [ /dev/pts/89 ] [~/binexp/asm]
    → ls -lash
    total 16K
    4.0K drwxr-xr-x 2 nothing nothing 4.0K Mar  2 16:17 .
    4.0K drwxr-xr-x 5 nothing nothing 4.0K Mar  2 16:01 ..
    4.0K -rw-r--r-- 1 nothing nothing  179 Mar  2 16:09 0.asm
    4.0K -rw-r--r-- 1 nothing nothing  848 Mar  2 16:17 0.o
    
    

Now we have our 0.asm code and the 0.o object file, now we need to link it using the gnu linker (ld) to make an executable file
    
    
    [ 192.168.0.18/24 ] [ /dev/pts/89 ] [~/binexp/asm]
    → ld 0.o -o 0
    
    [ 192.168.0.18/24 ] [ /dev/pts/89 ] [~/binexp/asm]
    → ls -lash
    total 28K
    4.0K drwxr-xr-x 2 nothing nothing 4.0K Mar  2 16:19 .
    4.0K drwxr-xr-x 5 nothing nothing 4.0K Mar  2 16:01 ..
     12K -rwxr-xr-x 1 nothing nothing 8.7K Mar  2 16:19 0
    4.0K -rw-r--r-- 1 nothing nothing  179 Mar  2 16:09 0.asm
    4.0K -rw-r--r-- 1 nothing nothing  848 Mar  2 16:17 0.o
    
    [ 192.168.0.18/24 ] [ /dev/pts/89 ] [~/binexp/asm]
    → file 0
    0: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped
    
    
    

and now we have our executable file called '0', we make it executable with chmod +x and then execute it:
    
    
    [ 192.168.0.18/24 ] [ /dev/pts/89 ] [~/binexp/asm]
    → chmod +x 0
    
    [ 192.168.0.18/24 ] [ /dev/pts/89 ] [~/binexp/asm]
    → ./0
    Hello, World!
    
    

And that concludes our first assembly code! in the next part we're going to explain everything about this code [here](2.md).

