News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

.NET

Started by NPNW, February 17, 2006, 05:04:49 AM

Previous topic - Next topic

NPNW

Anyone really dug into .NET?

I'm currently researching on the MSDN site and trying to narrow down how .NET and Assembly are going to get along?

Any ideas would be useful.   :bg

NPNW

NPNW

here is what I have found so far?

this link has additional information pertaining to the new .Net assembler.
http://msdn2.microsoft.com/en-us/library/496e4ekx.aspx


The reason that I am curious about this is that a friend of mine was trying to write a piece of code to interface into some .Net code and he couldn't get it written. They were hopeing to get the code to work in the 2.0 framework. Usually Microsoft will leave you some way to write it in Assembly and get the interface. It looks like they have a new assembler llasm.exe, and document how to access at least some of the .Net code. They then describe how to make .Net code.  There also appears to be an intermediary step where we have to write it to MSIL specification.

At least its a start.


QuoteThe following MSIL code example corresponds to the previous C# code example. You can compile this code into an assembly using the MSIL Assembler (Ilasm.exe) tool. Both MSIL and C# code examples display "Hello World!" to the console.

Copy Code// Metadata version: v2.0.50215
.assembly extern mscorlib
{
  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..
  .ver 2:0:0:0
}
.assembly sample
{
  .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
  .hash algorithm 0x00008004
  .ver 0:0:0:0
}
.module sample.exe
// MVID: {A224F460-A049-4A03-9E71-80A36DBBBCD3}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003       // WINDOWS_CUI
.corflags 0x00000001    //  ILONLY
// Image base: 0x02F20000


// =============== CLASS MEMBERS DECLARATION ===================

.class public auto ansi beforefieldinit Hello
       extends [mscorlib]System.Object
{
  .method public hidebysig static void  Main(string[] args) cil managed
  {
    .entrypoint
    // Code size       13 (0xd)
    .maxstack  8
    IL_0000:  nop
    IL_0001:  ldstr      "Hello World!"
    IL_0006:  call       void [mscorlib]System.Console::WriteLine(string)
    IL_000b:  nop
    IL_000c:  ret
  } // end of method Hello::Main

  .method public hidebysig specialname rtspecialname
          instance void  .ctor() cil managed
  {
    // Code size       7 (0x7)
    .maxstack  8
    IL_0000:  ldarg.0
    IL_0001:  call       instance void [mscorlib]System.Object::.ctor()
    IL_0006:  ret
  } // end of method Hello::.ctor

} // end of class Hello

Now to lookup the MSIL specification and try to get a complete picture of this process.

NPNW

gwapo

#2
Hi, try this link:
http://www.codeproject.com/dotnet/ilassembly.asp

It contains good introduction with MSIL and ILAsm

Regards,

-chris

NPNW

Chris,

Thank You!!!

Looks good.

This will definately help.

sluggy

Quote from: NPNW on February 17, 2006, 06:28:02 AM
The reason that I am curious about this is that a friend of mine was trying to write a piece of code to interface into some .Net code and he couldn't get it written. They were hopeing to get the code to work in the 2.0 framework.
The easiest and quickest way to do this is to write a mixed mode C++ dll, and call from your asm app to that and then into managed code. The other way to do it is to write a COM component as an interface, but that is harder to call from asm.

Quote
Usually Microsoft will leave you some way to write it in Assembly and get the interface. It looks like they have a new assembler llasm.exe, and document how to access at least some of the .Net code. They then describe how to make .Net code.  There also appears to be an intermediary step where we have to write it to MSIL specification.
MSIL is an assembly type language, which is similar in concept to java byte codes - when it comes time to execute the code it gets JIT compiled to whatever flavour of asm suits the processor that the code is running on. All .Net code is compiled to MSIL. The only time .Net code is compiled to a native image (full asm) is when the developer takes the extra step of using a tool called ngen.exe on it, but once you have done this you lose portability.


NPNW

Hi Sluggy,

I guess I am still trying to figure out what all the hoopla is on .NET and java. I know its managed code and supposedly there are some advantages. I just don't understand their logic. I personally would prefer to write most of my stuff in Assembler or C. The .Net and Java just seem to add more overhead and muddy the water when you go outside the box of what they have envisioned. I just don't see the flexability yet that I have with assembler. 

Is that what you have found out?


zooba

The flexibility is the capability to cater for the other 1% of the market that doesn't run Windows (not including webservers). If you're happy to settle for only 99% of desktop computers then you may as well not bother with .Net/java. :U

drhowarddrfine

I haven't messed with this stuff in a long time but, iirc, one of the advantages is the ability to combine code written in most languages and being able to run it on Windows.  This works great for large corporations that want to unify the platform they run on but it does nothing for smaller operations.  Other than that, anything .net can do you can do with any other method and you don't need Windows for that.

NPNW

Zooba,

That is what I was confused about. Why would you develope code in .Net/Java when most people predominately run on one platform? There are so many issues of performance, operating system specifics, with a one size fits all design methodology. I just don't get why all the trouble when it will rarely be used. 

