Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing assembly code for the .Net platform

Tags:

c#

assembly

I'm a seasoned C# developer who wants, for fun, to write a bit of assembly code. I was wondering if it was easiest simply to write in byte code and somehow use the C# compiler, linker whatever. I'm a bit unsure on how to go about this.

Or maybe there is a decent assembly language out there with a step debugger and other nice things shipped in an environment that I should pick up instead?

I mainly want to write code to do calculations and output to the console window.

like image 731
Carlo V. Dango Avatar asked Jun 10 '11 13:06

Carlo V. Dango


People also ask

What is assembly in .NET with example?

NET-based applications. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. Assemblies take the form of executable (.exe) or dynamic link library (. dll) files, and are the building blocks of . NET applications.

What is a .NET assembly file?

NET defines a binary file format, assembly, that is used to fully describe and contain . NET programs. Assemblies are used for the programs themselves as well as any dependent libraries. A . NET program can be executed as one or more assemblies, with no other required artifacts, beyond the appropriate .

Can I write assembly code in Visual Studio?

Successful execution of an assembly code file with Visual Studio IDE depends on an external library file, which will be available from MASM SDK. Hence, choose project Properties by right clicking it from the solution explorer.

Can C# be compiled to assembly?

By default, the compiler creates an assembly file with an .exe extension. Visual Studio for C# and Visual Basic can be used only to create single-file assemblies. If you want to create multifile assemblies, you must use command-line compilers or Visual C++.


2 Answers

You can write IL code and compile it with ILASM

like image 168
Thomas Levesque Avatar answered Sep 29 '22 11:09

Thomas Levesque


You can write it in MSIL and assemble it via the MSIL assembler (ilasm.exe).

As for a debugger, I've previously used DILE (DotNet IL Editor) to step through IL code, it's a bit out-dated though.

Seems that DILE is still being updated, check out the weekly builds.

like image 26
Khaled Nassar Avatar answered Sep 29 '22 11:09

Khaled Nassar