Arm Community
Site
Search
User
Site
Search
User
Support forums
Arm Development Studio forum
give C struct to assembler...
Jump...
Cancel
Locked
Locked
Replies
7 replies
Subscribers
119 subscribers
Views
10961 views
Users
0 members are here
Options
Share
More actions
Cancel
Related
How was your experience today?
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion
give C struct to assembler...
Etienne SOBOLE
over 12 years ago
Note: This was originally posted on 24th November 2011 at
http://forums.arm.com
how can I send the offset of a C struct to en assembly code ? For example
In my C code I have
typedef struct
{
unsigned int a;
unsigned int b;
} CMyStruct;
I send to an ASM function a pointer of a CMyStruct structure Let suppose that my pointer is into R0
To access to a and b attribute I need to do that.
ldr r1, [r0, #0] // read a
ldr r2, [r0, #4] // read b
Is there anyway to not specify #0 and #4 as contant value ? Something like
ldr r1, [r0, CMyStruct.a] // read a
ldr r2, [r0, CMyStruct.b] // read b
Thank's Etienne
Parents
Gilead Kutnick
over 12 years ago
Note: This was originally posted on 26th November 2011 at
http://forums.arm.com
I haven't ever come across a way to communicate this information from GCC to GAS. I use #defines in my assembly files to specify the offsets. I usually create them manually. But you could write a program which converts a header and all the structs in it into a C program which creates a new ASM safe offset header files that you can #include from the ASM. The tricky part here is that the program has to run on the same device that's executing the C code, which may not be an option for some embedded platforms. So it's not something you can easily put in a makefile if you're cross-compiling.
Doing it manually does at least help you pay more attention to organizing your data efficiently.
Cancel
Vote up
0
Vote down
Cancel
Reply
Gilead Kutnick
over 12 years ago
Note: This was originally posted on 26th November 2011 at
http://forums.arm.com
I haven't ever come across a way to communicate this information from GCC to GAS. I use #defines in my assembly files to specify the offsets. I usually create them manually. But you could write a program which converts a header and all the structs in it into a C program which creates a new ASM safe offset header files that you can #include from the ASM. The tricky part here is that the program has to run on the same device that's executing the C code, which may not be an option for some embedded platforms. So it's not something you can easily put in a makefile if you're cross-compiling.
Doing it manually does at least help you pay more attention to organizing your data efficiently.
Cancel
Vote up
0
Vote down
Cancel
Children
No data