Hi!
I had a discussion in the other day about the usefullness and validity of the following (non-std) C extension in PICC:
static bit BitVar @ 0x20*8+0;
This would mean that a static variable, named BitVar will be located in the memory at address 0x20 at bit 0. (Note, that this C compiler is for an 8-bit microcontroller and this construct should provide a means to define HW-related functions in C.)
With this declaration the following program would set bit 0 of address 0x20 to 0 and bit 1 to 1:
static bit BitVar1 @ 0x20*8+0; static bit BitVar2 @ 0x20*8+1;
void main() { BitVar1 = 0; BitVar2 = 1; }
The discussion was about two things:
- Since there are other (though more complex) constructs in standard C to achieve the same effect, is it a good idea to add a new built-in type (without the __ prefix) and an address-binding syntax (with the @ operator) to the language?
- Since all operations on all modern CPUs are work on at least 8-bits of data at once, is it even possible to compile such a source program into a valid executable (in a sense that it accesses only memory that's defined in the source)?
We couldn't on our own reach an agreement so I seek the opinions of a wider audience.
-- Thanks, Andras Tantos