Search code examples
embeddedmicrocontrollercpu-architecture8051

What is the main difference between byte addressable and bit addressable?


I'm learning 8051, and find it's hard to understand byte addressable and bit addressable.

a addressable SPF


Solution

  • They are not really using the terms right, byte addressable is what we are used to an address represents a unique byte in memory or the memory space. Bit addressable would mean that each bit in the memory space has a unique address, which is not the case. they are just showing you how to make some macros/variables that can access individual bits, is not an 8051 thing, but a generic programming thing and specifically implemented in C using variable types or keywords (or just macros) for their compiler.

    What they are telling you is they have this sbit declaration which unless it is just a macro is clearly not a C standard declaration. But you can do the same things without. it is just bit manipulation that they are doing for you. Normally to set bit 5 you would do something like

    variable |= (1<<5);  
    

    to clear bit 5

    variable&=~(1<<5);
    

    and you can certainly make macros from that to make it more generic. What they have done for this compiler is allow you to declare a variable that is a single bit in some other variable and then that bit sized variable you can set to a one or zero.