01-helloworld.asm 725 B

1234567891011121314151617181920212223242526
  1. ;;; Required packages: nasm, ld
  2. ;;; compile commands:
  3. ;;; nasm -f elf 01-helloworld.asm -o bin/01-helloworld.o
  4. ;;; ld -m elf_i386 -s -o bin/01-helloworld.out bin/01-helloworld.o
  5. section .data
  6. msg db 'Hello, world!', 0xa ; db - define bytes, 0xa - code of \n
  7. len equ $ - msg
  8. section .text
  9. global _start ; _start label is an entry point
  10. _start:
  11. ; output
  12. mov eax, 4 ; 4 - system call sys_write
  13. mov ebx, 1 ; 1 - file descriptor stdout
  14. mov ecx, msg ; text
  15. mov edx, len ; text size
  16. int 0x80 ; processor interruption to run syscall
  17. ; exit code
  18. mov eax, 1 ; 1 - system call sys_exit
  19. mov ebx, 0 ; 0 - error code 0
  20. int 0x80 ; processor interruption to run syscall