GNU Assembler (Mac OS X 64-bit): Illegal Instruction: 4

I am new to GNU Assembler and I am trying to execute this piece of code:

.globl _main _main: movl $1, %eax movl $0, %ebx int $0x80 

This program should exit the system call ( 1 ). Compiled (no warnings):

 gcc test.s 

But running it gives me an error: Illegal instruction: 4

Thanks for the help!

0
source share
1 answer

If you are compiling a 64-bit executable, you should write something like this:

 movq $0x2000001, %rax movq $0, %rdi syscall 

Source

+1
source

All Articles