<?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>C runtime environment setup by &amp;quot;#pragma asm&amp;quot;</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/39330/c-runtime-environment-setup-by-pragma-asm</link><description> 
I am checking some terrible C source code; I haven&amp;#39;t got any idea
about how to maintain it or cooperate with it. But I found a very
fundamental problem. It does NOT have a startup. asm ; it has a
startup. c using the powerful C extension &amp;quot;#pragma&amp;quot;.</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/147713?ContentTypeID=1</link><pubDate>Fri, 08 Jul 2011 20:20:04 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:33394463-9dc3-4b3b-9350-048439302273</guid><dc:creator>John Linq</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi Hans-Bernhard,&lt;/p&gt;

&lt;p&gt;
Many Thanks for your help.&lt;/p&gt;

&lt;p&gt;
( I saw someone calls you &amp;quot;Hans&amp;quot; before, But as I am a
Taiwanese/Chinese, I don&amp;#39;t know which is proper. )&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/146725?ContentTypeID=1</link><pubDate>Fri, 08 Jul 2011 12:49:40 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:18a99c2f-e398-4a98-a8bc-425431681299</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;[ I can NOT find the define of BNKSYM in the startup.c
]&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
That&amp;#39;s becaus it&amp;#39;s not in there. BNKSYM (and BNKSEC in the Fuji,
which you failed to stumble over) is an assembler operator. Look it
up in the assembler manual.&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;but my knowledge about Assembly programming is very
poor.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
In that case I have to warn you against messing with the startup
code unless you know &lt;b&gt;for sure&lt;/b&gt; there&amp;#39;s an actual problem in
there that you have to fix. You seem to have more important fish to
fry than that one. Starting with what sounded quite a lot like a
stack overflow described in one of your earlier posts.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/147709?ContentTypeID=1</link><pubDate>Fri, 08 Jul 2011 08:51:25 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:bb2fa8be-99b0-4bfe-bc17-22f6920e7b71</guid><dc:creator>Ashley Madison</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;quot;But, to minimize the effort, and maintain the compatibility, I
will remedy the current startup.c, based on the original paper copy;
and focus on the other critical problems, like a very huge single
main.c .&amp;quot;&lt;/p&gt;

&lt;p&gt;
I would find it risky to attempt changing something you don&amp;#39;t
fully understand.&lt;/p&gt;

&lt;p&gt;
from what you described, the .c startup file seems to be working
and the problem of its poor documentation can be remedied later,
probably after you have fixed other problems, like introducing more
structure to the user code.&lt;/p&gt;

&lt;p&gt;
it allows you more time to learn about the start-up and the .c
startup code.&lt;/p&gt;

&lt;p&gt;
but then that&amp;#39;s just me.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/146721?ContentTypeID=1</link><pubDate>Fri, 08 Jul 2011 02:01:16 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2ba0e812-f65b-4770-85dc-78c6a521e6e7</guid><dc:creator>John Linq</dc:creator><description>&lt;p&gt;&lt;p&gt;
I decided to take the opinions from Mike and Hans-Bernhard.&lt;/p&gt;

&lt;p&gt;
I got an original paper copy of the startup.c and other c-files,
they look better. Most of the suspicious portions are not written by
the mentioned third party, it is added by users.&lt;/p&gt;

&lt;p&gt;
Of course, the Fujitsu startup.asm is much better, and more
reliable.&lt;/p&gt;

&lt;p&gt;
But, to minimize the effort, and maintain the compatibility, I
will remedy the current startup.c, based on the original paper copy;
and focus on the other critical problems, like a very huge single
main.c .&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/145148?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 18:51:27 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ffabb797-84b5-49a9-9ed7-d4fa832c9a47</guid><dc:creator>John Linq</dc:creator><description>&lt;p&gt;&lt;p&gt;
Per Westermark =&amp;gt;&lt;br /&gt;
&lt;i&gt;If we ignore potential timing issues, a comparison of that startup
file with the code you have should be able to tell if the current
code does try to recreate all steps performed by the
compiler-supplied startup file.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Hans-Bernhard Broeker =&amp;gt;&lt;br /&gt;
&lt;i&gt;If you really don&amp;#39;t believe in that startup code getting the job
done properly, compile it to asm and look at what you get.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
I have done the comparison for Fujitsu&amp;#39;s startup.asm and the
mentioned startup.c yesterday.&lt;br /&gt;
The Fujitsu&amp;#39;s startup.asm has some features/supports, that the
mentioned startup.c doesn&amp;#39;t provide.&lt;/p&gt;

