Hello all, I have been pondering upon getting each bit of a variable (e.g. declared as char) using a for loop char bdata Char1; bit y; for(x=0; x<7; x++) y = Char1^x; My question is : Is it possible?
If you are trying to make y equal to bits 0 through to 7 in turn you could do this: unsigned char x; unsigned char char1; bit y; for(x=0;x<8;x++) { y=(char1 >> x) & 0x01; } There is no particular advantage I can think of for using a bdata variable in this situation. Stefan
When I am done with my application in which I am trying to interface an EEPROM with C52, I shall send u the code for your remarks. Anyway Thanks again. Friendly Regards, Mansoor
bit y; for(x=0; x<7; x++) y = Char1^x;
Is it possible? Nope. Your example assumes that bits can be accessed indirectly. The 8051 does not support pointers to bits or any other type of indirect bit access. Therefore, the compiler ALSO doesn't support pointers to bits. This is documented in the manual. Jon