fork download
  1. section .data ; section for initialized data
  2. str: db 'Hello world!', 0Ah ; message string with new-line char at the end (10 decimal)
  3. str_len: equ $ - str ; calcs length of string (bytes) by subtracting this' address ($ symbol) from the str's start address
  4.  
  5. section .text ; this is the code section
  6. global _start ; _start is the entry point and needs global scope to be 'seen' by the linker -equivalent to main() in C/C++
  7. _start: ; procedure start
  8. mov eax, 4 ; specify the sys_write function code (from OS vector table)
  9. mov ebx, 1 ; specify file descriptor stdout -in linux, everything's treated as a file, even hardware devices
  10. mov ecx, str ; move start _address_ of string message to ecx register
  11. mov edx, str_len ; move length of message (in bytes)
  12. int 80h ; tell kernel to perform the system call we just set up - in linux services are requested through the kernel
  13. mov eax, 1 ; specify sys_exit function code (from OS vector table)
  14. mov ebx, 0 ; specify return code for OS (0 = everything's fine)
  15. int 80h ; tell kernel to perform system call
Success #stdin #stdout 0.01s 144KB
stdin
Standard input is empty
stdout
Hello world!