<?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>Address of an element of a struct</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/23323/address-of-an-element-of-a-struct</link><description> 
I have this code: 

 
typedef struct _DLL_struct
 {
 unsigned char DLL_type;
 unsigned char DLL_lenght;
 unsigned char DLL_data_begin;
 } DLL_struct;

unsigned char xdata FskRxBuf[MAX_SIZE_BUFFER];


void main(void)
 {
 DLL_struct *DLL_ptr; // pointer</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Address of an element of a struct</title><link>https://community.arm.com/thread/138764?ContentTypeID=1</link><pubDate>Tue, 06 May 2008 05:44:48 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:73b58905-f738-4eab-9a80-624ae2f5758c</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;That said, I don&amp;#39;t think that something has to be difficult to
be good.&lt;/i&gt;&lt;br /&gt;
Agreed, KISS is the best way. However, how much do you learn from
something easy?&lt;br /&gt;
&lt;i&gt;The 8051 memory management isn&amp;#39;t the smartest way I can imagine to
handle memory.&lt;/i&gt;&lt;br /&gt;
Smart?, maybe not, but darn efficient &lt;i&gt;when the &amp;#39;51 is used for the
applications it is intendede for&lt;/i&gt;&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: Address of an element of a struct</title><link>https://community.arm.com/thread/100606?ContentTypeID=1</link><pubDate>Tue, 06 May 2008 03:41:51 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5e161668-ce80-4d86-b486-999f985466d4</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
emme effe (a newcomer to the 8051) said, &lt;i&gt;&amp;quot;I hate, I really hate
this micro...&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Shivaram Cunchala (a newcomer to ARM from the 8051) said, &lt;i&gt;&amp;quot;I
just want to know if ARM is &lt;b&gt;user friendly like our
8051&lt;/b&gt;&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;;-)&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
Any new thing will always seem a bit bewildering until you get
used to it!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Address of an element of a struct</title><link>https://community.arm.com/thread/138762?ContentTypeID=1</link><pubDate>Tue, 06 May 2008 00:52:07 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f61f1e68-ed43-4dc6-b4b9-efd74e2b261a</guid><dc:creator>Christoph Franck</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;The 8051 memory management isn&amp;#39;t the smartest way I can imagine
to handle memory.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Back in the time when the architecture was invented, the memory
architecture was pretty smart for the intended purposes and the
expected price range of the chip.&lt;/p&gt;

&lt;p&gt;
Today, when throwing lots of transistors at a problem is cheap and
acceptable, there are more convenient ways to deal with memory. Back
then, that wasn&amp;#39;t the case.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Address of an element of a struct</title><link>https://community.arm.com/thread/141992?ContentTypeID=1</link><pubDate>Tue, 06 May 2008 00:25:48 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:7740e0aa-c266-41f3-9252-05a961fe4015</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Two reasons for the memory layout:&lt;br /&gt;
- Minimal transistor count.&lt;br /&gt;
- Small instructions.&lt;/p&gt;

