can same memory space use two diff variables ?

Dear Sir,

I m in beginning phase of 8051 with C. i have compiled my c file and i found in .m51 file that one of the SFR and a user defined variable share the same memory space(0080H) .How it's possible.Could you pls explain me.
.M51 lists ....

------- MODULE func1

D:0080H PUBLIC PORT0
I:0080H PUBLIC variabl1

Kindly help with reference to above.

regards,
Arup

Parents
  • How it's possible.Could you pls explain me.

    If you want the long, detailed explanation, you will need to refer to document describing the 8051 architecture, especially the memory architecture:

    Chapter 1 - 80C51 Family Architecture:
    www.nxp.com/.../80C51_FAM_ARCH_1.pdf

    The short explanation is that the variables simply do not share the same memory space. Let's look at the listing file again:

    D:0080H PUBLIC PORT0
    I:0080H PUBLIC variabl1
    

    Do you see the memory type specifier ("D:", "I:") in front of the address ? It indicates that the first variable is in directly addressable data memory, and the second variable is in indirectly addressable data memory. The 8051 uses different instructions to access data in directly and indirectly addressable memory, and above address 0x7F this distinction will actually access different memory areas (direct accesses will access the Special Function Registers, while indirect accesses will access internal RAM if available). An instruction that accesses data memory directly at address 0x80 will actually access PORT0, while an instruction that indirectly accesses data memory at address 0x80 will access the byte of internal RAM at this address.

    Read the document linked above for the detailed explanation.

Reply Children
More questions in this forum