We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hey all,
I have a question relating to accessing C structure members from within an assembly module. I notice that the manual indicates that no type information from C modules is available to A51 modules (which makes sense). This leaves a bit of an ugly picture for the accessing of any external structures, however.
Does anyone have any clean method of getting the offsetof() an element within an assembly module? For the moment, I've hard-coded the byte offsets and put some notes in the source file not to rearrange the structure, but I find this unsatisfying. Any advice?
-Jay Daniel
I have tried to find some such without any success.
However for "structures with identical member sizes" I do the following:
instead of
struct Ralph { U8 member1 U8 member2 .... U8 member9 } I do the following U8 Ralph[9] #define member1 0 #define member2 1 .... #define member9 8 then, of course Ralph.member2 becomes Ralph[member2]
Erik
Erik,
Thanks for the tip. No such luck in this case (differing element sizes). I suspect that there's no cleaner way to do it than what I'm doing now, but I was holding out hope. Perhaps this is one of those situations where inline-assembly in the C source might be useful. That way, I could #define some offsetof()'s in the header files, let the compiler process them, and then use the #defined values in the in-line assembler.