.section .data # data starts here
string: .ascii "Hello World!\n"
s_size: .long . - string # string_size: 14
.section .text # code starts here
.globl _start
# write(1, "huba\n", 5)
_start: movl $4, %eax # syscall 4: write(fd, buf, size)
movl $1, %ebx # file descriptor (stdout)
movl $string, %ecx # buffer start
movl s_size, %edx # buffer size
int $0x80 # syscall interrupt
# exit(0) - you must call this to avoid segfault
movl $1, %eax # syscall 1: exit(rc)
movl $0, %ebx # rc
int $0x80 # syscall interrupt
Assemble and link:
as -otest.o test.s ld test.o ./a.out