H
harvie wang
I want to embeded ASM code in c# code ,like C++ embed asm:
_asc{
mov ax,3
.....
}
how to do?
thanks!
_asc{
mov ax,3
.....
}
how to do?
thanks!
harvie wang said:I want to embeded ASM code in c# code ,like C++ embed asm:
_asc{
mov ax,3
....
}
how to do?
Daniel O'Connell said:You can't. C# compiles in a relativly machien independent manner, so x86
assembly wouldn't make sense.
make sense (and even be useful on rare occasions.)
Abubakar said:thats right and infact writing code in Ilasm inside C# (like __asm in c++)
was submitted as a suggestion to microsoft for C# 2.0 and got a lot of
positive votes but still it was rejected cuz they say it was complicating
the
language and nothing valueable enough could be achieved through this
feature.
Daniel O'Connell said:I tend to agree. Adding an entire sublanguage and primary langauge hookups
for a feature that has very minimal value doesn't make sense. Adding ILASM
could double the complexity of the compiler, IDE, and language to help the
handful of people that would actually use it properly.
Actually, I agree too. Allowing ILASM and C# files to be linked into the
same assembly would solve the same set of problems much more naturally.
(It still strikes me as bizarre that a system deisgned from day one to
support multiple languages and compiles them all to a common object format
doesn't support heterogeneous linking.)
Jeff Louie said:You can code in IL assembler and call the dll method from c#
ilasm testildll.il /dll
OK..
Here is the assembler code that prints a string to the console wrapped
in a dll
call testildll. To compile this code is the ilasm with the /dll
directive:You can then add a reference to the dll in your C# project and callilasm testildll.il /dll
the method.
// testildll.il
// 11.29.04 Jeff Louie
.assembly extern mscorlib {}
.module testildll.dll
.class public auto autochar Class2
{
.method public hidebysig static void Test() cil managed
{
.maxstack 1
ldstr "JAL 11.25.04"
call void [mscorlib]System.Console::WriteLine(string)
ret
}
}
Regards,
Jeff
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.