Is READ/WRITE_REGISTER_UXYZ still best practice?

Based on my searches of this forum, it appears that the answer is “YES”, just checking, since I’ve only recently returned to bit banging after more than a decade writing software much higher in the stack …

my_struct-\>member = 42 is considerably easier to read than WRITE_REGISTER_ULONG(PULONG(my_struct + offsetof(MY_STRUCT, member)), 42).

Maybe I need to make an addressof() thing for that …

Thanks in advance for any discussion you might offer,

Phil B

Not speaking for AMD
Phil Barila
Senior Software Engineer | AMD
Adaptive and Embedded Computing Group
C +(1) 303-249-9361

“WRITE_REGISTER_ULONG(&my_struct->member, 42);” works just fine, reads pretty easily, and compiles to exactly the same code you have above (assuming the platform doesn’t have memory barriers).

1 Like

@Tim_Roberts said:
“WRITE_REGISTER_ULONG(&my_struct->member, 42);” works just fine, reads pretty easily, and compiles to exactly the same code you have above (assuming the platform doesn’t have memory barriers).

Yeah, that is quite readable. Wish I had thought of that … :slight_smile: