<?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>#pragma ASM/ENDASM inside a #define (???)</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/20602/pragma-asm-endasm-inside-a-define</link><description> 
Hello, 

 
I&amp;#39;m having trouble using #pragma ASM/ENDASM inside a #define
statement. This is what I want to do inside the #define: 

 
- push ACC (assembly) 
- push IE (assembly) 
- EA = 0 (C) 

 
This is the code I&amp;#39;m * trying * to use: 

 
#define portENTER_CRITICAL</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: #pragma ASM/ENDASM inside a #define (???)</title><link>https://community.arm.com/thread/88363?ContentTypeID=1</link><pubDate>Wed, 10 Oct 2007 01:18:51 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:58325e62-e60b-4b86-8805-a480508e3cf8</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;SDCC manuals says _bp is the stack frame pointer and keil
doesn&amp;#39;t allow compiling of the same&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Keil doesn&amp;#39;t use a &amp;quot;stack frame&amp;quot; in the conventional sense!&lt;/p&gt;

&lt;p&gt;
Anyhow, &amp;quot;_bp&amp;quot; is an internal symbol of SDCC - you should never
expect any compiler to understand the internal symbols of another
compiler!&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;What could be the alternative?&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
I think you&amp;#39;re going to have to do this in &lt;b&gt;assembler&lt;/b&gt;.&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;Free RTOS for 8051 SDCC ... how to port?&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
First, you&amp;#39;re going to need to gain a very thorough, in-depth
understanding of how this &amp;quot;Free RTOS&amp;quot; works, and how it relies upon
the specific implementation details of SDCC (this, of course, implies
an in-depth understanding of the specific implementation details of
SDCC itself);&lt;br /&gt;
Next, you&amp;#39;re going to need to gain a very thorough, in-depth
understanding of Keil&amp;#39;s implementation details;&lt;br /&gt;
Then - and only then - you will be in a position to understand how to
adapt &amp;quot;Free RTOS for SDCC&amp;quot; to Keil.&lt;/p&gt;

&lt;p&gt;
Again, this so-called &amp;quot;free&amp;quot; RTOS may have a zero price tag to
obtain, but it certainly has a non-zero cost to implement!&lt;/p&gt;

&lt;p&gt;
Would it not be simpler just to use SDCC?&lt;/p&gt;

&lt;p&gt;
Or, if you must use Keil, why not use an RTOS supplied &amp;amp;
supported by Keil?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: #pragma ASM/ENDASM inside a #define (???)</title><link>https://community.arm.com/thread/48193?ContentTypeID=1</link><pubDate>Tue, 09 Oct 2007 05:54:51 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e74914b9-0c8f-4da1-af25-9d35dd3b0be3</guid><dc:creator>Anand Budni</dc:creator><description>&lt;p&gt;&lt;p&gt;
Free RTOS for 8051 SDCC compiler uses &amp;quot;pop/push _bp&amp;quot; instructions
for restoring/storing the context during context switch.SDCC manuals
says _bp is the stack frame pointer and keil doesn&amp;#39;t allow compiling
of the same.What could be the alternative?....how to port?...Anyone
tried this?...&lt;br /&gt;
Thanks,&lt;br /&gt;
P.S.Manikandan.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: #pragma ASM/ENDASM inside a #define (???)</title><link>https://community.arm.com/thread/48194?ContentTypeID=1</link><pubDate>Wed, 06 Jun 2007 19:50:40 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:cce05534-c409-433b-9816-ca29eb098855</guid><dc:creator>white holes</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;b&gt;Hello:&lt;br /&gt;&lt;/b&gt; &lt;b&gt;I&amp;#39;m a newer here.&lt;/b&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: #pragma ASM/ENDASM inside a #define (???)</title><link>https://community.arm.com/thread/138456?ContentTypeID=1</link><pubDate>Mon, 04 Jun 2007 11:50:24 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:20e52c8e-1a6e-4f7d-ba33-3448a245d49e</guid><dc:creator>Drew Davis</dc:creator><description>&lt;p&gt;&lt;p&gt;
ANSI C does not allow preprocessor directives to be generated by
#define.&lt;/p&gt;

&lt;p&gt;
There&amp;#39;s one ugly way to do this just with the C preprocessor:&lt;/p&gt;

&lt;p&gt;
header.h&lt;br /&gt;
--&lt;br /&gt;
...&lt;br /&gt;
#include &amp;quot;mypragma.pragma&amp;quot;&lt;br /&gt;
...&lt;/p&gt;

&lt;p&gt;
mypragma.pragma&lt;br /&gt;
--&lt;br /&gt;
#pragma mypragma&lt;br /&gt;
--&lt;/p&gt;

&lt;p&gt;
But I can&amp;#39;t really recommend it.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: #pragma ASM/ENDASM inside a #define (???)</title><link>https://community.arm.com/thread/130170?ContentTypeID=1</link><pubDate>Mon, 04 Jun 2007 07:42:01 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e35d736e-be68-4698-a527-3b8616c86f6a</guid><dc:creator>Carlos Santos</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi,&lt;/p&gt;

&lt;p&gt;
It&amp;#39;s only on the demo software, to test the RTOS. The logic behind
that is the greater probability of a task being interrupted by a
context switch between a float operation (sum, multiplication,
etc...) than with a single byte operation...&lt;/p&gt;

