BITFIELDS AND STRUCTURES

When I was writing keil c v/s svd2forth I wondered why so many embedded C Programming Languages use C Structures as their way of dealing with Register Bitfields. This page looks into that preference and compares it to the way Forth might deal with the same issues.

It has been suggested that “You often need to make sure the right accesses are being generated by the C compiler, if they’re defined as 32/64-bit integers in a struct you can be sure changes will generate the correct sized store/move. In Forth the access size is very explicit everywhere so it’s not ‘hidden’ in something like that. In C it tries to hide it… and then every embedded C programmer has to turf it up somehow.”

_images/wip-transparent.jpg