Watcom C++ inline assembler

This is a discussion on Watcom C++ inline assembler within the C++ Programming forums, part of the General Programming Boards category; I'm having many troubles with inline asm block referring to C++ data, either structs or classes. I read on the ...

  1. #1
    r0x
    r0x is offline
    Registered User
    Join Date
    Jun 2002
    Posts
    5

    Watcom C++ inline assembler

    I'm having many troubles with inline asm block referring to C++ data, either structs or classes. I read on the help files that Watcom inline assembler doesn't support TASM/MASM macros for accessing structs, and that should be only a readability problem; the "real" problem is with member functions, because I need to refer to 'this' pointer, at least. But 'this' is an undeclared reference in inline asm blocks, so this is my only solution, at the moment (it's a stupid example):

    Code:
    #include <stdio.h>
    
    class myClass
    {
    public:
    	void myFunction();
    
    private:
    	int myMember1;
    	int myMember2;
    	int myMember3;
    
    } myObject;
    
    void myClass::myFunction()
    {
    	int a, b, c;
    
    	myMember1 = 10;
    	myMember2 = 20;
    	myMember3 = 30;
    
    	const myClass* const myThis = this;
    
    	__asm
    	{
    		mov		ebx, myThis
    		mov		eax, [ebx]
    		mov		a, eax
    		mov		eax, [ebx+4]
    		mov		b, eax
    		mov		eax, [ebx+8]
    		mov		c, eax
    	}
    
    	printf( "%d %d %d\n", a, b, c );
    }
    
    void main()
    {
    	myObject.myFunction();
    }
    I would be very pleased if anyone tells me an alternative and more flexible solution. I'm starting to hate Watcom! Version is 11 (patched to 11.0c from openwatcom.org).

    P.S.: 'this' is on the stack but I cannot find it through ebp/esp. I tried many values, but I'm for [ebp+8] (return address+pushed ebp), and doesn't work at all!

    Bye!
    Last edited by r0x; 06-03-2002 at 12:10 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  2. inline assembler as alternative to int86()
    By Bigbio2002 in forum C Programming
    Replies: 3
    Last Post: 11-12-2004, 03:57 PM
  3. Certain functions
    By Lurker in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2003, 12:26 AM
  4. Inline Assembler Macros?
    By Aidman in forum C++ Programming
    Replies: 14
    Last Post: 07-15-2003, 05:10 AM
  5. Inline Assembler
    By mikef in forum C Programming
    Replies: 4
    Last Post: 08-22-2002, 03:28 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21