&lt;p&gt;
And also:&lt;/p&gt;

&lt;p&gt;
Fujitsu&amp;#39;s startup.asm&lt;/p&gt;

&lt;pre&gt;
; Use word aligned stack section. Stack symbols are ignored.
#define SSTACK_L    ((SSTACK + 1) &amp;amp; ~1)
#define SSTACK_H    ((SSTACK + SIZEOF(SSTACK)) &amp;amp; ~1)
#define SSTACK_BNK  BNKSEC SSTACK
[......]
          MOVL A, #SSTACK_H
          MOVW SP,A                 ; load offset of stack top to pointer
          MOV  A, #SSTACK_BNK       ; load bank of stack start address to A
          MOV  SSB, A
&lt;/pre&gt;

&lt;p&gt;
the mentioned startup.c&lt;/p&gt;

&lt;pre&gt;
#pragma asm
                .SECTION STACK, STACK, ALIGN=2
                .RES.B  SSTACK_SIZE - 2
SSTACK_TOP:
                .RES.B  2
#pragma endasm

[......]
&lt;b&gt;[ I can NOT find the define of BNKSYM in the startup.c ]&lt;/b&gt;
                ;--- setup SSTACK
                MOV             A, #BNKSYM SSTACK_TOP
                MOV             SSB, A
                MOVW    A, #SSTACK_TOP + 2
                MOVW    SP, A
&lt;/pre&gt;

&lt;p&gt;
It is embarrassing that, I may be able to read the Assembly code,
but my knowledge about Assembly programming is very poor.&lt;/p&gt;

&lt;p&gt;
( I am a member of&lt;br /&gt;
&lt;a href="http://fujitsu-mcubbs.com/"&gt;http://fujitsu-mcubbs.com/&lt;/a&gt;&lt;br /&gt;
but it is almost a frozen forum. )&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/142948?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 18:06:25 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:720feec9-fcaf-47a0-a454-b3008235621b</guid><dc:creator>John Linq</dc:creator><description>&lt;p&gt;&lt;p&gt;
I don&amp;#39;t know who is Mike Kleshov. But I have read his posts for
more than one or two years.&lt;br /&gt;
My impression on his posts is, &amp;quot;straightforward&amp;quot;, &amp;quot;correct&amp;quot;,
&amp;quot;helpful&amp;quot;.&lt;br /&gt;
My impression on his expertise is, &amp;quot;somehow Mike knows
compilers/compiler behaviors very well.&amp;quot; Although I don&amp;#39;t think Mike
is a compiler developer.&lt;/p&gt;

&lt;p&gt;
Since my colleagues and myself don&amp;#39;t know much about
compilers/compiler behaviors, C runtime environment setup procedures
etc; and I don&amp;#39;t know anything about the mentioned third party; it is
reasonable to me to believe what Mike told me.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/136544?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 13:59:40 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5e41643b-1f18-4d73-8de8-3e926d5ed026</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;because it is a Fujitsu F2MC-16LX MCU. Sorry for that.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Yes, you should be sorry for that. For two reasons:&lt;/p&gt;

&lt;p&gt;
1) You&amp;#39;re holding this discussion in entirely the wrong place&lt;br /&gt;
2) You&amp;#39;re working on an outdated architecture. IIRC, Fuji
(rightfully) stopped making new versions of that years ago.&lt;/p&gt;

&lt;p&gt;
As to the problem in point, I think you should just stop worrying
about it. If you really don&amp;#39;t believe in that startup code getting
the job done properly, compile it to asm and &lt;b&gt;look&lt;/b&gt; at what you
get. If you&amp;#39;re still not convinced, replace the .c file by the
generated .asm file and forget about the fact it was ever .C in the
first place.&lt;/p&gt;

&lt;p&gt;
And yes, I have seen a project using exactly that kind of setup on
exactly that architecture, and it&amp;#39;s working just fine on millions of
devices in the field.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/139989?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 10:47:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d39193c4-23d8-41d7-a947-89a9cc136ac6</guid><dc:creator>Ashley Madison</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;quot;The problem is: I can not trust the mentioned third party as I
trust you.&amp;quot;&lt;/p&gt;