&lt;p&gt;
For an 8-bit processor without real 16-bit registers, a full
16-bit address is no fun at all. Intel wanted as large part of the
application as possible to use 8-bit addresses. Remember that the
original C51 did not have any processor cache to handle the extra
ticks required to access one or more extra bytes of instruction data
from a very, very slow memory.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Address of an element of a struct</title><link>https://community.arm.com/thread/138760?ContentTypeID=1</link><pubDate>Tue, 06 May 2008 00:16:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:71d1efd3-ffa0-47b0-93b0-33a066ea9fdd</guid><dc:creator>Catcus Blip</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;quot;we love you, emme!&amp;quot;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Address of an element of a struct</title><link>https://community.arm.com/thread/130310?ContentTypeID=1</link><pubDate>Tue, 06 May 2008 00:12:05 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3e68d93a-43c7-4f88-a747-3a11e3e55ac6</guid><dc:creator>emme effe</dc:creator><description>&lt;p&gt;&lt;p&gt;
I forgot a smiley in my previous statement.&lt;br /&gt;
That said, I don&amp;#39;t think that something has to be difficult to be
good.&lt;br /&gt;
The 8051 memory management isn&amp;#39;t the smartest way I can imagine to
handle memory.&lt;br /&gt;
But I have to admit I&amp;#39;m not so into this micro to understand what
could be the idea behind that.&lt;br /&gt;
Just don&amp;#39;t hate me for that, please.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Address of an element of a struct</title><link>https://community.arm.com/thread/124638?ContentTypeID=1</link><pubDate>Mon, 05 May 2008 13:35:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:36ad0715-3619-47ba-97af-444a02469840</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;&lt;p&gt;
nothing emotional, just that hating something because it is not
easy will never get you anywhere.&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: Address of an element of a struct</title><link>https://community.arm.com/thread/113895?ContentTypeID=1</link><pubDate>Mon, 05 May 2008 11:27:50 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a47dc456-4549-4fde-b090-bb7e2b242dfd</guid><dc:creator>Catcus Blip</dc:creator><description>&lt;p&gt;&lt;p&gt;
are we getting emotional, erik :)&lt;br /&gt;
effe is simply expressing frustration that he needs to learn so much
and that the material less than evident. he will fall in love with
the 51 soon, I&amp;#39;m sure...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Address of an element of a struct</title><link>https://community.arm.com/thread/100604?ContentTypeID=1</link><pubDate>Mon, 05 May 2008 10:33:31 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2167bcd6-4ecd-41ec-9c64-7178aca31cf9</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;I hate, I really hate this micro...&lt;/i&gt;&lt;br /&gt;
what you are relly saying is: &amp;quot;I hate, I really hate having to
think...&amp;quot;&lt;/p&gt;

&lt;p&gt;
Erik&lt;/p&gt;

&lt;p&gt;
The &amp;#39;51 with all its quirks is, for many applications, the best
processor you can choose. Now, the contrary, choosing the &amp;#39;51 for the
wrong application is, of course, just as wrong.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Address of an element of a struct</title><link>https://community.arm.com/thread/76259?ContentTypeID=1</link><pubDate>Mon, 05 May 2008 09:09:42 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:15634840-3398-402f-b203-0b2845e54b8e</guid><dc:creator>emme effe</dc:creator><description>&lt;p&gt;&lt;p&gt;
Yep, I know about alignement, I had a lot of experience on that
issue in the past, but thanks to nominate it.&lt;/p&gt;

&lt;p&gt;
About the real problem: you&amp;#39;re right, I don&amp;#39;t mention xdata on the
pointer definition, &amp;#39;cause I hadn&amp;#39;t read the &lt;i&gt;generic and memory
specific pointer&lt;/i&gt; section yet!&lt;br /&gt;
I hate, I really hate this micro...&lt;/p&gt;

&lt;p&gt;
For the record: I changed the pointer definition into:&lt;/p&gt;

&lt;pre&gt;
DLL_struct xdata * data DLL_ptr;   // pointer (in data) to cast on the buffer (in xdata)
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
and all works fine.&lt;/p&gt;

&lt;p&gt;
Except the fact that my debugger continues to show me the
expression&lt;/p&gt;

&lt;pre&gt;
&amp;amp;DLL_ptr-&amp;gt;DLL_data_begin = 0x92
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
but I bet it&amp;#39;s a flaw of the debugger (unfortunately it wouldn&amp;#39;t be
the first one...)&lt;/p&gt;

&lt;p&gt;
Thanks a lot for your help.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Address of an element of a struct</title><link>https://community.arm.com/thread/51735?ContentTypeID=1</link><pubDate>Mon, 05 May 2008 08:38:50 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a78dc744-aaad-4acc-ad1e-33bcad78e03a</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
I should probably not answer this, since I don&amp;#39;t work with the C51
compiler.&lt;/p&gt;

&lt;p&gt;
However, an interesting thing is that FskRxBuf resides in xdata,
but you typecast to a pointer type that does not mention xdata.&lt;/p&gt;

&lt;p&gt;
Another thing to think about - even if it doesn&amp;#39;t affect the C51 -
is that typecasting between a raw buffer and a struct can break
alignment requirements.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>