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