<?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: Problem with copy routine in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problem-with-copy-routine-for-HCS08-and-CW-5-1/m-p/135738#M1773</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hello Mac,&lt;BR /&gt;&lt;BR /&gt;sorry for my late reply, I was on vacation some days.&lt;BR /&gt;I think these examples are old ones which are copied from older manuals. I remember during my studies we played around with the 68332. In the TPU manual there were also programming examples given. They had some obvious mistakes and could therefore not be compiled and this was never corrected.&lt;BR /&gt;&lt;BR /&gt;I use your given method and it works fine, thanks for your help again!&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;&lt;BR /&gt;Ralph&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 21 Jun 2007 22:25:26 GMT</pubDate>
    <dc:creator>Ralph</dc:creator>
    <dc:date>2007-06-21T22:25:26Z</dc:date>
    <item>
      <title>Problem with copy routine for HCS08 and CW 5.1</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problem-with-copy-routine-for-HCS08-and-CW-5-1/m-p/135733#M1768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;SPAN&gt;Hi!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe a beginners question, but I don't know whats wrong there.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In my program I have to copy different strings from Flash to my transmit queue which is in RAM (for sure :-)). So I tried to find a good assembler routine to do this with minimal effort. Fortunately (?) I have found a routine in HCS08RM chapter 6.5.1.3 "Memory to Memory Moves":&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldhx&amp;nbsp;&amp;nbsp;&amp;nbsp; #TX_queue&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;copy_loop:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lda&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; (Text-TX_queue),x&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; beq&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; end_of_copy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sta&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; ,x&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; incx&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bra&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; copy_loop&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;end_of_copy:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;.....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I start with "make" button of CW5.1 I get the following Error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A target="_blank"&gt;&lt;SPAN style="font-family: Arial; font-size: 2;"&gt;A2401: Complex relocatable expression not supported&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;A target="_blank"&gt;&lt;/A&gt;&lt;SPAN&gt;for " &amp;nbsp;&amp;nbsp; lda&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; (Text-TX_queue),x"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't know why this is happening. It should be a valid command (address mode IX2). Is this a bug of CW5.1 or do I have to use fixed flash adresses and compute the difference of "Text-TX_queue" by myself?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks in advance!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ralph&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;J2MEJediMaster added MCU type and CodeWarrior version to subject line&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Message Edited by J2MEJediMaster on &lt;/SPAN&gt;&lt;SPAN class="date_text"&gt;2007-06-05&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;09:19 AM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jun 2007 22:31:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problem-with-copy-routine-for-HCS08-and-CW-5-1/m-p/135733#M1768</guid>
      <dc:creator>Ralph</dc:creator>
      <dc:date>2007-06-04T22:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with copy routine</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problem-with-copy-routine-for-HCS08-and-CW-5-1/m-p/135734#M1769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello Ralph,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;This sort of compile time calculation is apparently a big&amp;nbsp;no no for relocatable assembly, but seems to be quite OK for absolute assembly (using CW assembler tool rather than IDE).&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;A work-around method given in the help file is to calculate the required offset in run time.&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;Perhaps another method is to use two different (non-zero) offsets, one for the source location and the other for the destination.&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 face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldhx&amp;nbsp;&amp;nbsp;&amp;nbsp; #0&lt;BR /&gt;copy_loop:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lda&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Text,x&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; beq&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end_of_copy&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sta&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TX_queue,x&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; incx&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bra&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;copy_loop&lt;BR /&gt;end_of_copy:&lt;BR /&gt;&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;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jun 2007 23:38:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problem-with-copy-routine-for-HCS08-and-CW-5-1/m-p/135734#M1769</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-06-04T23:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with copy routine</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problem-with-copy-routine-for-HCS08-and-CW-5-1/m-p/135735#M1770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hello Mac,&lt;BR /&gt;&lt;BR /&gt;many thanks for your quick reply! I now understand that this kind of programming is not good for relative assembly code. So a little note in the RM would have been good that this is not a good programming style.&lt;BR /&gt;&lt;BR /&gt;Many thanks also for your code proposal. I'll use your code then and think my problems have gone :smileyhappy:.&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;&lt;BR /&gt;Ralph&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2007 00:31:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problem-with-copy-routine-for-HCS08-and-CW-5-1/m-p/135735#M1770</guid>
      <dc:creator>Ralph</dc:creator>
      <dc:date>2007-06-05T00:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with copy routine</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problem-with-copy-routine-for-HCS08-and-CW-5-1/m-p/135736#M1771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;Ralph wrote:&lt;BR /&gt;. . . So a little note in the RM would have been good that this is not a good programming style.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;Hi Ralph,&lt;BR /&gt;&lt;BR /&gt;I don't think that there is anything wrong with that style, and I use it all of the time.&lt;BR /&gt;&lt;BR /&gt;It would work if the two lables were in the same segment, because the assembler could calculate the offset. But if the two lables are in different segments, as they must be when one is in ram and the other is in flash, then the assembler can't calculate the offset. For some reason, the linker is not smart enough to calculate the offset, although it has all of the neccessary information.&lt;BR /&gt;&lt;BR /&gt;In my opinion, Mac's code is more understandable and would be the method that I would prefer if I wasn't concerned with a couple of extra cycles.&lt;BR /&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2007 09:15:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problem-with-copy-routine-for-HCS08-and-CW-5-1/m-p/135736#M1771</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2007-06-05T09:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with copy routine</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problem-with-copy-routine-for-HCS08-and-CW-5-1/m-p/135737#M1772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello Ralph,&lt;/FONT&gt;&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;HR /&gt;&lt;FONT size="2"&gt;Ralph wrote:&lt;BR /&gt;. . . So a little note in the RM would have been good that this is not a good programming style.&lt;BR /&gt;&lt;/FONT&gt;&lt;HR /&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;FONT size="2"&gt;I now see to what you were referring -&lt;BR /&gt;&lt;BR /&gt;T&lt;/FONT&gt;&lt;FONT size="2"&gt;here are at least two instances, within the Reference Manual HCS08RMv1 (on page 137 and page 150), where programming samples are given that do not work for CW relocatable assembler, because of the "unknown" offset between the two different segments.&amp;nbsp; The samples would work as intended for absolute assembly (using ORG directives), and maybe for assemblers other than CW.&lt;BR /&gt;&lt;BR /&gt;However, because of the now&amp;nbsp;implicit assumption of the use of CW, the code samples given are probably inappropriate.&amp;nbsp; The use of indexed addressing could easily have been demonstrated using sample code that did not need to calculate the offset value at compile/link time.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Mac&lt;/FONT&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jun 2007 11:42:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problem-with-copy-routine-for-HCS08-and-CW-5-1/m-p/135737#M1772</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-06-12T11:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with copy routine</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problem-with-copy-routine-for-HCS08-and-CW-5-1/m-p/135738#M1773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hello Mac,&lt;BR /&gt;&lt;BR /&gt;sorry for my late reply, I was on vacation some days.&lt;BR /&gt;I think these examples are old ones which are copied from older manuals. I remember during my studies we played around with the 68332. In the TPU manual there were also programming examples given. They had some obvious mistakes and could therefore not be compiled and this was never corrected.&lt;BR /&gt;&lt;BR /&gt;I use your given method and it works fine, thanks for your help again!&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;&lt;BR /&gt;Ralph&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jun 2007 22:25:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problem-with-copy-routine-for-HCS08-and-CW-5-1/m-p/135738#M1773</guid>
      <dc:creator>Ralph</dc:creator>
      <dc:date>2007-06-21T22:25:26Z</dc:date>
    </item>
  </channel>
</rss>

