Hi, i'm using Keil Evaluation Boards to program my STM32F4Discovery. I was wondering, why can't I use boolean or bit type data? Or it's because i'm using the Evaluation version? I want to use "true" or "false" value, maybe i can use another type data besides that two buddies? I'll be happy and glad if anybody can help me with this one. Sorry for my bad english...
Got the answer. for bool type variables, the size is 8bits i.e. 1byte. hence, bool in ARM is not same as bool on x51 architecture.
structures & bit padding can be done instead of 'bool'
On c51 it's a bit type that only has one bit of storage allocated.
Why not Please read the manual? Dumbass.
If at the pompous pretentious gits were burnt, one pompous pretentious git would still remain in the ashes.
Dumbass Really?? What amount of experience you got working on controllers?
And on x51 architecture, if bool is 1byte, i would really want to check for different tool chain. IMO, a bool & bit should occupy same amount of memory.
"IMO, a bool & bit should occupy same amount of memory."
Except for the tiny little fact that the C language doesn't have any 1-bit data type, and the same is true for most microprocessors. The bit field construct is just a grammatical work-around to hide a lot of AND/OR machine code instructions, so while it may save RAM space, it still consumes way more code space than what is needed by a 8051 processor that can actually read and write individual bits.
it still consumes way more code space than what is needed by a 8051 processor i totally agree. either save code at the cost of ram or vice-versa.
but some (over)smart people dont realize the fact that 7bits should not be wasted for what can be done in 1bit.
i have come across situations where people have written code using a lot of ram (unnecessarily) and then have altered a lot of code or written a lot of extra code just to create more space in ram. imho, precaution is better than cure.
IMO, a bool & bit should occupy same amount of memory.
Why?
And on x51 architecture, if bool is 1byte, i would really want to check for different tool chain.
Keil's C51 isn't C99 compliant and doesn't support the bool (_Bool) type anyway.
It does, however, have an extension for the bit type. Careful use of this facility can help produce space and time efficient code.
Just realised the guy's name and the paraphrase. Now it makes sense.
why Well, bool is generally used for storing & checking true/false or 1/0. Logically, for storing only 2 values, 1 binary bit is enough.
Controllers have low on-chip ram memory & hence external memory is interfaced. If an engineer (having only on-chip ram) misuses ram memory (and doesn't know how to reduce ram usage or use it efficiently), then he may either have to modify hardware or modify software after getting stuck up or compromise on the features of the embedded device he is writing the software for. now-a-days the controllers (generally) dont have bit/byte addressible area as in x51.
Well, bool is generally used for storing & checking true/false or 1/0. Logically, for storing only 2 values, 1 binary bit is enough.
An admirable reason. On more than one occasion I have commented a bool in C51 as "true or false or maybe"
It would have been better for you to say at the first that you'd prefer bool and bit to be precisely one bit rather than wanting them both to be the same (unspecified) size. That would have removed any doubt in what you meant.
Lost of embedded programs have quite a limited number of global boolean variables, so the amount of memory consumed by using a byte instead of a bit is often very marginal.
At the same time, lots of embedded programs have quite limited code space, in which case the code size becomes just as critical as RAM space might be.
Often, programs wastes too much RAM by using global variables for something that could have been local variables.
And for lots of processors, a char or maybe even a full int variable can be much quicker to work with than a bit variable because of better matching to the processor instruction set. So boolean variables accessed by interrupts can give a big difference in interrupt latency if stored as a single bit or as a byte - besides the fact that if memory controller or instruction set doesn't have single-bit support then a single bit stored in a word can't be atomically updated resulting in lots of potential timing issues between main loop and interrupt handlers or between different threads.