Hello World - Linux 32bit - syscall/gcc compiled version

This is the 32bit version of the famous: "hello, world" program written in assembly language for a Linux system. Instead of using as and ld to link and compile, here we'll make use of the GNU C compiler (gcc) to compile the executable. The only read difference here is that we need to change the start label from _start to main as this is what gcc is looking for.



.section .data
	msg: .ascii "Hello, world\n"
	.set len, . - msg

.section .text
    .global main

main:
	movl    $4, %eax
	movl    $1, %ebx
	movl    $msg, %ecx
	movl    $len, %edx
	int     $0x80

	movl    $1, %eax
	movl    $0, %ebx
	int     $0x80

Assuming the file is called hellogcc.s, use the following command, to compile and link it with gcc:



gcc -o hellogcc hellogcc.s

And run it with:



./hellogcc