Topic: Accessing objects from assembler


Author: Carsten Ditze <cadi>
Date: 1995/07/26
Raw View
I have to integrate some assembler code into a C++ method and want to know if
parameter passing is/will be a standardized aspect of C++.  Example:

class A {
private:
 int data;
public:
 void print(char* format);
};

If I want to access 'data' from assembler, I have to do it via the 'this'
pointer, which is a hidden parameter for the 'print' method.  Currently all
compilers I know about (including g++) pass the this - pointer first, so that
the method above is equivalent to

friend void print(const A* this, char* format);

Is it part of the standard, that
1. the this-pointer will always be a hidden parameter to a method  *and*
2. the this-pointer will always be the first one that is passed ??

(Furthermore (vice versa), can I call a method from assembler, if I know the
object?)

I'm working on a new OO-Operating System, and my experiences using C++ show
more
and more that the language is too restrictive for implementations at level
close to hardware

E.g.: The code address of a method is not accessible, but this is required for
      many services of an operating system (for instance dynamic code loading)

--

+------------------------------------------------------------------------+
| Carsten Ditze                   | e-mail: cadi@uni-paderborn.de        |
| University of Paderborn         | or:     cadi@pbinfo.uucp             |
| FB 17 (Dept. of Math. & CS)     | or:     ...!uunet!unido!pbinfo!cadi  |
|                                 | voice:  +49 +5251 60-2074            |
| 33095 Paderborn, Germany        | fax:    +49 +5251 60-3427            |
+------------------------------------------------------------------------+