<?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>How to propagate a value from C to a SPACE directive with armasm</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/38845/how-to-propagate-a-value-from-c-to-a-space-directive-with-armasm</link><description> 
Hi all, 

 
I would like to ask help to some expert in armasm. 

 
In my startup.s file I have the following code which reserves
0x400 bytes of RAM to the stack. 

 
; this is the original startup.s file
Stack_Size EQU 0x00000400

 AREA STACK, NOINIT</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: How to propagate a value from C to a SPACE directive with armasm</title><link>https://community.arm.com/thread/142633?ContentTypeID=1</link><pubDate>Fri, 27 Aug 2010 03:21:48 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:066a64ed-e691-4550-ac93-a491c61784ef</guid><dc:creator>Tamir Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
Marcus,&lt;/p&gt;

&lt;p&gt;
Thanks for your reply. I&amp;#39;m using MDK-4.11 - I would have thought
it is supposed to be solved in it...?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to propagate a value from C to a SPACE directive with armasm</title><link>https://community.arm.com/thread/139594?ContentTypeID=1</link><pubDate>Fri, 27 Aug 2010 03:03:59 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ca877f95-c519-4d92-84e1-a58c90daf4c5</guid><dc:creator>Marcus Harnisch</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;gt; Any thoughts...?&lt;/p&gt;

