| ??? 02/19/02 06:21 Read: times |
#19928 - RE: 1 bit operation in C |
Hello Gopal.
If you make the variable bit addressable, only then C compiler will translate (setting and clearing of a particular bit of the variable) into SBIT and CLR instructions. You could also make a variable bit addressable using "int bdata my_var", and then pointing a bit variable to it using "sbit mybit = my_var^0". I have given you help using KEIL tools. Some data types may not comply with ANSI C, therefore may not work with other tools. Check your tools for help. e.g. Observe the code below. Here I have made the variable of type bit. The way I have placed my sections in the link directives, temp is 0x20.0 (byte address) or 0x0 bit address. This resolves to SETB and CLR instructions. ---------------------------------------- #include <reg51.h> bit temp = 1; void main () { while (1) { if ((P0&0x1) == 1) temp = 1; else temp = 0; } } -------------------------- Regards Aman |
| Topic | Author | Date |
| 1 bit operation in C | 01/01/70 00:00 | |
| RE: 1 bit operation in C | 01/01/70 00:00 | |
| RE: 1 bit operation in C | 01/01/70 00:00 | |
| RE: 1 bit operation in C - Hosman | 01/01/70 00:00 | |
| RE: 1 bit operation in C - Aman | 01/01/70 00:00 | |
| RE: 1 bit operation in C | 01/01/70 00:00 | |
| RE: 1 bit operation in C - Andy | 01/01/70 00:00 | |
| RE: 1 bit operation in C - Andy | 01/01/70 00:00 | |
| RE: 1 bit operation in C - Andy | 01/01/70 00:00 | |
| RE: 1 bit operation in C - Andy | 01/01/70 00:00 | |
| RE: 1 bit operation in C - Andy | 01/01/70 00:00 | |
| RE: 1 bit operation in C - Andy | 01/01/70 00:00 | |
RE: 1 bit operation in C - Andy | 01/01/70 00:00 |



