|
-
Dec 16th, 2005, 08:24 PM
#1
Thread Starter
Fanatic Member
inline asm
is it possible to use inline asm in C# like in C++?
C++ Example:
Code:
_asm
{
push 0
push title
push message
push 0
call blah
}
possible?
if you helped me, consider yourself thanked
-
Dec 18th, 2005, 10:24 PM
#2
Thread Starter
Fanatic Member
if you helped me, consider yourself thanked
-
Dec 18th, 2005, 11:51 PM
#3
Re: inline asm
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.
-
Dec 18th, 2005, 11:56 PM
#4
Lively Member
Life may suck, but we can't live without it...
----------------------
 Originally Posted by penagate
What the hell is 'Ptr'? All pointers will be untyped? That points (if you'll excuse the lame pun) to disaster, if you ask me.
-
Dec 18th, 2005, 11:59 PM
#5
Lively Member
Re: inline asm
Also, i found something on a site that might be interesting:
C# has a magical "unsafe" keyword that lets me write assembly language inline in a method body
Code:
/**
* 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
}
}
http://www.darronschall.com/weblog/archives/000162.cfm
Life may suck, but we can't live without it...
----------------------
 Originally Posted by penagate
What the hell is 'Ptr'? All pointers will be untyped? That points (if you'll excuse the lame pun) to disaster, if you ask me.
-
Dec 19th, 2005, 05:12 PM
#6
Re: inline asm
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
I don't live here any more.
-
Dec 19th, 2005, 09:30 PM
#7
Thread Starter
Fanatic Member
Re: inline asm
wossname, that's exactly what I wanted to know, thanks. I'll stick with C++ I guess
Thanks guys.
if you helped me, consider yourself thanked
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|