News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Offset of a struct within a struct

Started by sluggy, November 22, 2005, 12:33:26 PM

Previous topic - Next topic

sluggy

Here is a nice simple question for everyone.... i have a TOOLINFO struct embedded in another struct (call it 'structA'). The esi register points to structA. Is there a nice easy pretty way to get the offset of the TOOLINFO struct from that? Kind of like this piece of pseudo code:


  assume esi : ptr structA
  mov edi, [esi].toolInfo


Basically, i want edi to end up with a pointer to the TOOLINFO struct embedded in this instance of structA. Is there a way of doing this without having to actually calculate the offset?

The reason why i ask is because everytime i modify the definition of structA, i have to go through the code and adjust offset calculations. The other option is to have to a bunch of global variables holding offset values. Neither of these options is particularly desirable, which is why i'm hoping there is an easy way i don't know about  :red

Cheers  :U


Gustav


what about

lea edi, [esi].toolinfo

:green


sluggy

Doh!! I should have thought of that! Thanks for the super quick answer, it works nicely  :P