Question: How can I access a member variable in an assembly from a non-POD class?
Development:
I wrote some built-in assembler code for a member function of a class, but it eluded me how to access the member variables of the class. I tried the offsetof macro , but this is not a POD class.
The current solution I'm using is to assign a pointer from the global scope to a member variable, but this is a messy solution, and I was hoping there was something better that I don’t know about.
note: I am using the g ++ compiler. A solution with Intel Asm syntax would be nice, but I'll take something.
example of what I want to do (syntax):
class SomeClass
{
int* var_j;
void set4(void)
{
asm("mov var_j, 4");
}
};
current hacker solution:
int* global_j;
class SomeClass
{
int* var_j;
void set4(void)
{
asm("mov global_j, 4");
var_j = global_j;
}
};
, , .