digitalmars.D - Inline Assembler
- Michael (15/15) Aug 11 2004 Hello, I was just wondering if there is a way to use structures in inlin...
- Michael (6/6) Aug 11 2004 Sorry meant to use .y in my example (hence [my_struct+4])
- Jarrett Billingsley (5/5) Aug 11 2004 nope, D only shuffles class members for efficiency. structs are left as
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.
Aug 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.
Aug 11 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.
Aug 11 2004