Results 1 to 7 of 7

Thread: inline asm

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Posts
    566

    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

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Posts
    566

    Re: inline asm

    yes? no? maybe so?
    if you helped me, consider yourself thanked

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4
    Lively Member Girvo911's Avatar
    Join Date
    Dec 2004
    Posts
    88

    Re: inline asm

    Not sure whether this will help but,

    http://www.thecodeproject.com/csharp...ASM_for_C_.asp
    Life may suck, but we can't live without it...
    ----------------------


    Quote 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.

  5. #5
    Lively Member Girvo911's Avatar
    Join Date
    Dec 2004
    Posts
    88

    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...
    ----------------------


    Quote 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.

  6. #6
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    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.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Posts
    566

    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
  •  



Click Here to Expand Forum to Full Width