<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>can same memory space use two diff variables ?</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/37388/can-same-memory-space-use-two-diff-variables</link><description> 
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&amp;#39;s possible.Could
you pls explain me. 
.M51 lists ....</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: can same memory space use two diff variables ?</title><link>https://community.arm.com/thread/149258?ContentTypeID=1</link><pubDate>Thu, 16 Aug 2007 06:00:47 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a4da7e05-ecdf-40a3-a32a-5b66bdbe9d27</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot; no SFR &amp;#39;occupies x no of bytes&amp;#39;, they all &amp;#39;occupy&amp;#39;
ONE.&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
The so-called &amp;quot;bible&amp;quot; refers to the (TH0+TL0) and (TH1+TL1) pairs
as &amp;quot;16-bit registers&amp;quot;&lt;/p&gt;

&lt;p&gt;
DPTR is also a 16-bit register (thought also accessible as DPH and
DPL)&lt;/p&gt;

&lt;p&gt;
There maybe others specific to particular derivatives?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: can same memory space use two diff variables ?</title><link>https://community.arm.com/thread/149260?ContentTypeID=1</link><pubDate>Thu, 16 Aug 2007 05:54:08 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6336599c-ce34-405b-bf73-58a9561b90da</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;there is no such thing as &lt;b&gt;my&lt;/b&gt; SFR&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
True for a standard chip, but (possibly) not if you&amp;#39;re using a
softcore, or something like the old Triscend...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: can same memory space use two diff variables ?</title><link>https://community.arm.com/thread/135105?ContentTypeID=1</link><pubDate>Thu, 16 Aug 2007 05:48:52 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8e61e7d3-c4d4-4abb-b6dd-7a7d046af9ba</guid><dc:creator>Christoph Franck</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;what i understand is above 007F in internal data memory if my
SFR occupies x no of bytes of memory ,then same memory
location(numerical) i can use for user defined variables in different
addr space i.e IDATA&lt;/i&gt;&amp;lt;p&amp;gt;&lt;/p&gt;

&lt;p&gt;
The SFR area contains 128 bytes. What SFRs these 128 bytes
contain, and at which address, mostly depends on the type of chip you
are using. The chip documentation will provide this information.&lt;/p&gt;

&lt;p&gt;
Whether your chip also has 128 of (indirectly addressable) RAM
starting at address 0x80 also depends on what chip you are working
with. Information about this will also be in the chips
documentation.&lt;/p&gt;

&lt;p&gt;
If your chip has the 128 bytes of RAM at address 0x80, then they
will be usable as part of the IDATA space.&lt;/p&gt;

&lt;p&gt;
(IDATA refers to all internal RAM that is indirectly addressable,
which means that it ranges from 0x00 to 0xFF. Be aware that the low
addresses also contain the register space and the bit-adressable
area.&lt;/p&gt;

&lt;p&gt;
DATA refers to directly addressable internal RAM, which means 0x00
to 0x7F).&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: can same memory space use two diff variables ?</title><link>https://community.arm.com/thread/135098?ContentTypeID=1</link><pubDate>Thu, 16 Aug 2007 05:40:15 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8f7cb51e-f4e1-434d-bd1d-2e5436c5e646</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;what i understand is above 007F in internal data memory if my
SFR occupies x no of bytes of memory ,then same memory
location(numerical) i can use for user defined variables in different
addr space i.e IDATA&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
DO read &amp;#39;the bible&amp;#39;&lt;/p&gt;

&lt;p&gt;
while your statement abobe is basically correct there is no such
thing as &lt;b&gt;my&lt;/b&gt; SFR and no SFR &amp;quot;occupies x no of bytes&amp;quot;, they all
&amp;#39;occupy&amp;#39; ONE.&lt;/p&gt;

&lt;p&gt;
I do appreciate, that your expressions may be due to &amp;#39;language&amp;#39;,
but if you had (as you MUST) studied &amp;#39;the bible&amp;#39; I am sure that the
language woul have been clearer.&lt;/p&gt;

&lt;p&gt;
Erik&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: can same memory space use two diff variables ?</title><link>https://community.arm.com/thread/124019?ContentTypeID=1</link><pubDate>Thu, 16 Aug 2007 05:33:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9473c365-acbb-4d5c-aab0-d853ea8a2dd5</guid><dc:creator>dcd dcd</dc:creator><description>&lt;p&gt;&lt;p&gt;
dear sir,&lt;br /&gt;
what i understand is above 007F in internal data memory if my SFR
occupies x no of bytes of memory ,then same memory
location(numerical) i can use for user defined variables in different
addr space i.e IDATA&lt;/p&gt;

&lt;p&gt;
correct me if wrong.&lt;/p&gt;