I mean , if you are going to use Unix/Linux then code in Assembler/C for that platform.
If you are useing Windows/Windows server then code in regular Masm / GoAsm / HLA / etc.
Tools that work specifically with that platform to get the most out of your code.

The capabilites of .Net and Java don't yet to me seem relevent verses a well crafted Assembly program. I guess I just don't get it. I continue to study these areas in the hope that I will find something that makes more sense to me. I mean if it works well I want to incorporate it into my code.

Dr Howarddrfine,

i have some ideas for building software for corporations. However, the huge monolithic project is not exactly what I want. I am more along the lines of a lean simple program that does it's job well. Then continue to build upon that to add more functionality.

For webservers the ASP, Java, and .Net do they really provide an advantage? I mean what capabilites do they have that can not be built into a well crafted C/Assembly program?
Just my 2 cents worth, I just can't see the advantage yet over Assembly and C.



Timbo

NPNW,

It is possible to modify the IL ouput of a .NET assembly to have it export functions so that they can be called by native code.

http://www.c-sharpcorner.com/Code/2003/Aug/ExportManagedCodeasUnmanaged.asp

Enjoy,

Tim

arafel

Quote from: NPNW on February 19, 2006, 06:08:38 AM
...Why would you develope code in .Net/Java when most people predominately run on one platform? There are so many issues of performance, operating system specifics, with a one size fits all design methodology. I just don't get why all the trouble when it will rarely be used.

I mean , if you are going to use Unix/Linux then code in Assembler/C for that platform.
If you are useing Windows/Windows server then code in regular Masm / GoAsm / HLA / etc.
Tools that work specifically with that platform to get the most out of your code.

The capabilites of .Net and Java don't yet to me seem relevent verses a well crafted Assembly program....

It's not a point of what you can or cannot do in assembly/c versus managed languages, but more a development cost and speed issue.
And that what Java is all about. Fast software deployment at lower costs.

Obviously this is not much a concern for a common programmer. He doesn't need to worry about development costs skyrocketing when a new platform suddenly required to be supported by the product. Nor he needs to care about size of paychecks he going to write at the end of the month.
However from a company' point of view it either choosing a huge development team, even bigger qa team, another dev. team for another targeted platform, and what's not... Or adopting a managed language, and letting it's main purpose justify itself.

EduardoS

The reason for .Net and Java is costs,
VB s#$%s, but why so many people use it?
Because it's cheap,
Almost all programers know VB, and who don't know need only one month to learn, it's easy, so there are a lot of porgramers, you don't need to pay too much for them, and they will work fast (because it's easy to use),
But VB has thousands of problems, the .Net use the same ideia, and a managed code allow the system to control a big part of environment, so if the programer forgot the dispose on an object it won't crash the system.

NPNW

Arafel,
Quote
It's not a point of what you can or cannot do in assembly/c versus managed languages, but more a development cost and speed issue.
And that what Java is all about. Fast software deployment at lower costs.

Does it really work, or is it just a hack job? Hack jobs are okay to get an idea. Does Java/.Net actually deliver on what they promise? I haven't worked with .Net/Java enough and don't want to waste time on development if it doesn't do what they promise.

I guess my expectations are
Can I write the code, have it work according to documentation.
If there is a problem do they fix it in a short time or do I have to wait months or years?
Do they have their interface and internals documented so that I can make a work around?
What are the issues with changing over to another platform?
Even if it works does it work efficiently? Not everyone can afford the newest hardware.


Quote
Obviously this is not much a concern for a common programmer. He doesn't need to worry about development costs skyrocketing when a new platform suddenly required to be supported by the product. Nor he needs to care about size of paychecks he going to write at the end of the month.

I agree for the average programmer this is not a problem. For me I never seem to get involved in those types of projects. I'm usually the guy who ends up fixing things.

Quote
However from a company' point of view it either choosing a huge development team, even bigger qa team, another dev. team for another targeted platform, and what's not... Or adopting a managed language, and letting it's main purpose justify itself.

For this argument I see what .Net/Java were designed for. Again, does it work?

NPNW

EduardoS,

Hello,

Here is another quetion. 
If .Net/Java work so well, why are they asking for people with Bachelor/Masters degrees with 5-10 years experience when it is suppose to be managed code.

I thought that was what managed code was to be productive. If you need someone with a huge amount of experience then they must have all types of problems and its not really very good managed code then?

Mark Jones

Quote from: EduardoS on February 19, 2006, 02:25:52 PM
The reason for .Net and Java is costs, VB [sucks], but why so many people use it?
Because it's cheap, almost all programers know VB, and who don't know need only one month to learn, it's easy, so there are a lot of porgramers, you don't need to pay too much for them, and they will work fast (because it's easy to use)...

...and when their algorithm is too slow, they can hire one of us to optimize their routine for only $60/hr. :bdg :toothy
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08