&lt;p&gt;
Of course. You are suffering from an issue with armld that I
reported in 2008 (case #394129) and has been fixed a short while
after that.&lt;/p&gt;

&lt;p&gt;
The behavior you seem to be experiencing started in RVCT 3.1 Build
700. The include paths are relative to the temporary directory!&lt;/p&gt;

&lt;p&gt;
Although initially not acknowledged (to me anyway) as bug, ARM
reverted the change and returned to the proper behavior a few
releases later.&lt;/p&gt;

&lt;p&gt;
--&lt;br /&gt;
Marcus&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to propagate a value from C to a SPACE directive with armasm</title><link>https://community.arm.com/thread/136168?ContentTypeID=1</link><pubDate>Fri, 27 Aug 2010 00:52:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:12bac015-4454-41cc-9ee0-19291610f69e</guid><dc:creator>Tamir Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hello Marcus,&lt;/p&gt;

&lt;p&gt;
I haven&amp;#39;t given up yet, and now when I have a little bit of I am
determined to get this thing to work (having the preprocessor parse
my scatter file). I am trying this:&lt;/p&gt;

&lt;pre&gt;
#! armcc -E

#include &amp;quot;boot_firmware.h&amp;quot;
&lt;/pre&gt;

&lt;p&gt;
in order to include a definition that the scatter file needs. But
then the preprocessor reports&lt;/p&gt;

&lt;pre&gt;
C:\DOCUME~1\tm\LOCALS~1\Temp\p14c8-2(2): error:  #5: cannot open source input file &amp;quot;boot_firmware.h&amp;quot;: No such file or directory
&lt;/pre&gt;

&lt;p&gt;
using the -I directive does not seem to help. How do I tell the
preprocessor where to look for the file? The compiler settings
already use -I option to get to the relative path
&amp;quot;..\..\Bootloaders\src&amp;quot;, but if that one is used in the scatter file
itself, I get this error message:&lt;/p&gt;

&lt;pre&gt;
C:\DOCUME~1\tm\LOCALS~1\Temp\p200-3(103): error: L6226E: Missing base address for region typedef.
C:\DOCUME~1\tm\LOCALS~1\Temp\p200-3(103): error: L6292E: Ignoring unknown attribute &amp;#39;enum&amp;#39; specified for region typedef.
C:\DOCUME~1\tm\LOCALS~1\Temp\p200-3(105): error: L6226E: Missing base address for region e_target_internal_flash.
C:\DOCUME~1\tm\LOCALS~1\Temp\p200-3(105): error: L6292E: Ignoring unknown attribute &amp;#39;=&amp;#39; specified for region e_target_internal_flash.
C:\DOCUME~1\tm\LOCALS~1\Temp\p200-3(105): error: L6228E: Expected &amp;#39;{&amp;#39;, found &amp;#39;,...&amp;#39;.
C:\DOCUME~1\tm\LOCALS~1\Temp\p200-3(105): error: L6228E: Expected &amp;#39;}&amp;#39;, found &amp;#39;EOF&amp;#39;.
&lt;/pre&gt;

&lt;p&gt;
Any thoughts...?&lt;/p&gt;

&lt;p&gt;
Thanks in advance!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to propagate a value from C to a SPACE directive with armasm</title><link>https://community.arm.com/thread/126211?ContentTypeID=1</link><pubDate>Fri, 11 Jun 2010 04:47:44 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c6f0b25b-29b0-405e-b1aa-759e94e2057e</guid><dc:creator>Marcus Harnisch</dc:creator><description>&lt;p&gt;&lt;p&gt;
Just a quick remark: The Forum seems to have swallowed some Dollar
signs. Every &amp;#39;$&amp;#39; in my post should be a double dollar.&lt;/p&gt;

&lt;p&gt;
--&lt;br /&gt;
Marcus&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to propagate a value from C to a SPACE directive with armasm</title><link>https://community.arm.com/thread/115806?ContentTypeID=1</link><pubDate>Fri, 11 Jun 2010 03:01:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:bbf3a9f1-5c4d-43f4-a1f3-df91bf0eaf7d</guid><dc:creator>Marco Accame</dc:creator><description>&lt;p&gt;&lt;p&gt;
The former solution is better, but I think I will test also this
latter.&lt;/p&gt;

&lt;p&gt;
I have implemented a hal (hardware abstraction library) for the
cm3, which is usable with a hal.h, hal.lib, hal_startup.s and a
hal_cfg.h.&lt;/p&gt;

&lt;p&gt;
My aim was to have a single configuration point, the hal_cfg.h,
for everything and thus also for stack and heap size without having
to touch the startup file by hand.&lt;/p&gt;

&lt;p&gt;
The use of the preprocessor w/ the assembler works for that.&lt;/p&gt;

&lt;p&gt;
However, in runtime I also make a check of effective heap and
stack sizes. Now I am using a method which I already posted in the
thread with the __asm functions, but your latest suggestion seems
better.&lt;/p&gt;

&lt;p&gt;
Thanks again to you and to every member of the forum. It is a
great place where to share knowledge!&lt;/p&gt;

&lt;p&gt;
Hi, Marco.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to propagate a value from C to a SPACE directive with armasm</title><link>https://community.arm.com/thread/104012?ContentTypeID=1</link><pubDate>Fri, 11 Jun 2010 02:26:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a998a4d2-5173-427d-98a2-70895b3bd922</guid><dc:creator>Marcus Harnisch</dc:creator><description>&lt;p&gt;&lt;p&gt;
You are welcome. Alternatively, you could &lt;i&gt;import&lt;/i&gt; the stack
size information generated by the linker into C. This is a perhaps
little less of a hack, but that depends on the perspective of course
;-)&lt;/p&gt;

&lt;pre&gt;
extern unsigned int Image$$STACK$ZI$$Length;
const int Stack_Size = (int)&amp;amp;Image$$STACK$ZI$$Length;
&lt;/pre&gt;

&lt;p&gt;
(untested)&lt;/p&gt;

&lt;p&gt;
--&lt;br /&gt;
Marcus&lt;br /&gt;
&lt;a href="http://www.doulos.com/arm/"&gt;http://www.doulos.com/arm/&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to propagate a value from C to a SPACE directive with armasm</title><link>https://community.arm.com/thread/115799?ContentTypeID=1</link><pubDate>Thu, 10 Jun 2010 03:26:31 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:940b0413-67f4-4643-ad44-25060c009152</guid><dc:creator>Tamir Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thanks for this link. I have seen it already (obviously I checked
the linker and utilities guide) but as far as I recall I did not
manage to build, even. I will try this again. Thanks again.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to propagate a value from C to a SPACE directive with armasm</title><link>https://community.arm.com/thread/104015?ContentTypeID=1</link><pubDate>Thu, 10 Jun 2010 03:15:11 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5110a222-8c6e-40d9-a10d-ec0fe4146c9f</guid><dc:creator>Non Keil Related</dc:creator><description>&lt;p&gt;&lt;p&gt;
Tamir,&lt;/p&gt;

