??? 07/25/11 18:15 Read: times |
#183042 - bit != bool even if nominal storage range is same Responding to: ???'s previous message |
Yes, I also see a very specific distinction between a bit variable (a specific storage size) and a boolean variable (a logic variable).
While they are intended to store the same amount of information, a boolean variable may consume much more memory space. While a "bool" data type may not be space-efficient, it is normally very code-efficient and speed-efficient since it allows single reads or writes to be performed. True bit variables results in lots of problems for a hardware that does not have some form of support (instruction set or memory controller mappings) since they both inflates the code size (a single read will become a read + a masking, while a single write will become a read, optional masking, optional or, and a write) and produces severe atomicity issues. How fun would it be to get an interrupt between the read and the modify or between the modify and the write stages? In the end, no sane compiler implements single-bit variables unless they can be operated on atomically, with one processor instruction to set, one to clear and one to test. Even if the processor have special lock primitives to lock the n following instructions into one atomic block, that normally costs just too much execution time and code space. |
Topic | Author | Date |
Bit variable in KEIL Arm | 01/01/70 00:00 | |
Hw bit variables normally not available in processors | 01/01/70 00:00 | |
Not quite true. | 01/01/70 00:00 | |
He covered that | 01/01/70 00:00 | |
Choice of forum | 01/01/70 00:00 | |
bool | 01/01/70 00:00 | |
bool is nothing specifically to do with single-bit variables | 01/01/70 00:00 | |
Not wrong | 01/01/70 00:00 | |
Yes - wrong! | 01/01/70 00:00 | |
bit != bool even if nominal storage range is same | 01/01/70 00:00 | |
Bit Fields | 01/01/70 00:00 | |
Wrong answer for this question | 01/01/70 00:00 |