Original Post
I've just started working with inline assembly in VC++ express edition (just for fun). I've run into a problem when working with pointers & structures. Adding x.a and y.a through pointers doesn't work, because a is a field of both class1 and class2. I thought I had read you could access it like this: But that doesn't seem to work either. I suppose when only given [ebx].a, the compiler can't infer what type it would be. So I'm not sure if I'm making a syntactic error, or if I should be doing this in an entirely different fashion. Anyway, any help would be appreciated. Thanks for reading, Juturnas
typedef struct {
int a;
} class1;
typedef struct {
int a;
} class2;
void do_something() {
class1 x;
class2 y;
class1 *i = &x
class2 *j = &y
int foo;
__asm {
/* Add x.a and y.a directly, works fine */
mov eax, x.a
add eax, y.a
/* Add x.a and y.a through pointers, doesn't work */
mov eax, i
mov eax, [eax].a
mov ebx, j
mov ebx, [ebx].a
add eax, ebx
}
}
add eax, [ebx].class1.a