Accessing File registers in C by address. Pointers again
Peter email (remove spam text)
William "Chops" Westfield <westfw <at> mac.com> writes:
> volatile neat unsigned char *addr;
> Various C's are variously picky about having all those extra
> bits match up. You can also cast, but that would be evil.
Some compilers (which?) support an extended notation like:
#define LSFR ...
unsigned int foo @ LSFR;
And later foo can be used as usual.
I can find no references on 'neat', do you have a pointer for documentation on
Also one tries to use a predefined type or such to avoid too much typing.
I think that it is also valid to use a #defined or inlined function to represent
the hairy assignment. I.e. something like:
#define fsrub(addr) (*((unsigned char*)addr))
#define fsruw(addr) (*((unsigned short*)addr))
Then one could write:
fsrub(LFSR) = my_usqrt(fsrub(LFSR) + bias); ...
Defining the above as functions during debug time can add the possibility of
argument type and range checking, to be followed by recompilation with suitable
#defined flags to use the presumably shorter #defined code.
See also: www.piclist.com/techref/microchip/languages.htm?key=c
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the