On Sun, 7 Dec 2008, William \"Chops\" Westfield wrote: > On Dec 7, 2008, at 6:01 PM, solarwind wrote: > > GIE = 0; //(INTCON[7]) Disable global interrupts > RABIE = 1; //(INTCON[3]) Enable PORTA/PORTB > change interrupt > RABIF = 0; //(INTCON[0]) Change interrupt flag > bit - clear > C1ON = 0; //Disable comparators 1 and 2 > C2ON = 0; > > Hmm. Those are sort of interesting, since the left-side symbols are > single bits. Does HTC actually let you do that sort of thing? Yes. > I > mean, it's within what the PIC architecture allows via BSD/BCF > instructions, and it's within the "extensions" I've seen for some C > compilers on microcontrollers, but it's clearly not standard C, Sure it is. Those symbols are defined by the implementation by including implementation-specific header files. What happens under the hood is of no concern to the programmer. It's really no different than, say, the standard offsetof() macro. Its implementation details are of no concern to the programmer and it undoubtedly uses non-portable, and possibly non-standard constructs to get its job done. > I also might tend to avoid > this syntax as being less portable; it depends on how badly the code > generator does with more standard C constructs like: > INTCON |= INTCON_RABIE; > or > INTCON.RABIE = 1; There is no "portable" way to access a PIC's internal registers. You have to rely on the implementation to define INTCON. Both the examples you cite are problematic: the first is error prone since there's nothing to ensure the register matches bit mask, and both require you to remember which register RABIE is in. Hi-Tech's approach gives optimal code for something like "RABIE = 1", with the helpful side effects of not being error-prone and not requiring you to remember which register RABIE is in. -- John W. Temples, III -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist