RicardasSim

nasm syscall

Sep 3rd, 2019
796
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;64 bit
  2. ;nasm -f elf64 main.asm -o main.o
  3. ;ld main.o -o test
  4.  
  5. section .data
  6.     msg: db "Hello World !", 10
  7.     msgLen: equ $-msg
  8.  
  9. section .text
  10. global _start
  11.  
  12. _start:
  13.     mov rax, 1      ; sys_write
  14.     mov rdi, 1      ; write to stdout
  15.     mov rsi, msg    ; string address
  16.     mov rdx, msgLen ; size of string
  17.     syscall         ; syscall
  18.    
  19.     mov rax, 60     ; sys_exit
  20.     mov rdi, 0      ; return code 0
  21.     syscall         ; syscall
Advertisement