Thread: Calling Class Functions in ASM?

  1. #1
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question Calling Class Functions in ASM?

    I am trying to call a function that is in a class, through ASM. I have looked at the Assembly Listing Files, and I tried the code. It didn't work. I am programming an engine in SDL, btw. It was something like this (what I got from the listing files):

    Code:
    __asm
    {
    push 0
    mov  edx, SDL_SWSURFACE | SDL_ANYFORMAT
    push edx
    push 16
    push 480
    push 640
    mov  ecx, szTitle
    push ecx
    mov  eax, DWORD PTR screen
    
    mov  ebx, g_Engine        // 'g_Engine' : My global engine class declaration
    call    SDLWindow           // Call 'EngineSDL::SDLWindow'
    }
    This code will give me an error that says (something like this):

    'SDLWindow' ... Label not defined

    The listing file had some other characters in it, but they weren't part of the code. And it also included some text 'EngineSDL'. At the end, the comment says " EngineSDL::SDLWindow". If anyone can offer me any help on how to call the equality to g_Engine->SDLWindow(...) in ASM, please help me. I would like to figure this out.

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Just a suggestion...

    Use your compiler to display the assembly syntax for calling a c++ function in 'normal' c++ code. Presumably you could then adapt this information to ensure that 'SDLWindow' is defined?
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    There's no easy way to do it, and if you find a way it might not work on another (similar Win32) compiler, a different version of the compiler or even a different build configuration (optimised release builds can often take big liberties with how class members are dealt with....you may find that your code is broken at the point where you want to release it).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Calling functions through class
    By DJPlayer in forum C++ Programming
    Replies: 9
    Last Post: 12-11-2008, 02:48 AM
  2. Read-only class members
    By kidburla in forum C++ Programming
    Replies: 4
    Last Post: 10-14-2006, 12:52 PM
  3. Need help to build network class
    By weeb0 in forum C++ Programming
    Replies: 0
    Last Post: 02-01-2006, 11:33 AM
  4. Functions in class and class variables.
    By Karakus in forum C++ Programming
    Replies: 4
    Last Post: 01-15-2006, 03:29 AM
  5. Calling a Function From A Class
    By Okiesmokie in forum C++ Programming
    Replies: 8
    Last Post: 06-28-2002, 10:09 PM