Thread: Watcom C++ inline assembler

  1. #1
    Registered User
    Join Date
    Jun 2002

    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):

    #include <stdio.h>
    class myClass
    	void myFunction();
    	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;
    		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()
    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

    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!

    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, 04:57 PM
  3. Certain functions
    By Lurker in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2003, 01: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