How can we do this In assembly we do mov P0, #10001000B
But in Keil how can we do this P0 = 10001000, in binary not by P0 = 0x11; Thank you!
Standard C does not include a notation for integer literals in binary. Decimal, hexadecimal, and octal, yes; binary, no.
I've occasionally seen macro solutions such as that mentioned above. Most C programmers I've known just write the number in hex. The translation from that to binary is fairly easy in your head.
"in assembly we have, DB 00010000B, is nt there any equivalent in C"
Yes, that was the original question! Review the answers already given, and you will find the answer!
Could move it bit by bit, P0.0 = 1 P0.1 = 0 ... or, could take the whole thing as a string and proceed,
in assembly we have, DB 00010000B, is nt there any equivalent in C,
It works right!
By The Way: Note that Keil C51 does provide an extension to the standard 'C' language that allows you to make use of the 8051's bit-addressable features.
You need to look it up in the Manual
This won't help you for writing binary constants, of course.
I've found a topic to do this
#define LongToBin(n) \ (\ ((n >> 21) & 0x80) | \ ((n >> 18) & 0x40) | \ ((n >> 15) & 0x20) | \ ((n >> 12) & 0x10) | \ ((n >> 9) & 0x08) | \ ((n >> 6) & 0x04) | \ ((n >> 3) & 0x02) | \ ((n ) & 0x01) \ ) #define Bin(n) LongToBin(0x##n##l)
http://www.c-for-dummies.com/
This has nothing specifically to do with Keil - it is standard 'C'.
You need to look in any 'C' textbook for the number base representations supported by the 'C' programming language...
You might wanna check the Binary for Dummies manual ;-)
View all questions in Keil forum