Here's the code:
.text # Section declaration
.global _start
_start:
# Write our string to stdout
movl $len, %edx
movl $msg, %ecx
movl $1, %ebx
movl $4, %eax
syscall
# Exit
movl $0, %ebx
movl $1, %eax
syscall
.data
msg:
.ascii "Hello, world!\n" # Our string
len = . - msg # Length of the string
I use these shell commands to compile and build it:
as -o hello.o hello.S
ld -s -o hello hello.o
./hello
But when I run it, I get this error message:
Illegal instruction
I have tried to replace "syscall" with "int $0x80", but then I get this error:
Segmentation fault
I use Windows 10 64 bit, so, does anyone have any idea of how I can fix this?