&lt;p&gt;
the last part of what you wrote is scary.&lt;/p&gt;

&lt;p&gt;
&amp;quot;Maybe the mentioned third party is trustable, but it doesn&amp;#39;t mean
that my colleagues would use the startup.c correctly.&amp;quot;&lt;/p&gt;

&lt;p&gt;
sounds like you have trouble trusting your colleagues&amp;#39;
capabilities. if that&amp;#39;s the case, no amount of help over the internet
will get you there.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/139983?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 09:03:02 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3f596b76-ccdc-4c05-b5b7-dfa95119c35b</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Don&amp;#39;t you have access to an assembler startup file for the used
compiler?&lt;/p&gt;

&lt;p&gt;
If we ignore potential timing issues, a comparison of that startup
file with the code you have should be able to tell if the current
code does try to recreate all steps performed by the
compiler-supplied startup file.&lt;/p&gt;

&lt;p&gt;
Next step - if they do mix actual C code during their startup
sequence - is to figure out if the calling conventions are correct,
and stack etc are already correctly configured before first C
function is used.&lt;/p&gt;

&lt;p&gt;
Next step is to check when the C RTL gets initialized, and if any
C RTL functions might have been called before this has happened. Lack
of source code for the C RTL means that it will be impossible to know
the full set of requirements that needs to be fulfilled for each
individual C RTL function.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/136545?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 08:36:24 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1e511f82-102e-4a4a-8960-bf0273710a49</guid><dc:creator>John Linq</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi Mike,&lt;/p&gt;

&lt;p&gt;
If you believe it can be set up properly; then it must be
true.&lt;/p&gt;

&lt;p&gt;
The problem is: I can not trust the mentioned third party as I
trust you.&lt;/p&gt;

&lt;p&gt;
Maybe the mentioned third party is trustable, but it doesn&amp;#39;t mean
that my colleagues would use the startup.c correctly.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/139982?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 08:32:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:83f16ce9-a7c9-40ad-b92e-8cbd02ff8e47</guid><dc:creator>Tamiryan Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
Things can get really nasty when one bypasses the default
initialization of the C library, and that creates problems with some
hardware start-up timing, because of some rare &amp;quot;living on the edge&amp;quot;
condition that suddenly becomes relevant...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/136539?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 08:28:39 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:bfbf2a78-aa1f-4a55-9895-4763b056d317</guid><dc:creator>Tamiryan Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;I am not sure if that (inclusion of assembler instructions in a
C file) makes a big difference. end of the day, they produce the same
result.&amp;lt;i/&amp;gt;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;This is a very generic statement; it can be asserted about
programming in C vs. assembly or even almost any other programming
language. The bit stream (might) yield the same result, but as
mentioned the intricacies of start-up are very different and impose a
different discipline.&lt;br /&gt;
Also, generally speaking inline assembly greatly reduces the freedom
of the compiler to apply all soft of optimizations. Will you then get
the same result? I don&amp;#39;t think so.&lt;/i&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/126947?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 08:27:19 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:7b7589f2-0393-47e2-8722-4a235097b2a7</guid><dc:creator>Mike Kleshov</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;May I assume that, you have seen several cases, where the C
runtime environment is set up properly by &amp;quot;#pragma asm&amp;quot;?&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
No, I haven&amp;#39;t seen it. But I can easily imagine it.&lt;br /&gt;
Although I do agree that this is an unconventional way of writing
startup code. It does raise suspicion.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/126955?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 08:22:08 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:abeb9959-0821-443a-bb6b-4b05c680c648</guid><dc:creator>John Linq</dc:creator><description>&lt;p&gt;&lt;p&gt;
I avoid to mention the actual platform, because it is a Fujitsu
F2MC-16LX MCU. Sorry for that.&lt;/p&gt;

&lt;p&gt;
Hi Per,&lt;/p&gt;

&lt;p&gt;
Recently I am quite frustrated. But many thanks for your help,
explaining and illustrating.&lt;/p&gt;

