| ??? 12/08/03 12:06 Read: times |
#60137 - RE: Bit Memory Responding to: ???'s previous message |
Its not really confusing actually.
The point is, the certain internal memory locations that can be accessed as byte locations can also be accessed by bitwise instructions. Since there are 8 bits in a byte, so evey location contains 8 bits, that MCS-51 docs call the bit-addreseable area that begins at location 20h. Thus, 16 bytes starting from 20h can be accessed as 128 unique bit locations, you can use these for flags or boolean type variable as in a higher level language. Theres more. Upper 128 bits that can be accessed with a 8 bit address are mapped in what they call bit addreseable SFRs. One can get the exact byte memory by the following routine: if (bit_addr & 80h) { // upper 128 bits, those are in SFRs byte_addr = bit_addr & 0F8h; } else { // lower 128 bits, in the bit addreseable area 20-3Fh byte_addr = (bit_addr >> 3) + 20h } bit_pos = bit_addr & 7; // This is the byte location bit_pos = 1 << bit_pos; // This is the bit mask Since there is no indirect addressing of bit memory, you can use this routine to calculate the address of the byte that contains the bit, and a mask that has a 1 in the position of the desired bit. To set the bit, you simple OR the bit mask (bit_pos) with the byte at (byte_addr) To clear the bit, you AND the complement of the bit (you dont want to disturb other bits) with the byte at (byte_addr) Hope this helps Girish |
| Topic | Author | Date |
| Bit Memory | 01/01/70 00:00 | |
| RE: Bit Memory | 01/01/70 00:00 | |
| RE: Bit Memory | 01/01/70 00:00 | |
| RE:I\\\'m confused | 01/01/70 00:00 | |
| RE: clearing the confoosion | 01/01/70 00:00 | |
| RE: I'm confused | 01/01/70 00:00 | |
| RE: Bit Memory | 01/01/70 00:00 | |
| RE: Bit Memory | 01/01/70 00:00 | |
RE: Bit Memory | 01/01/70 00:00 |



