11

I want to compile intel syntax assembly using gcc. Is it possible? because I cant find something similar. I've only found this post.

Here is the code I am trying to compile.

    global  _main
    section .text
_main:
    mov eax, -1     
        ret

If this is not possible please provide alternative options in your answer.

Community
  • 1
  • 1
kechap
  • 2,077
  • 6
  • 28
  • 50

1 Answers1

11

Adding a .intel_syntax directive works for me:

  .globl _main
  .intel_syntax

_main:
  mov eax, -1     
  ret

Assembling and running:

$ gcc -o example example.s; ./example; echo $?
255
Carl Norum
  • 219,201
  • 40
  • 422
  • 469