You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
578 B

5 years ago
  1. ; hello_world.asm
  2. ; Prints "Hello, world!" in 64 bit linux assembly written in intel syntax
  3. ; Compile with "nasm -f elf64 hello_world.asm && ld hello_world.o -o hello_world"
  4. .text:
  5. global _start
  6. _start:
  7. mov rax, 1 ; system call for write
  8. mov rdi, 1 ; file handle for stdout
  9. mov rsi, msg ; move msg variable to rsi register for printing
  10. mov rdx, 14 ; length of the string
  11. syscall ; call kernel
  12. mov rax, 60 ; system call for exit
  13. mov rdi, 0 ; exit code
  14. syscall ; call kernel
  15. .data:
  16. ; initialize doubleword msg variable
  17. msg db 'Hello, world!',0xa