<?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>shared variable slots</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/14348/shared-variable-slots</link><description> The feature of shared variables in C is a wonderful saver of DATA space. Can the same be implemented in assembler ? 
 
Erik </description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: shared variable slots</title><link>https://community.arm.com/thread/84151?ContentTypeID=1</link><pubDate>Mon, 17 Sep 2001 01:54:36 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d1954fc2-f8e3-400a-b9df-54c501b6a6b0</guid><dc:creator>Sven Petersen</dc:creator><description>&lt;p&gt;Hi Tom!&lt;br /&gt;
&lt;br /&gt;
That&amp;#39;s an excellent idea. Have never seen that before and actually never thought about it, since when I write the programm, I know the purpose I use the registers for anyway and I usually comment my programms a lot.&lt;br /&gt;
&lt;br /&gt;
Your method is much better.&lt;br /&gt;
&lt;br /&gt;
Take care&lt;br /&gt;
  Sven&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: shared variable slots</title><link>https://community.arm.com/thread/53873?ContentTypeID=1</link><pubDate>Fri, 14 Sep 2001 10:38:21 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e022911d-6b27-49ad-add2-a5a11bf98d98</guid><dc:creator>Thomas Mazowiesky</dc:creator><description>&lt;p&gt;One comment that Sven made about using registers as variables.  In Keil, you can equate variable names with registers so that you can, within a local program segment, have meaningful names for variables stored in registers.&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
testvar  equ  R5
testvar2 equ  R6

tp1:
    mov  A,testvar
    mov  B,testvar2
    add  A,B

    ret
&lt;/pre&gt;
&lt;br /&gt;
   This is a nice feature as it makes reading the code more straitforward.&lt;br /&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: shared variable slots</title><link>https://community.arm.com/thread/37866?ContentTypeID=1</link><pubDate>Thu, 13 Sep 2001 02:00:36 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:63be24a4-23ad-4b01-a35b-e7cc7729add0</guid><dc:creator>Sven Petersen</dc:creator><description>&lt;p&gt;Hi Erik!&lt;br /&gt;
&lt;br /&gt;
Well, I think, you just have to use your memoryspace carefully.&lt;br /&gt;
&lt;br /&gt;
What I do is being restrictive with reserving space for global or static variables. I store all the local stuff in registers and the first thing I do in a subroutine is to save all used registers on stack.&lt;br /&gt;
&lt;br /&gt;
This requires commenting the souce code, though, because the variables are just named R0..R7 and don&amp;#39;t have names that describe their purpose.&lt;br /&gt;
&lt;br /&gt;
I also use temporary storage like a place to store the result of 32bit or floating point calculation, but that has to be used very carefully. That means, I cannot be sure that the content of that location in memory will survive a subroutine call.&lt;br /&gt;
&lt;br /&gt;
Sure, a linker will be able to generate a more compact memory usage from C code, but I have done some pretty big projects in just assembler before I had the C compiler and it all worked out well. Programming assembler requires lotsa discipline and commenting. I think, I am faster with C, but will still do a couple of things in assembler.&lt;br /&gt;
&lt;br /&gt;
Take care&lt;br /&gt;
  Sven.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: shared variable slots</title><link>https://community.arm.com/thread/134043?ContentTypeID=1</link><pubDate>Wed, 12 Sep 2001 18:41:30 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d79044c2-cbca-4927-a94a-45e4615b5a63</guid><dc:creator>Andrew Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;I think&lt;/i&gt; that this is not the case:&lt;br /&gt;
the name is simply what the Linker uses to &lt;i&gt;identify&lt;/i&gt; an object; all the other information about the &lt;i&gt;attributes&lt;/i&gt; of the object are conveyed in the Object File format (&lt;i&gt;eg,&lt;/i&gt; whether it&amp;#39;s a Segment or a variable; whether it&amp;#39;s overlayable or not,...)&lt;br /&gt;
&lt;br /&gt;
But I could be wrong; maybe someone from Keil could clarify?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: shared variable slots</title><link>https://community.arm.com/thread/121646?ContentTypeID=1</link><pubDate>Wed, 12 Sep 2001 12:31:18 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:da8d13c9-b7d1-485f-aaad-50dd1a366871</guid><dc:creator>Jon Young</dc:creator><description>&lt;p&gt;I thought, that certain information like a function data segement is associated with a particular function, is passed to the linker by the &amp;quot;Naming Convention&amp;quot;.  I could be wrong.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: shared variable slots</title><link>https://community.arm.com/thread/109869?ContentTypeID=1</link><pubDate>Wed, 12 Sep 2001 03:55:16 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:13fa432f-b891-45c4-9f21-5e14470c9868</guid><dc:creator>Andrew Neil</dc:creator><description>&lt;p&gt;Do you really?&lt;br /&gt;
Surely, it&amp;#39;s the Linker which does the overlaying, and all it cares about is whether the segment has the &amp;#39;Overlayable&amp;#39; attribute or not?&lt;br /&gt;
&lt;br /&gt;
The Linker doesn&amp;#39;t know (or care) about the naming conventions of C51, A51, PL/M, Pascal, or whatever source language you choose to use; the naming conventions are only of interest to you as the programmer if you want to mix these languages?&lt;br /&gt;
&lt;br /&gt;
I&amp;#39;ve not actually tried this on the Keil tools, so I could be totally wrong.&lt;br /&gt;
Again ;-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: shared variable slots</title><link>https://community.arm.com/thread/84152?ContentTypeID=1</link><pubDate>Tue, 11 Sep 2001 15:26:32 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ecf657b7-7669-47b5-a8ad-b8aa3f7a324c</guid><dc:creator>Jon Young</dc:creator><description>&lt;p&gt;You still need to follow the C51 naming conventions exactly to use this.  So first learn the conventions. Then apply then very carfully. Overlap errors are real hard to find. Or, just let the C compiler generate it for you. Being quit dumb, I choose the later.  For the smarter types just do it in assembly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: shared variable slots</title><link>https://community.arm.com/thread/53867?ContentTypeID=1</link><pubDate>Tue, 11 Sep 2001 13:40:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e1867a69-f4b2-46ae-89e3-7ee8e8b8c1e6</guid><dc:creator>Andrew Neil</dc:creator><description>&lt;p&gt;I think you just need to specify your Segments as OVERLAYABLE (where appropriate) and the Linker just does it?&lt;br /&gt;
No need for &amp;#39;C&amp;#39;!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: shared variable slots</title><link>https://community.arm.com/thread/37864?ContentTypeID=1</link><pubDate>Tue, 11 Sep 2001 12:08:20 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1e692c05-5c20-44bb-99c0-390374ccf7ea</guid><dc:creator>Jon Young</dc:creator><description>&lt;p&gt;Here is an idea. Take your assembly routines and write the headers in C.  Include parameter and local variables, but nothing else. Then have the compiler emit assembly code for this framework.  Now merge in the left out assembly code, and your done.  The linker will then overlay variables just like C objects.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: shared variable slots</title><link>https://community.arm.com/thread/37865?ContentTypeID=1</link><pubDate>Tue, 11 Sep 2001 09:03:15 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1597d444-959e-4c43-ac0f-c20b4996c299</guid><dc:creator>Andrew Neil</dc:creator><description>&lt;p&gt;I presume you&amp;#39;re talking about Overlaying?&lt;br /&gt;
&lt;br /&gt;
You  can specify OVERLAYABLE as a Segment Relocation Type - see Chapter 4, &lt;i&gt;Assembler Directives,&lt;/i&gt; in the manual&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>