<?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>delay_us assembly error</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/31928/delay_us-assembly-error</link><description> 
Following code is used to generate delays on a cortex M0. 

 
// for Cortex-M0 (subs for Cortex-M3)
void y_delay_3x_cycles(uint32_t cycles) __attribute__((naked, used));

void y_delay_3x_cycles(uint32_t cycles __attribute__((unused))) {
 __asm(
 &amp;quot; sub</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: delay_us assembly error</title><link>https://community.arm.com/thread/150423?ContentTypeID=1</link><pubDate>Thu, 30 Oct 2014 17:21:23 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:25376430-ecc5-4f82-b0a1-72d939708805</guid><dc:creator>Yash Parulekar</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thanks Pier. Included the assembly file thanks. Compile without an
error. Hope this ASM code create a 3 cycles per loop.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: delay_us assembly error</title><link>https://community.arm.com/thread/150418?ContentTypeID=1</link><pubDate>Thu, 30 Oct 2014 10:16:07 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:96b249ce-817c-43fb-982e-4944e26daacb</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;quot;Make sure the code is *not* after the END directive in the
assembler file.&amp;quot;&lt;/p&gt;

&lt;p&gt;
That&amp;#39;s a classic mistake - quite a lot of different assemblers who
has an &amp;quot;end&amp;quot; directive and silently allows any excess data after the
end directive.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: delay_us assembly error</title><link>https://community.arm.com/thread/149993?ContentTypeID=1</link><pubDate>Thu, 30 Oct 2014 10:00:44 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:65ee8ef8-9ea3-49ad-8222-f2d5210f84c2</guid><dc:creator>Westonsupermare Pier</dc:creator><description>&lt;p&gt;&lt;p&gt;
And is it actually assembling the startup_xx.s file and creating
the startup_xx.o file, is that being linked? Can you see the code in
the .LST file?&lt;/p&gt;

&lt;p&gt;
Make sure the code is *not* after the END directive in the
assembler file.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: delay_us assembly error</title><link>https://community.arm.com/thread/149528?ContentTypeID=1</link><pubDate>Wed, 29 Oct 2014 20:58:30 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9745ae0f-856c-49df-bff1-3e2fc9c1deba</guid><dc:creator>Yash Parulekar</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi Pier,&lt;/p&gt;

&lt;p&gt;
I&amp;#39;ve this at the end of the startup_xx.s file:&lt;/p&gt;

&lt;pre&gt;
;Delay 3x funtion
xx_delay_3x_cycles PROC
  EXPORT xx_delay_3x_cycles

  subs r0, r0, #1
  bne xx_delay_3x_cycles
  bx lr

  ENDP

;End of the file startup_xx.s
&lt;/pre&gt;

&lt;p&gt;
In the xx_micro.c file:&lt;/p&gt;

&lt;pre&gt;
extern void xx_delay_3x_cycles(uint32_t cycles);

//In this C file the funtion xx_delay_3x_cycles(CYCLES_PER_SECOND / 3000); is called a few times
&lt;/pre&gt;

&lt;p&gt;
still getting the same error:&lt;br /&gt;
.\obj\MyProj.axf: Error: L6218E: Undefined symbol xx_delay_3x_cycles
(referred from xx_micro.o).&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: delay_us assembly error</title><link>https://community.arm.com/thread/149025?ContentTypeID=1</link><pubDate>Wed, 29 Oct 2014 20:01:39 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:790c3d6a-a8c4-47cd-aada-99e62e693075</guid><dc:creator>Westonsupermare Pier</dc:creator><description>&lt;p&gt;&lt;p&gt;
Not the problem here, most probably not assembling file, or not
linking object.&lt;/p&gt;

&lt;p&gt;
Need to lose the quote after the lr, seems to have gotten in my
cut and paste&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: delay_us assembly error</title><link>https://community.arm.com/thread/137178?ContentTypeID=1</link><pubDate>Wed, 29 Oct 2014 19:20:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3324cf1b-7123-49fd-bb5d-10d40e96bdd1</guid><dc:creator>Yash Parulekar</dc:creator><description>&lt;p&gt;&lt;p&gt;
So I made the following change (ONLY) in the .s file:&lt;br /&gt;
I added an &amp;#39;_&amp;#39; infront of the function name:&lt;/p&gt;

&lt;pre&gt;
;Delay 3x funtion
_xx_delay_3x_cycles PROC
  EXPORT _xx_delay_3x_cycles

  subs r0, r0, #1
  bne _xx_delay_3x_cycles
  bx lr&amp;quot;

  ENDP
&lt;/pre&gt;

&lt;p&gt;
But, I&amp;#39;m still getting the same error:&lt;br /&gt;
.\obj\MyProj.axf: Error: L6218E: Undefined symbol xx_delay_3x_cycles
(referred from xx_micro.o).&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: delay_us assembly error</title><link>https://community.arm.com/thread/128737?ContentTypeID=1</link><pubDate>Wed, 29 Oct 2014 19:02:44 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b3324545-2123-42fe-99ae-30ecb9bd9aaa</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Note that the C language has a convention that a &amp;#39;_&amp;#39; is added
first in the external symbol name - this is done to make sure that
the C program has it&amp;#39;s own &amp;quot;name space&amp;quot; that doesn&amp;#39;t collide with
assembler routines in the startup code etc.&lt;/p&gt;

&lt;p&gt;
So your C code might look for a symbol named _xx_delay_3x_cycles
while your assembler code exports a symbol without any leading
underscore.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: delay_us assembly error</title><link>https://community.arm.com/thread/120450?ContentTypeID=1</link><pubDate>Wed, 29 Oct 2014 13:04:14 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3502d92d-d483-4fab-9231-e51ffd408e54</guid><dc:creator>Yash Parulekar</dc:creator><description>&lt;p&gt;&lt;p&gt;
I did what u posted: Westonsupermare Pier ARM @ 7-Oct-2014 04:33
GMT . So I edited the .c and .s files.&lt;/p&gt;

&lt;p&gt;
Now I&amp;#39;m getting this error:&lt;br /&gt;
.\obj\MyProj.axf: Error: L6218E: Undefined symbol xx_delay_3x_cycles
(referred from xx_micro.o).&lt;br /&gt;
Trying to figure out this error. Your feedback is valuable Mr. Pier.
Thanks!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: delay_us assembly error</title><link>https://community.arm.com/thread/118556?ContentTypeID=1</link><pubDate>Tue, 07 Oct 2014 11:12:02 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a191815d-b962-4dba-bbaa-bb745b97a91b</guid><dc:creator>Westonsupermare Pier</dc:creator><description>&lt;p&gt;&lt;p&gt;
Because it&amp;#39;s not the GNU/GCC compiler? And it&amp;#39;s not supported in
Keil ARM compilers?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: delay_us assembly error</title><link>https://community.arm.com/thread/107925?ContentTypeID=1</link><pubDate>Tue, 07 Oct 2014 09:47:41 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:26063c8b-af18-45da-bcdb-cb8a56cb1383</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;pre&gt;
Why does the compiler ignore &amp;quot;naked&amp;quot;
&lt;/pre&gt;

&lt;p&gt;
What does the compiler manual say about the &amp;quot;naked&amp;quot; attribute?&lt;/p&gt;

&lt;p&gt;
I know the manual contains &amp;quot;used&amp;quot; but where did you find any
documentation for &amp;quot;naked&amp;quot;?&lt;br /&gt;
&lt;a href="http://www.keil.com/support/man/docs/armccref/armccref_babcighe.htm"&gt;
&lt;a href="http://www.keil.com/support/man/docs/armccref/armccref_babcighe.htm"&gt;www.keil.com/.../armccref_babcighe.htm&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: delay_us assembly error</title><link>https://community.arm.com/thread/82180?ContentTypeID=1</link><pubDate>Mon, 06 Oct 2014 20:34:53 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:4d14532e-ff64-4e36-8800-340b44b3f9ae</guid><dc:creator>Yash Parulekar</dc:creator><description>&lt;p&gt;&lt;p&gt;
Why does the compiler ignore &amp;quot;naked&amp;quot;:&lt;/p&gt;

&lt;pre&gt;
..\src\y.c(75): warning:  #1207-D: unknown attribute &amp;quot;naked&amp;quot;
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: delay_us assembly error</title><link>https://community.arm.com/thread/118554?ContentTypeID=1</link><pubDate>Mon, 06 Oct 2014 20:33:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:745c3e10-46e4-4e17-acd0-c528751a3f68</guid><dc:creator>Westonsupermare Pier</dc:creator><description>&lt;p&gt;&lt;pre&gt;
; In .C file  extern void xx_delay_3x_cycles(uint32_t cycles);

; In .S file

;...

xx_delay_3x_cycles PROC
  EXPORT xx_delay_3x_cycles

  subs r0, r0, #1
  bne xx_delay_3x_cycles
  bx lr&amp;quot;

  ENDP
;...
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: delay_us assembly error</title><link>https://community.arm.com/thread/82179?ContentTypeID=1</link><pubDate>Mon, 06 Oct 2014 20:14:49 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5e7f6976-2bbf-4e73-aa67-4cf9ec61802a</guid><dc:creator>Yash Parulekar</dc:creator><description>&lt;p&gt;&lt;pre&gt;
..\src\mp_micro.c(80): error:  #2829: Cannot perform desired action on condition flags
          &amp;quot;    sub regVariable, #1\n&amp;quot;
&lt;/pre&gt;

&lt;p&gt;
I&amp;#39;m trying to repair this. I&amp;#39;ve no idea on how this code could be
moved to startup_MyArch.s file and then how to access that code
through the current file (i.e. micro.c): Currently this code is
written in micro.c file.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: delay_us assembly error</title><link>https://community.arm.com/thread/63178?ContentTypeID=1</link><pubDate>Mon, 06 Oct 2014 20:01:08 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:30281c85-9657-49cd-aec0-af7717563872</guid><dc:creator>Westonsupermare Pier</dc:creator><description>&lt;p&gt;&lt;p&gt;
..\src\mp_micro.c(79): error: #2829: Cannot perform desired action
on condition flags &amp;quot; sub r0, #1\n&amp;quot;&lt;/p&gt;

&lt;p&gt;
subs r0,r0,#1 ;??&lt;/p&gt;

&lt;p&gt;
If in-lining assembler is a problem, then put it in the
startup_arch.s file&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>