&lt;p&gt;
thanks,&lt;br /&gt;
Arup&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: can same memory space use two diff variables ?</title><link>https://community.arm.com/thread/113118?ContentTypeID=1</link><pubDate>Thu, 16 Aug 2007 04:40:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9e3564b4-bdd5-45a5-a6d4-86055396b66b</guid><dc:creator>dcd dcd</dc:creator><description>&lt;p&gt;&lt;p&gt;
I understood. Thanks to everybody for the quick help.&lt;/p&gt;

&lt;p&gt;
regards&lt;/p&gt;

&lt;p&gt;
Arup&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: can same memory space use two diff variables ?</title><link>https://community.arm.com/thread/99524?ContentTypeID=1</link><pubDate>Thu, 16 Aug 2007 04:08:26 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1c16225e-4a27-4a11-a23c-a94971336270</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
Yes, it is possible for two variables to have the same address -
even in the same Address Space!&lt;/p&gt;

&lt;p&gt;
This is a result of the &lt;b&gt;Overlaying&lt;/b&gt; scheme used by the Keil
C51 compiler for &lt;i&gt;&lt;b&gt;Automatic&lt;/b&gt;&lt;/i&gt; variables (ie, non-static
local variables).&lt;/p&gt;

&lt;p&gt;
But that&amp;#39;s not what you&amp;#39;re seeing here.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: can same memory space use two diff variables ?</title><link>https://community.arm.com/thread/88469?ContentTypeID=1</link><pubDate>Thu, 16 Aug 2007 04:05:04 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1b931a7d-92d9-4e3e-9831-d89fbc0e9373</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
See also: &lt;a href="http://www.keil.com/forum/docs/thread10400.asp"&gt;http://www.keil.com/forum/docs/thread10400.asp&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: can same memory space use two diff variables ?</title><link>https://community.arm.com/thread/51036?ContentTypeID=1</link><pubDate>Thu, 16 Aug 2007 03:58:52 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d19322f0-f06e-4cc7-9cce-a8f56c8364bb</guid><dc:creator>Christoph Franck</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;How it&amp;#39;s possible.Could you pls explain me.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
If you want the long, detailed explanation, you will need to refer
to document describing the 8051 architecture, especially the memory
architecture:&lt;/p&gt;

&lt;p&gt;
Chapter 1 - 80C51 Family Architecture:&lt;br /&gt;
&lt;a href="http://www.nxp.com/acrobat_download/various/80C51_FAM_ARCH_1.pdf"&gt;www.nxp.com/.../80C51_FAM_ARCH_1.pdf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
The short explanation is that the variables simply &lt;b&gt;do not&lt;/b&gt;
share the same memory space. Let&amp;#39;s look at the listing file
again:&lt;/p&gt;

&lt;pre&gt;
D:0080H PUBLIC PORT0
I:0080H PUBLIC variabl1
&lt;/pre&gt;

&lt;p&gt;
Do you see the memory type specifier (&amp;quot;D:&amp;quot;, &amp;quot;I:&amp;quot;) in front of the
address ? It indicates that the first variable is in &lt;b&gt;directly&lt;/b&gt;
addressable data memory, and the second variable is in
&lt;b&gt;indirectly&lt;/b&gt; 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.&lt;/p&gt;

&lt;p&gt;
Read the document linked above for the detailed explanation.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: can same memory space use two diff variables ?</title><link>https://community.arm.com/thread/48442?ContentTypeID=1</link><pubDate>Thu, 16 Aug 2007 03:54:31 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:304df29b-121c-408f-8de9-89234caf8b0a</guid><dc:creator>Arthur Plank</dc:creator><description>&lt;p&gt;&lt;p&gt;
Although they might look as if they&amp;#39;re in the same location, they
are not.&lt;/p&gt;

&lt;p&gt;
Each one is in a different &amp;#39;address space&amp;#39; and just happen to have
the same offset.&lt;/p&gt;

&lt;p&gt;
I suggest you look at the bible for details:&lt;/p&gt;

&lt;p&gt;
Chapter 1 - 80C51 Family Architecture:&lt;br /&gt;
&lt;a href="http://www.nxp.com/acrobat_download/various/80C51_FAM_ARCH_1.pdf"&gt;www.nxp.com/.../80C51_FAM_ARCH_1.pdf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
Chapter 2 - 80C51 Family Programmer&amp;#39;s Guide and Instruction
Set:&lt;br /&gt;

&lt;a href="http://www.nxp.com/acrobat_download/various/80C51_FAM_PROG_GUIDE_1.pdf"&gt;www.nxp.com/.../80C51_FAM_PROG_GUIDE_1.pdf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
Chapter 3 - 80C51 Family Hardware Description:&lt;br /&gt;

&lt;a href="http://www.nxp.com/acrobat_download/various/80C51_FAM_HARDWARE_1.pdf"&gt;www.nxp.com/.../80C51_FAM_HARDWARE_1.pdf&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>