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):
I would be very pleased if anyone tells me an alternative and more flexible solution. I'm starting to hate Watcom!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(); }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!



LinkBack URL
About LinkBacks
Version is 11 (patched to 11.0c from openwatcom.org).


