<?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>topic Re: How do I compile relocatable functions? in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC12-How-do-I-compile-relocatable-functions/m-p/135582#M1733</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;According to TN235, the PIC qualifier is not available for HC9(S)08.&amp;nbsp; So what is the solution for these devices?&amp;nbsp; Writing the relocatable code in assembler would seem to be the only workable arrangement.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Nov 2006 02:08:10 GMT</pubDate>
    <dc:creator>bigmac</dc:creator>
    <dc:date>2006-11-08T02:08:10Z</dc:date>
    <item>
      <title>HC12: How do I compile relocatable functions?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC12-How-do-I-compile-relocatable-functions/m-p/135578#M1729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I am writing in Codewarrior v4.5 C for HCS12X cpu.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I am trying to make a few&amp;nbsp;relocatable functions that I can copy to RAM and execute there. I have no problem with the copy and execute. The problem is that the compiler has used some JMP and JSR opcodes that make it non-relocatable. These are short jumps to the end of the function and for optimization of repetitive code but they are&amp;nbsp;jumping to flash and not the RAM copy. How can I disable this and force the compiler to use relative branches (long or short as needed) instead of absolute jumps when I compile these functions?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;...oh and NO I can NOT build the code to reside in RAM because the RAM location of the buffer may change in future versions so it MUST use relative branches.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I really don't want to have to re-write all of this in asm just to get it to run.&lt;/DIV&gt;&lt;P&gt;Message Edited by CrasyCat on &lt;SPAN class="date_text"&gt;2007-04-13&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;01:21 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Message Edited by CrasyCat on &lt;SPAN class="date_text"&gt;2007-04-13&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;01:21 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Nov 2006 04:43:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC12-How-do-I-compile-relocatable-functions/m-p/135578#M1729</guid>
      <dc:creator>xgater</dc:creator>
      <dc:date>2006-11-07T04:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do I compile relocatable functions?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC12-How-do-I-compile-relocatable-functions/m-p/135579#M1730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;There's a PIC (position independend code) section qualifier:&lt;BR /&gt;(out of my memory, not tried)&lt;BR /&gt;&lt;PRE&gt;
#pragma CODE_SEG PIC REL_CODE
void fun(void) {
.......
}
#pragma CODE_SEG DEFAULT
&lt;/PRE&gt;&lt;BR /&gt;I guess that's what you are looking for. With the RELOCATE_TO prm file syntax&lt;BR /&gt;it is also possible to link the code to a different place than it is executed from.&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Nov 2006 09:21:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC12-How-do-I-compile-relocatable-functions/m-p/135579#M1730</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2006-11-07T09:21:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I compile relocatable functions?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC12-How-do-I-compile-relocatable-functions/m-p/135580#M1731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Thanks, once again you've bailed me out. This is working well.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Nov 2006 10:14:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC12-How-do-I-compile-relocatable-functions/m-p/135580#M1731</guid>
      <dc:creator>xgater</dc:creator>
      <dc:date>2006-11-07T10:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I compile relocatable functions?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC12-How-do-I-compile-relocatable-functions/m-p/135581#M1732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Answers my question as well! (Also, you can find a technical note elsewhere on this site TN235 on the same subject).&lt;/DIV&gt;&lt;DIV&gt;(I am writing a "bootstrap" function to update the firmware remotely - did this previously on the HC11 where I ran the interface and flash program modules from RAM, allowing me to completely rewrite the code in FLASH.. I don't know if you are looking at a similar application?)&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 00:42:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC12-How-do-I-compile-relocatable-functions/m-p/135581#M1732</guid>
      <dc:creator>Scratch</dc:creator>
      <dc:date>2006-11-08T00:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do I compile relocatable functions?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC12-How-do-I-compile-relocatable-functions/m-p/135582#M1733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;According to TN235, the PIC qualifier is not available for HC9(S)08.&amp;nbsp; So what is the solution for these devices?&amp;nbsp; Writing the relocatable code in assembler would seem to be the only workable arrangement.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 02:08:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC12-How-do-I-compile-relocatable-functions/m-p/135582#M1733</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2006-11-08T02:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I compile relocatable functions?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC12-How-do-I-compile-relocatable-functions/m-p/135583#M1734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;PIC is not supported for the HC08, that's correct.&lt;BR /&gt;If you "just" have to execute your code from a specific known location in RAM, then using RELOCATE_TO does the trick, check TN228.&lt;BR /&gt;&lt;BR /&gt;If you need real relocatable code (which can execute from any address) for a HC(S)08, then the only clean solution today is to use assembly, AFAIK. For smaller functions you could also check and hope (and configure up to some extend) that the compiler does not use any JMPs or JSRs. But that's more a (ugly) workaround, I know.&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 02:30:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC12-How-do-I-compile-relocatable-functions/m-p/135583#M1734</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2006-11-08T02:30:41Z</dc:date>
    </item>
  </channel>
</rss>