&lt;p&gt;
regards,&lt;br /&gt;
Carlos.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: #pragma ASM/ENDASM inside a #define (???)</title><link>https://community.arm.com/thread/123858?ContentTypeID=1</link><pubDate>Mon, 04 Jun 2007 07:31:02 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1b4d7ba4-49d5-4817-8d58-e654d6bb7e5f</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;(I think it has to do with floating point operations)&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Why would an RTOS be doing floating-point operations...?!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: #pragma ASM/ENDASM inside a #define (???)</title><link>https://community.arm.com/thread/112920?ContentTypeID=1</link><pubDate>Mon, 04 Jun 2007 05:27:20 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:abdeb7f6-af4a-48fb-bea0-a5ff78ab871e</guid><dc:creator>Carlos Santos</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hello :)&lt;/p&gt;

&lt;p&gt;
Yep, I took Cygnal port as a base... The problem is the
compiler... I&amp;#39;m using Keil and they use SDCC. SDCC suports assembly
in #define statements, but doesn&amp;#39;t support 51MX family, I think only
keil cx51 supports 51MX...&lt;/p&gt;

&lt;p&gt;
I already &amp;quot;expanded&amp;quot; all #defines with the code that was supposed
to be inside them (basically I&amp;#39;ve made the pre-processor work by hand
:), but now I have linker errors saying that it can&amp;#39;t find some
libraries (I think it has to do with floating point
operations)...&lt;/p&gt;

&lt;p&gt;
Regards and thanks for the replies :)&lt;br /&gt;
Carlos.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: #pragma ASM/ENDASM inside a #define (???)</title><link>https://community.arm.com/thread/99269?ContentTypeID=1</link><pubDate>Mon, 04 Jun 2007 05:17:51 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f7db311e-681e-4cec-9423-9d9361e24f5a</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
It says a port already exists to the SiLabs 8051-derivatives:&lt;br /&gt;
&lt;a href="http://www.freertos.org/main.html#ports"&gt;www.freertos.org/main.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
could you get any tips from the way they did it?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: #pragma ASM/ENDASM inside a #define (???)</title><link>https://community.arm.com/thread/99268?ContentTypeID=1</link><pubDate>Mon, 04 Jun 2007 05:11:39 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:4e323163-61bf-45cb-9d79-34529e811753</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;Those defines are used mainly for context switching, so they
need to be done in assembly&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Yes that &lt;i&gt;is&lt;/i&gt; the kind of thing that should be done in
assembly!&lt;/p&gt;

&lt;p&gt;
It really shouldn&amp;#39;t be anywhere near a &amp;#39;C&amp;#39; file!&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;If anyone saw the freertos sources, you know what I&amp;#39;m talking
about...&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
I haven&amp;#39;t, so I&amp;#39;ll take your word for it...&lt;/p&gt;

&lt;p&gt;
If you&amp;#39;re stuck with having to do it this way because of 3rd-party
constraints, then I s&amp;#39;pose you&amp;#39;ll have to go that way - even if it
really is a &lt;i&gt;&amp;quot;bad practice&amp;quot;&lt;/i&gt; blah, blah, etc...&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;:-(&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
So, although the source is &amp;quot;free&amp;quot;, the work to port it is going to
cost something - that&amp;#39;s always the tradeoff: is it worth it, rather
than buy something &amp;quot;ready-to-go&amp;quot;...?&lt;br /&gt;
That&amp;#39;s a call only you can make!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: #pragma ASM/ENDASM inside a #define (???)</title><link>https://community.arm.com/thread/75150?ContentTypeID=1</link><pubDate>Mon, 04 Jun 2007 04:13:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:92103703-5ba5-462b-911f-45e112df478c</guid><dc:creator>Carlos Santos</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hello,&lt;/p&gt;

&lt;p&gt;
What I&amp;#39;m trying to do is port FreeRTOS (&lt;a href="http://www.FreeRTOS.org"&gt;http://www.FreeRTOS.org&lt;/a&gt;) to the philips
51MX architecture (P89C669)...&lt;/p&gt;

&lt;p&gt;
The way freertos is made, to add support to other
processors/microcontrolers one needs to make some architecture
specific functions and some macros (#defines) . Those defines are
used mainly for context switching, so they need to be done in
assembly, to make use of push&amp;#39;s and pop&amp;#39;s. If anyone saw the freertos
sources, you know what I&amp;#39;m talking about...&lt;/p&gt;

&lt;p&gt;
Regards,&lt;br /&gt;
Carlos.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: #pragma ASM/ENDASM inside a #define (???)</title><link>https://community.arm.com/thread/50798?ContentTypeID=1</link><pubDate>Mon, 04 Jun 2007 01:10:12 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:80e17fed-28da-44a2-8c64-7ee819eac0c7</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;I really need this&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
What makes you think that you really need this?&lt;/p&gt;

&lt;p&gt;
If you explained what you&amp;#39;re actually trying to
&lt;i&gt;&lt;b&gt;achieve&lt;/b&gt;&lt;/i&gt;, people might be able to offer you solutions to
your problem, rather than try to fix a fundamentally broken
approach...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: #pragma ASM/ENDASM inside a #define (???)</title><link>https://community.arm.com/thread/48190?ContentTypeID=1</link><pubDate>Sun, 03 Jun 2007 15:20:51 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:4a6366d7-fc66-41cf-82e0-0eb23f3c4c9b</guid><dc:creator>Dan Henry</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;... it seems that #pragma ASM/ENDASM can&amp;#39;t be used inside
header files (who knows why...)&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
It doesn&amp;#39;t have anything to do with header files. It&amp;#39;s because
#pragma can&amp;#39;t be used as part of macro expansion.&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;is there any workaround for that ...&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
No.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>