&lt;p&gt;
Also thanks to all the helps/hints, which I got from this Keil
discussion forum.&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;This is bad modularization. And potentially, there may be part
of the initialization in assembler and part in C, and lots of
assumptions about compiler-specific requirements.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Base on the reading about C51, I suspect that:&lt;br /&gt;
the [startup.c + other C-files] project creates two C runtime
environment setup procedules, one is the startup.c itself, another is
the other C-files partially invoke the C runtime library of the
Toolchain.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/126956?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 08:19:47 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0fa22965-3223-46ab-b027-28a8de84f169</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;quot;but if the amount of assembler instructions is small, it probably
makes more sense to include them in a .c file.&amp;quot;&lt;/p&gt;

&lt;p&gt;
That very much depends on used compiler.&lt;/p&gt;

&lt;p&gt;
Some compilers will remove support for source-level debugging if
mixing assembler and C.&lt;/p&gt;

&lt;p&gt;
Some compilers will merge the compiler-generated assembler
instructions with the inlined assembler instructions and then run
everything through the optimizer, potentially resulting in an object
file containing other instruction sequences than the programmer did
write.&lt;/p&gt;

&lt;p&gt;
So in the general case, C and assembler shouldn&amp;#39;t be mixed in the
same file. Having assembler in a C file in the first place is outside
of the C standard, so any such use should not be considered unless
the specific compiler have specific documentation saying both how to
do it and clearly documenting limitations or potential problems.&lt;/p&gt;

&lt;p&gt;
A compiler vendor normally ships sample startup files since there
are a number of needs that must be fulfilled to make the C RTL work
as expected and make the processor reach main() in a way fulfilling
the requirements from the C standard. Not using the compiler-supplied
startup file (with optional additions for supporting extra hardware)
means that a developer have to take his chances about his own startup
code being enough to fulfill all initialization requirements.
Compiler vendors often do not write a document listing these
requirements for the simple reason that they consider it enough to
just ship a startup file.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/126951?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 08:16:20 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e0308541-36ce-458d-82c9-96ad0481b917</guid><dc:creator>Ashley Madison</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;quot;To me, the worst case is, people here think that:&lt;br /&gt;
...&lt;/p&gt;

&lt;p&gt;
Since I don&amp;#39;t have choices,&amp;quot;&lt;/p&gt;

&lt;p&gt;
then no point in worrying about things you have no power to
influence.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/126954?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 08:08:55 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:506a06e9-1fdd-4320-bf94-6f0c3f896f17</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;quot;like what?&amp;quot;&lt;/p&gt;

&lt;p&gt;
Already covered in previous posts.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/119367?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 08:03:04 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:185e2806-d181-49ac-9d89-8f38ad15d2fa</guid><dc:creator>John Linq</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;Both of these are major risks to you / your project / your
company - I&amp;#39;m not sure which is worse!&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
To me, the worst case is, people here think that:&lt;br /&gt;
what John Linq did well is due to those things are simple; And what
John Linq failed to do it well, is due to John Linq&amp;#39;s fault.&lt;/p&gt;

&lt;p&gt;
Hope this worst case would not happen. I guess I have to be more
positive. Since I don&amp;#39;t have choices, and I am being paid to handle
this.&lt;/p&gt;

&lt;p&gt;
Hi Mike,&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;. As long as the environment is set up properly, it doesn&amp;#39;t
matter if it&amp;#39;s a .s or a .c file.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
May I assume that, you have seen several cases, where the C
runtime environment is set up &lt;b&gt;properly&lt;/b&gt; by &amp;quot;#pragma asm&amp;quot;?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/119359?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 08:01:19 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:bbcfd88f-d816-48c0-ae67-26e0ad2422b1</guid><dc:creator>Ashley Madison</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;quot;In this case, we are talking about assembler initialization - but
assembler instructions in a C file instead of in a separate assembler
file.&amp;quot;&lt;/p&gt;

&lt;p&gt;
I am not sure if that (inclusion of assembler instructions in a C
file) makes a big difference. end of the day, they produce the same
result.&lt;/p&gt;

&lt;p&gt;
I do see a benefit to create a separate assembler file for those
assembler instructions if you have tons of them -&amp;gt; essentially
create a .asm start-up file.&lt;/p&gt;

&lt;p&gt;
but if the amount of assembler instructions is small, it probably
makes more sense to include them in a .c file.&lt;/p&gt;

&lt;p&gt;
my point is that it is hard to make an absolute statement about
whether it is right (or wrong) to embed assembler instructions in a
.c file. it depends on many other factors.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/119356?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 07:51:50 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9356d44e-d28d-421f-a45f-ccefe50db707</guid><dc:creator>Ashley Madison</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;#39;Yes, the Cortex really are special.&amp;#39;&lt;/p&gt;

