Dear all, I want to access some continus bit,let me can modify the value,such as, for(i = 0 ; i < 10 ; i++) { bit[i] = ?; } but you know,the bit var cann't build as a array in keil c51,but build some boolean var with byte will speed down the MCU and more code,Who can give me a good advice and a way,Thanks in advance.
you could try copying your byte into a bit-addressable temporary variable? you'd have to examine for yourself whether that's advantageous in your particular application.
Thanks every one in this message which give it a glance. But the way on above all is convert the bit array to a byte array,You compile the code will generate the asm code,all op code will be translated to byte operating mode,but you know,if we had build a array,and the member in the array is bit addressable var,some jump op will be translated as ,jb or jbc or jz and so on,this way will run more quickly and few code space,I had found no way to do this work,and I thinks embeding a piece asm code will be one way to resolve it. Waiting your good advice.
Paddy, your explanation is not at all clear, but it appears that you want the 8051 to do something which it just cannot. There is no "bit pointer" functionality in the 8051 design. If you want to access an array, then the assembler code has no choice but to use byte operations to access the required bit.
Paddy, your idea is fine, in principle, but unfortunately doesn't correspond to the reality of the 8051 processor family. You seem to be assuming that Keil wilfully withheld a useful feature of the CPU from being used by your C code. But they didn't --- it at all, it's IBM who did that, back when they designed the original 8051. There simply is no opcode in the 8051 machine language to indirectly access a bit, i.e. you can't compute the address of any bit and use the result of that computation to access it. This almost completely rules out array-of-bit as a C datatype. It still could be done, but only by use of methods that are practically guranteed to be even less efficient than the shift+mask technique which you so much would like to avoid. E.g. you could use self-modifying code, or a jump table to select one of a lot of hardwired "read bit #i" functions.
"IBM ... designed the original 8051" Eh??????????????????????????????????????????
OK, alright, so you caught me. 'Twas Intel, not IBM, of course.
View all questions in Keil forum