0

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

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

This programm should exit by the system call exit (1). Compiled it (no warnings):

gcc test.s

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

Thanks for help!

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
qwertz
  • 14,614
  • 10
  • 34
  • 46

1 Answers1

1

If you're compiling a 64-bit executable, then you should write something like this:

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

Source.

Alexey Frunze
  • 61,140
  • 12
  • 83
  • 180