Thread: Using external ASM function in C++

  1. #1
    For Narnia! Sentral's Avatar
    Join Date
    May 2005
    Location
    Narnia
    Posts
    719

    Using external ASM function in C++

    I want to know the advantages of using external ASM functions, in a C++ program. If anyone has an example of how this is done would be nice. Also, in what situations and how often should this be used? Do I still get the same flexibility with ASM functions as I do with C++ function in my program? Thanks!
    Videogame Memories!
    A site dedicated to keeping videogame memories alive!

    http://www.videogamememories.com/
    Share your experiences with us now!

    "We will game forever!"

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    pros: speed, closer hardware interaction
    cons: not portable outside the architecture. Not as easy to interact with the rest of the C/C++ program.
    uses: optimization, device driver programming, OS programming
    example:
    Code:
    extern "asm"
    {
        mov ax, bx
    }

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Code:
    extern "C" void Foo(int iParams)
    Parameters begin at ebp+8. Don't forget this:

    Code:
    push ebp
    mov ebp,esp
    
    ...
    ...
    
    pop ebp
    Or your code will crash.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. Replies: 5
    Last Post: 02-08-2003, 07:42 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 09:51 AM