is it possible to use inline asm in C# like in C++?
C++ Example:
possible?Code:_asm
{
push 0
push title
push message
push 0
call blah
}
Printable View
is it possible to use inline asm in C# like in C++?
C++ Example:
possible?Code:_asm
{
push 0
push title
push message
push 0
call blah
}
yes? no? maybe so?
It appears not, in so far as every reference to "inline assembly" I can find in the help relates to C++. I've also never heard anyone mention doing it previously. I'd guess that you'd have to write your assembly code in a C++ library and reference that from your C# app.
Not sure whether this will help but,
http://www.thecodeproject.com/csharp...ASM_for_C_.asp
Also, i found something on a site that might be interesting:
Quote:
C# has a magical "unsafe" keyword that lets me write assembly language inline in a method body
http://www.darronschall.com/weblog/archives/000162.cfmCode:/**
* Manipulates the stack directly. Note the use
* of the unsafe keyword which allows us to use
* the __asm keyword.
*/
private unsafe string[] listFiles(string path) {
__asm {
push path
push 1 // number of arguments
push "mFile"
getv // get the mFile global object
push "listFiles"
callm // call mFile.listFiles method
}
}
Hang your head in shame. That is not assembly.
And no, C# doesn't do inline ASM. Or at least not natively. You can get a few crappy tools that let you fake it out but its still not the real deal.
If you want to get a benefit from ASm in a C# app then you'd be better off writing a DLL in ASM and linking it directly into your C# program. This has more or less the same effect as inline ASM anyway, both ways are a compromise in the "Managed code" paradigm.
C# and ASM are not designed to be used together. C++ and ASM are (sort of).
Hey, at least you aren't using VB.net ;)
wossname, that's exactly what I wanted to know, thanks. I'll stick with C++ I guess :thumb:
Thanks guys.