&lt;p&gt;
Is this what you&amp;#39;re after?&lt;/p&gt;

&lt;p&gt;

&lt;a href="http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0474a/Chdiehag.html"&gt;infocenter.arm.com/.../index.jsp&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to propagate a value from C to a SPACE directive with armasm</title><link>https://community.arm.com/thread/78390?ContentTypeID=1</link><pubDate>Wed, 09 Jun 2010 08:43:10 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:31f3a9fe-3a34-4d0e-806d-84182098790d</guid><dc:creator>Marco Accame</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thanks Marcus,&lt;/p&gt;

&lt;p&gt;
it works and solves my problem.&lt;/p&gt;

&lt;p&gt;
regards, marco.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to propagate a value from C to a SPACE directive with armasm</title><link>https://community.arm.com/thread/90449?ContentTypeID=1</link><pubDate>Wed, 09 Jun 2010 08:38:54 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:32d5a27b-e465-44db-b428-f80fa768f229</guid><dc:creator>Tamir Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
Marcus,&lt;/p&gt;

&lt;p&gt;
I&amp;#39;m sorry for asking in this thread, but do you know a similar
trick for a scatter file? How can I run the preprocessor on a scatter
file?&lt;/p&gt;

&lt;p&gt;
Thanks&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to propagate a value from C to a SPACE directive with armasm</title><link>https://community.arm.com/thread/58282?ContentTypeID=1</link><pubDate>Wed, 09 Jun 2010 08:27:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c0cc6ed1-6a3e-447e-966c-be1fc7164391</guid><dc:creator>Marcus Harnisch</dc:creator><description>&lt;p&gt;&lt;p&gt;
Please have a look at this&lt;br /&gt;

&lt;a href="http://infocenter.arm.com/help/topic/com.arm.doc.kui0100a/armasm_chdhcfgd.htm"&gt;infocenter.arm.com/.../armasm_chdhcfgd.htm&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
--&lt;br /&gt;
Marcus&lt;br /&gt;
&lt;a href="http://www.doulos.com/arm/"&gt;http://www.doulos.com/arm/&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to propagate a value from C to a SPACE directive with armasm</title><link>https://community.arm.com/thread/78391?ContentTypeID=1</link><pubDate>Wed, 09 Jun 2010 08:26:36 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0504b9b9-afc4-4172-91e6-68507b8f1243</guid><dc:creator>Marco Accame</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi,&lt;/p&gt;

&lt;p&gt;
I already do that. However, it is not just enough to use an extern
variable called Stack_Size, but you need to use some more code:&lt;/p&gt;

&lt;pre&gt;
// this is startup.s
Stack_Size      EQU     0x00000400
               EXPORT  Stack_Size

                AREA    STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem       SPACE   Stack_Size
__initial_sp
&lt;/pre&gt;
&lt;pre&gt;
// this is myfile.c
__asm int getstacksize (void) {
        IMPORT  Stack_Size
        LDR     R0,=Stack_Size
        BX      LR
}
&lt;/pre&gt;

&lt;p&gt;
However, it is not what I want to do.&lt;/p&gt;

&lt;p&gt;
My aim is to hide the startup.s and use just .h and .c files for
configuration.&lt;/p&gt;

&lt;p&gt;
Thank anyway, marco.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to propagate a value from C to a SPACE directive with armasm</title><link>https://community.arm.com/thread/58281?ContentTypeID=1</link><pubDate>Wed, 09 Jun 2010 08:10:27 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ac73a9ba-a928-4368-b8ad-5b49a9192e35</guid><dc:creator>Non Keil Related</dc:creator><description>&lt;p&gt;&lt;p&gt;
You could consider the opposite; i.e., have the define and
variable in the startup, export that and then have an extern in your
C.&lt;/p&gt;

&lt;p&gt;
This way is quite straightforward.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>