The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Spartan on June 16, 2006, 02:01:25 PM

Title: Visual C++ compiler really have asm compiler inside or it is separate program?
Post by: Spartan on June 16, 2006, 02:01:25 PM
My friend Igor said that VC++ compiler has outsideĀ  asm compiler. what is true?
Title: Re: Visual C++ compiler really have asm compiler inside or it is separate progra
Post by: Ossa on June 16, 2006, 02:06:54 PM
I'm not too sure what your question here is... but I'll take my best guess:

The VC++ compiler (cl.exe) compiles C/C++ code. There is a seperate assembler called MASM (ml.exe) that is often but not always packaged with it. You can also use inline ASM code in your C/C++, but that is assembled by cl.exe.

Hope that answers your question,
Ossa
Title: Re: Visual C++ compiler really have asm compiler inside or it is separate program?
Post by: asmfan on June 16, 2006, 02:08:46 PM
He is right it is called ml.exe, but cl.exe can assemble inline asm instructions as well...
Title: Re: Visual C++ compiler really have asm compiler inside or it is separate program?
Post by: Spartan on June 16, 2006, 02:12:52 PM
But  why use the ml.exe if cl.exe can compile asm code?
And second question - what better to use ml.exe or cl.exe for compiling asm subroutins?
Title: Re: Visual C++ compiler really have asm compiler inside or it is separate progra
Post by: Ossa on June 16, 2006, 02:16:32 PM
Hi again,

Quote from: Spartan on June 16, 2006, 02:12:52 PM
But  why use the ml.exe if cl.exe can compile asm code?

cl.exe can only assemble inline asm. It is very troublesome to code entire modules in asm from cl.exe, whilst ml.exe is setup to do exactly that.

Quote from: Spartan on June 16, 2006, 02:12:52 PM
And second question - what better to use ml.exe or cl.exe for compiling asm subroutins?

It depends on what you want to do. If you have subroutines composed of pure asm (no C/C++ what-so-ever) then use MASM. If the ASM forms only a small part of the routines, use inline ASM with cl.exe.

Ossa
Title: Re: Visual C++ compiler really have asm compiler inside or it is separate progra
Post by: hutch-- on June 16, 2006, 02:59:52 PM
CL.EXE and ML.EXE are very different tools and they respectively do their own tasks very well if properly understood but they line up with the output which is both COFF Microsoft format object modules and this make correctly written procedures in both usable by either. Both are fully application capable yet both can be used with each other to produce binay files so its really a case of pick what you need and write it to do that job.

Modern compiler design does not like inline asm as it messes up register allocation so in most instances, you are better off writing assembler code in MASM and linking the object module in VC projects. It works just as well the other way if you want a C algo in a MASM program.