&lt;p&gt;
like what?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/105044?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 07:04:24 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5c410eef-e2f6-4e8a-b81f-fb676fdcc445</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Yes, the Cortex really are special.&lt;/p&gt;

&lt;p&gt;
No __irq keywords for interrupt handlers.&lt;/p&gt;

&lt;p&gt;
A fixed address for storage of information of the stack, so that
the processor can initialize an initial stack on its own.&lt;/p&gt;

&lt;p&gt;
C is well qualified for low-level tasks.&lt;/p&gt;

&lt;p&gt;
One thing to care about when having strict C code to initialize a
processor is that this init() function don&amp;#39;t have access to the full
C RTL until it has called a init function available with the C RTL -
the call we normally see either directly before our main() is called,
or the last call in a normal assembler startup file in case the C RTL
init function performs the call to main().&lt;/p&gt;

&lt;p&gt;
Same thing with zeroing memory and assign of initialized data.&lt;/p&gt;

&lt;p&gt;
But having the init code in C or assembler is really irrelevant to
this specific thread. In this case, we are talking about assembler
initialization - but assembler instructions in a C file instead of in
a separate assembler file.&lt;/p&gt;

&lt;p&gt;
This is bad modularization. And potentially, there may be part of
the initialization in assembler and part in C, and lots of
assumptions about compiler-specific requirements.&lt;/p&gt;

&lt;p&gt;
When talking about an all-C initialization for a Cortex processor,
it would normally be the compiler vendor who supplies a complete
system with the required helper functionality in the CRTL, and with a
sample startup.c file containing the &amp;quot;normal&amp;quot; initialization
steps.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/105046?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 07:02:02 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:827124a5-a2a6-4803-9b30-bb3542db8ec5</guid><dc:creator>Ashley Madison</dc:creator><description>&lt;p&gt;&lt;p&gt;
the cmsis example is to show that there is nothing wrong with
using .c start-up code.&lt;/p&gt;

&lt;p&gt;
and I am not sure why that wouldn&amp;#39;t / couldn&amp;#39;t be extended to
cover the 8051.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/91095?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 06:43:15 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d2d82651-b2f2-4dba-af8c-1ad8ddb4d4d1</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
CMSIS applies specifically to ARM Cortex-M&lt;i&gt;x&lt;/i&gt;, and one of the
key goals of that architecture&amp;#39;s design was to allow &amp;quot;all C&amp;quot; coding -
in particular, witout requiring assembler startup code.&lt;/p&gt;

&lt;p&gt;
The 8051 is very different!&lt;/p&gt;

&lt;p&gt;
That&amp;#39;s why I said early on that this can&amp;#39;t be treated (just) as a
generic topic - it &lt;b&gt;does&lt;/b&gt; depend very much on the particular
toolset!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/59622?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 06:25:26 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:4883d916-414b-45ee-92aa-72b74018a857</guid><dc:creator>Ashley Madison</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;quot;What will be the side-effect, when the C runtime environment is
setup by the C extension &amp;quot;#pragma&amp;quot;?&amp;quot;&lt;/p&gt;

&lt;p&gt;
probably none.&lt;/p&gt;

&lt;p&gt;
as far as the mcu is concerned, it simply executes a series of
commands sent to it. what generated those commands is irrelevant.&lt;/p&gt;

&lt;p&gt;
as to the wisdom of using .c start-up files, check the cmsis
document and you will see that they plan to use .c start-up files
later.&lt;/p&gt;

&lt;p&gt;
no, I wouldn&amp;#39;t lose too much sleep over that.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C runtime environment setup by "#pragma asm"</title><link>https://community.arm.com/thread/119362?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2011 04:43:13 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a52cc198-1f77-497e-acdc-b5d87492f598</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
BUT how do you know that the setup was &amp;quot;successful&amp;quot;?!&lt;/p&gt;

&lt;p&gt;
If the setup is broken, it will leave the system in a broken state
- likely to cause problems in later execution.&lt;/p&gt;

&lt;p&gt;
A classic example is the many C51 posts where the setup is
&amp;quot;broken&amp;quot; in that it does not correctly configure the XDATA
access...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>