intel2gas 1.3.3 (c)1999 Mikko Tiihonen (mikko.tiihonen@hut.fi)

This program converts assembler source from Intel (NASM), to AT&T (gas) 
syntax. It is FREE SOFTWARE under the terms of the GNU General Public 
License (GPL), enclosed in the file 'COPYING'.
----------------------------------------------------------------------------

1. What's this?
---------------

Intel2gas is a small text parser that can convert assembler source
written in NASM syntax to gas syntax. And nowadays 
more often also the other way.

The program does minimal error checking and does not understand the
text it's converting. It's just tries to find matches from its syntax
database.


2. Using intel2gas
------------------

It's simple. To convert from NASM format to gas format type
   intel2gas infile.asm -o outfile.s
or
   cat infile.asm | intel2gas > outfile.s

Or the other way around from gas to NASM format
   intel2gas -g infile.s -i outfile.asm

To test how correctly intel2gas works try:
   intel2gas infile.asm | intel2gas -g -o outfile.asm
   diff -u infile.asm outfile.asm

If the data files can't be found from the compiled-in default 
directory, set the I2G_DATA environment variable to point
to the correct directory. 
For example, for Bourne and Korn shells:
   export I2G_DATA="./"
For C shells:
   setenv I2G_DATA "./"


3. Converting from TASM/MASM
----------------------------

Use the command-line switch -m or -t to use the less strict syntax
files suitable for MASM/TASM conversion.

There could be some errors from unrecognized directives that intel2gas
doesn't yet understand.

I chose NASM syntax as the base because it's so much simpler and does
not have thousands of useless directives and compatibility defines
which do not even have a meaning in other syntaxes. I recommend that
you write all your future assembly with NASM. You can get it from
http://www.web-sites.co.uk/nasm/.

Due the common misuse of syntax 'mov eax, a' instead of 'mov eax, [a]' 
intel2gas assumes that you mean the latter. The actual assemblers know 
from context wheather it means 'address of a' or 'value of a'.

If you teach intel2gas to ignore some new directives in m2g/main.syntax,
send me your modifications and I'll include them in the next version.


4. Converting from GNU assembler
--------------------------------

When converting code with variables declared .globl:
NASM seems to require that only functions should be declared GLOBAL and 
variables instead as COMMON. Currently i2g defaults to GLOBAL and all
references to variables should be replaced by hand to COMMON.


5. Converting inline assembly
-----------------------------

Here's an example invocation:
   intel2gas -m -I infile-msvc.c -o outfile-gcc.c

Just the opposite of the previous section's initial comment:  in most
cases it will *not* produce many (or any) errors, but the code itself
will not be complete.  In particular, inlined MASM-style assembly
(such as that intended for compilation with MSVC) makes use of local
variables at will; gcc will use only global variables (i.e., those
defined outside of any function, although they can be static).  For
local variables, it is necessary to make use of the "input registers"
feature of gcc's extended inline assembly syntax.  This is the field
that comes after the second colon (:) at the end of an asm block.
(Search for the word FIXASM in the output file.)

The advantage is that many MOV statements required by MASM usually
can be eliminated.  See Brennan Underwood's Guide to Inline Assembly,
http://www.delorie.com/djgpp/doc/brennan/brennan_att_inline_djgpp.html,
for details, but be mindful that it is DJGPP-specific in some areas.
For example, when it talks about referencing global variables by pre-
fixing an underscore, that does *not* apply to gcc/gas under Linux.

Other notes:
 - Compiling shared-object code with -fPIC eliminates %ebx as a valid
    input register; gcc will complain about register spillage but (ever
    so helpfully) will not identify which register is the problem.
 - When %eax is 0, executing the CPUID instruction will "secretly"
    clobber %ebx, %ecx and %edx.  This is fully documented behavior
    (the three registers will be filled with a 12-byte string specifying
    the manufacturer--e.g., "GenuineIntel" or "AuthenticAMD"), but it
    can easily catch the unwary.  Add these regs to the clobber list!
 - At least as of gcc 2.7.2.3 and egcs 1.1, the MMX registers (%mm0, etc.)
    cannot be listed in the clobber list.  I don't know if this applies to
    the (aliased) floating-point registers, too.
 - intel2gas tries to create the list of clobbered registers automatically, 
    but you should still check the results yourself. Usually you should add
    at least "cc" ("condition codes," i.e., the flags register) to the list.


6. Bug reports
--------------
If you find any syntax mismatches you are too lazy to fix yourself, just
send the offending line to me and I'll send you updated syntax files back.
If you somehow manage to fix the syntax files yourself, it would be nice
to send them to me, too.

You are encouraged to send any bug reports, suggestions and comments to
the author.


7. Homepage 
----------- 
The new homepage is 
http://www.niksula.cs.hut.fi/~mtiihone/intel2gas 
