[an error occurred while processing this directive]
Q: I have some code written in assembly which compiles under
MASM and TASM, but GCC gives me a long list of error
A: The GNU Assembler (
Gas, called by GCC
accepts the AT&T syntax, which is different from the Intel
syntax. Notable differences between the two syntaxes are:
$; Intel immediate operands are undelimited (Intel
push 4is AT&T
%; Intel register operands are undelimited. AT&T absolute (as opposed to PC-relative)
calloperands are prefixed by
*; they are undelimited in Intel syntax.
add eax, 4is
addl $4, %eaxin AT&T syntax.
source, dest convention is maintained for compatibility with
previous Unix assemblers, so that GCC won't care about the assembler with
which it is configured, as some of GCC installations (on systems other
than MS-DOS) don't use GNU Binutils.
lspecify byte (8-bit), word (16-bit), and long (32-bit) memory references. Intel syntax accomplishes this by prefixing memory operands (not the opcodes themselves) with
`word ptr', and
`dword ptr'.Thus, Intel
mov al, byte ptr FOOis
movb FOO, %alin AT&T syntax.
lcall/ljmp $SECTION, $OFFSETin AT&T syntax; the Intel syntax is
call/jmp far SECTION:OFFSET.Also, the far return instruction is
lret $STACK-ADJUSTin AT&T syntax; Intel syntax is
ret far STACK-ADJUST.
SECTION:[BASE + INDEX*SCALE + DISP]
is translated into the AT&T syntax
SECTION:DISP(BASE, INDEX, SCALE)
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 GNU assembler documentation. If you don't
read this FAQ with an Info browser, download GNU Binutils,
unzip the files named
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 user guide for inline assembly 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. One of the sections there describes the CPU architecture, which is geared towards assembly-language programming.
Yet another tutorial on the subject of inline assembly is available at
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.
Note that Binutils maintainers are working on adding an option to Gas which will cause it accept the Intel syntax as well, so it is most probable that beginning with Binutils 2.10, Gas will have this feature.