<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>LPC MicrocontrollersのトピックRe: LP4330 (or other) - Calling assembly function located in RAM from C that is in Flash</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LP4330-or-other-Calling-assembly-function-located-in-RAM-from-C/m-p/662044#M26367</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As there is a veneer, this means the linker thinks you are calling an ARM function, which is not psooible with a Cortex-M &amp;nbsp;base part. I think you need to tell the assembler that your function is thumb code. I think this is. thumbfunc assembler directive - but double check!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Sep 2016 18:43:06 GMT</pubDate>
    <dc:creator>avt</dc:creator>
    <dc:date>2016-09-29T18:43:06Z</dc:date>
    <item>
      <title>LP4330 (or other) - Calling assembly function located in RAM from C that is in Flash</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LP4330-or-other-Calling-assembly-function-located-in-RAM-from-C/m-p/662043#M26366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using a LPC4330 with LPCXpresso 8.2.&amp;nbsp; In the project, most code runs in place in QSPI at 100MHz but I have some functions I need to run very fast so they are located into RAM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've been attempting to determine how to call an assembly function located in RAM.&amp;nbsp; An example of the assembly code is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; .syntax unified&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; .section .ramfunc.$RAM2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; .global&amp;nbsp;&amp;nbsp; &amp;nbsp;CLZ&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLZ:&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;clz r0, r0&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;bx lr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;.END&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This assembly file is part of the project and built with the GCC tool along with the rest of the project.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a header file I have the C prototype for this assembly function:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;__RAMFUNC(RAM2) int CLZ(int x);&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The call to this function from C code that is located in Flash compiles using an address for the CLZ call that is in the middle of some other functions.&amp;nbsp; Therefore I assume something isn't setup right as the linker is just plain confused.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The C code that first attempts to use this assembly function is:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return CLZ(gbMask) - 1;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The instructions that are compiled into flash are (not the indicated veneer address):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;14002780:&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r0, r10&lt;BR /&gt;14002782:&amp;nbsp;&amp;nbsp; blx&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x14013db0 &amp;lt;__CLZ_veneer&amp;gt;&lt;BR /&gt;14002786:&amp;nbsp;&amp;nbsp; subs&amp;nbsp;&amp;nbsp;&amp;nbsp; r0, #1&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;However the CLZ function is located in RAM where I expect it (From the map file):&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [!provide]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PROVIDE (__start_data_RAM2, .)&lt;BR /&gt;&amp;nbsp;*(.ramfunc.$RAM2)&lt;BR /&gt;&amp;nbsp;.ramfunc.$RAM2&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x10080000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x16 ./src/mp3codec/asmmisc.o&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x10080000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MULSHIFT32&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x10080006&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FASTABS&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x10080010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CLZ&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;So, I'm expecting the branch call to be to 0x10080010 but instead it is to some other code.&amp;nbsp; It happens to be some const data that are invalid instructions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do I have to do something special to get the C code to link to the assembly properly in the case it is in a different section?&amp;nbsp; I don't get any compile or link warnings that I can find.&amp;nbsp; Seems like this should be throwing a warning or an error as it certainly isn't linking to anything valid.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Sep 2016 18:08:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LP4330-or-other-Calling-assembly-function-located-in-RAM-from-C/m-p/662043#M26366</guid>
      <dc:creator>nsmith17044</dc:creator>
      <dc:date>2016-09-29T18:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: LP4330 (or other) - Calling assembly function located in RAM from C that is in Flash</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LP4330-or-other-Calling-assembly-function-located-in-RAM-from-C/m-p/662044#M26367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As there is a veneer, this means the linker thinks you are calling an ARM function, which is not psooible with a Cortex-M &amp;nbsp;base part. I think you need to tell the assembler that your function is thumb code. I think this is. thumbfunc assembler directive - but double check!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Sep 2016 18:43:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LP4330-or-other-Calling-assembly-function-located-in-RAM-from-C/m-p/662044#M26367</guid>
      <dc:creator>avt</dc:creator>
      <dc:date>2016-09-29T18:43:06Z</dc:date>
    </item>
  </channel>
</rss>

