Re: Which x86 assembler for Windows/Linux/Solaris?



In article <dl5jo702cu1@xxxxxxxxxxxxxxxxxx>, spamtrap@xxxxxxxxxx says...
> MASM was clearly the standard under DOS and Windows.
> We use MASM to support a quite sizable hand-tuned algorithm running SMP
> under Windows.
>
> I am faced with the problem of moving to Linux, but would
> like to continue supporting our Windows program.

One thought is to follow the slightly dated recommendation of Agner Fog.
His optimisation manual can be downloaded from

http://www.agner.org/assem/#optimize

Section 4.11 of the version I downloaded a few months ago reads:

"4.11 Using MASM under Linux

"The Gnu assembler that comes with Linux, BSD and similar operating
systems uses the terrible AT&T syntax. As I am in favor of standardizing
assembly syntax, I will recommend using the MASM assembler under Linux.

"Available tools for converting assembly files in MASM syntax to AT&T
syntax are not reliable, but tools for converting object files seem to
work well. You may assemble your code with MASM under Windows or under
Linux using Wine, the Windows emulator. Let MASM generate object files
in MS-COFF format and convert them to ELF format using the objcopy
utility from MingW32 mentioned above. The object files in ELF format can
then be linked into a C++ project using g++ or ld. Under Linux, the
process goes like this:

"wine -- ml.exe /c /Cx /coff myfile.asm
"wine -- objcopy.exe -Oelf32-i386 myfile.obj myfile.o
"g++ somefile.cpp myfile.o

"You may include this sequence in a make script or shell script. It may
seem awkward to use the MING version of objcopy which needs Wine to run
under Linux. It is probably possible to rebuild the native objcopy
utility to add support for the MS-COFF format (called pe-i386 in this
context), but I haven't figured out how.

"If you have leading underscores on your function names then add the
option --removeleading- char to the objcopy command line.

"If you want to build a function library that can be used under several
different operating systems, then make a .lib file under Windows using
the lib.exe utility that comes with Microsoft compilers and convert the
..lib file to ELF format with the command

"objcopy -Oelf32-i386 --remove-leading-char myfile.lib myfile.a

"The library myfile.a can then be used under Linux, BSD, UNIX, etc. Make
sure your library doesn't call any system functions."




I should stress I have not done this myself. I am merely pointing out
the existence of this possibility without holding any view on it at all.
It may be easier to rewrite the appropriate file rather than having the
additional debugging headache of wondering whether the ELF file is a
true representation of what was originally written. Maybe someone has
some practical experience of this.




Regards,

Simon.

.



Relevant Pages

  • Re: MASM32 help
    ... As I understand it (as is probably obvious, I am neither a Masm user nor a Windows programmer - and it makes a difference!), Masm uses ".386" and friends for two purposes - to enable "modern" instructions, and to ask for 32-bit code. ... What you've got there is Linux code, modified from Nasm syntax - not quite enough, apparently - to Masm syntax. ... I've done "push -11" and had it work, but what I think you're supposed to do is "push -11", call GetStdHandle, and use what that returns as your handle to ...
    (comp.lang.asm.x86)
  • Re: beginner asm, where next?
    ... Kip's book uses concentrates on MASM, and since I'm on a Windows ... Desktop more than Linux, I figured MASM is the way to go ... I failed to mention that I'm learning VC++ (Vis Studio 2005) at the ...
    (alt.lang.asm)
  • Re: beginner asm, where next?
    ... Kip's book uses concentrates on MASM, and since I'm on a Windows ... Desktop more than Linux, I figured MASM is the way to go ... I failed to mention that I'm learning VC++ (Vis Studio 2005) at the ...
    (alt.lang.asm)
  • Re: Best Compiler
    ... > Hi there can any one tell me what is the best assembly (assembler) or ... > for Linux OS i am using MASM for Windows OS so i am looking ... > on Linux is't as easy as MSAM invoke or call? ...
    (alt.lang.asm)
  • Re: Future of IT in Lebanon
    ... working knowledge of Indian programmers DNA, nor of their intuitive Java ... > So Longhorn is not an experiment and Linux is an experiment? ... another chapter in the Windows story, and the Microsoft marketing machine is ... > application opens, Check the about, it says Microsoft Visual Basic 6.3. ...
    (soc.culture.lebanon)