bæltazor
bæltazor

Reputation: 423

Writing Assembly and C in Visual Studio

I have seen a lot of talk about this but I can't get it to work. Maybe the information is outdated or I might have done something wrong. But, is it possible to write and compile Assembly and C code in Visual Studio?

Are there basic project templates available for these languages, I mean, in the same way that there are VB, C++ and C# project templates for creating new projects?

I am using Visual Studio 2012 Ultimate. I also have all of the Visual Studio Express Editions installed.

Is it possible to write assembly and/or C code from within a normal C++ project?

I'm sorry if this is a dumb question, but I want to learn more low level languages. I feel like I would be able to better understand a lot of things if I learn what is actually happening at a much lower level.

Upvotes: 3

Views: 4252

Answers (3)

David Heffernan
David Heffernan

Reputation: 613442

Out of the box, VS does not include a standalone assembler. You can write inline assembly in your C or C++ source code, but only for x86 targets. For anything beyond inline assembly you'll need to use a separate assembler. You can of course link the object files produced by an assembler into your MSVC project.

As for C, the MS compiler will compile code that broadly follows the C89 standard. But MS have stated repeatedly that they will not update their C compiler to newer standards. If what MS support is enough you just include files with a .c extension in your project and compile. Otherwise, if what MS support is not sufficient for you, then you are looking at external compilers.

Update

I stand corrected. Visual Studio does indeed ship with the standalone Microsoft assembler MASM.

Upvotes: 3

torak
torak

Reputation: 5812

One thing to be aware of is that, as stated here, you can't use inline assembly when compiling for x64.

Visual Studio also includes the MASM assembler in both ml.exe (32-bit) and ml64.exe. This may be of some assistance with getting started on their use.

Upvotes: 6

Devolus
Devolus

Reputation: 22094

If you just want to implement some small things for a function, you can do this via inline assembly. If you want to write more complex functions, then you can also use an external assembler. In this case you can configure the properties of the source file to use an external command and you have to write the command line yourself, as well as specifying the source and targets.

Upvotes: 0

Related Questions