www.delorie.com/djgpp/v2faq/faq135.html   search  

| Previous | Next | Up | Top |

17.1 GCC/Gas won't accept valid assembly code ...

Q: I have some code written in assembly which compiles under MASM and TASM, but GCC gives me a long list of error messages.


A: The GNU Assembler (as.exe), or Gas, called by GCC accepts the AT&T syntax, which is different from the Intel syntax. Notable differences between the two syntaxes are: Examples:
         Intel:  [ebp - 4]         AT&T:  -4(%ebp)
         Intel:  [foo + eax*4]     AT&T:  foo(,%eax,4)
         Intel:  [foo]             AT&T:  foo(,1)
         Intel:  gs:foo            AT&T:  %gs:foo

For a complete description of the differences, see the "i386-Dependent" section of the "GNU assembler documentation". If you don't read this FAQ with an Info browser, download GNU Binutils, unzip the files named as.iN (where N is a digit) from it, then type at the DOS prompt:
      info as machine i386

You will see a menu of Gas features specific to x86 architecture.

A guide is available which was written by Brennan Underwood; it describes how to use inline assembly programming with DJGPP and includes a tutorial on the AT&T assembly syntax. Check out the DJGPP inline assembly tutorial. Another useful tutorial about writing separate assembly-language modules for DJGPP was written by George Foot and is available from George's home page. The DJGPP User's Guide also has a tutorial on writing assembly-language code. Many people who used Intel syntax and then converted to the AT&T style say that they like the AT&T variant more. However, if you prefer to stick with the Intel syntax, download and install NASM, which is a free portable assembler. It is compatible with DJGPP and accepts a syntax which is much more similar to the Intel style. A guide for using NASM with DJGPP was written by Matthew Mastracci and is available from Matthew's Web page.


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright ⌐ 1998   by Eli Zaretskii     Updated Sep 1998  

Powered by Apache!

You can help support this site by visiting the advertisers that sponsor it! (only once each, though)