Thread overview
Inline Assembler
Aug 11, 2004
Michael
Aug 11, 2004
Michael
August 11, 2004
Hello, I was just wondering if there is a way to use structures in inline assembler... what I mean is:


struct st {
int x, y;
}

st my_struct;

asm {
mov EAX, my_struct.x;
}

I know I could use

asm {
mov EAX, [my_struct+4];
}

But I don't trust I could avoid padding issues and everything.

Any opinions, or solutions, are very welcome.


August 11, 2004
Sorry meant to use .y in my example (hence [my_struct+4])

I'm doing this now, and it is working fine, but I remember reading that D will shuffle the contents of struct for efficiency...


..later...

Alright just found out about StructName.member.offset, that should much safer, I think.


August 12, 2004
nope, D only shuffles class members for efficiency.  structs are left as they are, as they are often used to "memberize" memory-mapped hardware, file data etc.

but using the struct.x should be fine, and you shouldn't have to use the offset.  it's all struct members compile to anyway - an offset.