|
-
January 9th, 2013, 07:13 AM
#11
Re: Representing and dynamically creating a managed object in assembly
 Originally Posted by AKRichard
I just remembered reading somewhere, that when passing an object to assembly code from c++ that the actual value passed in is equavilent to the "this" pointer. [...]
Perhaps my assumptions about the context that refers to are incorrect, but I'd say this specifically refers to passing the object by pointer or reference, when what actually gets passed is the address of the object rather than the object itself. Now, what gets actually passed when passing an object A a; by pointer, is &a, i.e. the address of a from any perspective where a is in scope. And this is exactly the same as this as seen from inside of an a member function (or, more elaborate, an A member function called on the instance a). However, IMO that rather explains the nature of the this pointer than how objects are passed to assembly language routines.
I have been trying to figure out what was going on, when using the value passed into the assembly routines I have to do something like
Code:
mov r11 qword ptr[rcx]
, then I could use instructions such as :
Code:
mov rax, [r11].BI._sign
and such. [...]
Again, I'm not exactly sure about the 64-bit calling convention, but given that rcx holds a pointer to a pointer to a BI object, then yes. Also, I'd expect the second statement to rather look something like
Code:
mov rax, BI ptr [r11]._sign
but that may be x64 assembly language details I'm not aware of.
[...]the only reason why I am asking is because if that is the fact then I can get rid of the translating sections of code in both assembly and c++. [...]
I don't know your translation code, but as I understand it, the main thing you'd get rid of that way is the necessity to make object copies, likely but not necessariliy incurred by passing them by value. And that may give you a nice performance boost.
[...] So if I am understanding this correctly, the "this" pointer could be looked at as an array itself holding pointers to the data itself like I have setup in the structure allready.
Whell, if that's the memory layout of the C++ object, then that's it. There's nothing more to that as I understand it.
And we're still not covering how to wrap the objects to make them .NET-friendly, but as you seem to be testing your code in a .NET environment all the way, you already must have done that somehow.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|