开发者

how to make struct member pointer in assembly?

开发者 https://www.devze.com 2023-01-01 17:07 出处:网络
I\'m trying to create a macro which would make easier to point to a structs member. C开发者_运维问答urrently I am pointing to a structs member in assembly file using the STRUCT_NAME + offset method.

I'm trying to create a macro which would make easier to point to a structs member. C开发者_运维问答urrently I am pointing to a structs member in assembly file using the STRUCT_NAME + offset method.

For example if I want to point structs third member, I would have to do it like this:

STRUCT_NAME + 3

This seems stupid way to do it, and if I insert more members in the struct, I have to update all the offset values in the code.

Is there a way to point using STRUCT_NAME + macro(struct_name, member_name)?

I`m using texas instruments TMS320C28x hardware.

Thanks!


Your compiler should have the offsetof macro, not sure if you can use that from within inline-assembly though.

0

精彩评论

暂无评论...
验证码 换一张
取 消