<?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>CodeWarrior for MCUのトピックCompiler problem with large table Switch statements</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Compiler-problem-with-large-table-Switch-statements/m-p/317435#M10959</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First post here, so hopefully I'm doing this right?! :-)&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this may be me being stupid (entirely possible!), but I'm having a problem with using Switch on tables of greater than 256 bytes&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is using the latest (just downloaded) version of Codewarrior and 'C' of course...&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To explain...&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a look up table which is 448 rows deep and 5 bytes wide (2,240 bytes in all)... it looks like this...&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;unsigned char const IncTable [448] [5] = &lt;/P&gt;&lt;P&gt;{ &lt;/P&gt;&lt;P&gt;EBeep,EBeep,EBeep,EHorn,0,&lt;/P&gt;&lt;P&gt;EBeep,EBeep,EHorn,EHorn,1,&lt;/P&gt;&lt;P&gt;EBeep,EBeep,EAux,EHorn,0,&lt;/P&gt;&lt;P&gt;EBeep,EBeep,EHnAx,EHorn,1,&lt;/P&gt;&lt;P&gt;EBeep,EBeep,EWait,EHorn,0,&lt;/P&gt;&lt;P&gt;EBeep,EBeep,ELoop,EHorn,0,&lt;/P&gt;&lt;P&gt;EBeep,EBeep,ELPxx,EHorn,0&lt;/P&gt;&lt;P&gt;EBeep,EBeep,EStop,EHorn,0,&lt;/P&gt;&lt;P&gt;EBeep,EHorn,EBeep,EAux,0,&lt;/P&gt;&lt;P&gt;EBeep,EHorn,EHorn,EAux,0,&lt;/P&gt;&lt;P&gt;EBeep,EHorn,EAux,EAux,1,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;etc. FYI (not relevant, but to explain), the 1st three entries are what went before, now and after; the last two entries are what we then do.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my switch statement (Where EVinTab is a worked out offset)...&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt; switch (IncTable [EVinTab] [3])&lt;/P&gt;&lt;P&gt; {&lt;/P&gt;&lt;P&gt; case EBeep:&lt;/P&gt;&lt;P&gt;break;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;etc&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, if I want a result residing in the first 256 bytes all is dandy. If it's a higher byte it vectors to the correct case statement but doesn't execute it.&amp;nbsp; Go figure.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I make the table unsigned shorts it all works fine, but why should I need to do that?&amp;nbsp; I don't really have the memory to give a table of bytes twice&lt;/P&gt;&lt;P&gt;the allocated storage to get the compiler to work correctly.&amp;nbsp; I don't see why I should have to do that either. ATEOTD it's a big table of single bytes,&lt;/P&gt;&lt;P&gt;surely they don't need to be defined as shorts for the compiler to figure out to use 16bit math?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thoughts gratefully received.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Jun 2014 15:05:10 GMT</pubDate>
    <dc:creator>jwp</dc:creator>
    <dc:date>2014-06-11T15:05:10Z</dc:date>
    <item>
      <title>Compiler problem with large table Switch statements</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Compiler-problem-with-large-table-Switch-statements/m-p/317435#M10959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First post here, so hopefully I'm doing this right?! :-)&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this may be me being stupid (entirely possible!), but I'm having a problem with using Switch on tables of greater than 256 bytes&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is using the latest (just downloaded) version of Codewarrior and 'C' of course...&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To explain...&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a look up table which is 448 rows deep and 5 bytes wide (2,240 bytes in all)... it looks like this...&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;unsigned char const IncTable [448] [5] = &lt;/P&gt;&lt;P&gt;{ &lt;/P&gt;&lt;P&gt;EBeep,EBeep,EBeep,EHorn,0,&lt;/P&gt;&lt;P&gt;EBeep,EBeep,EHorn,EHorn,1,&lt;/P&gt;&lt;P&gt;EBeep,EBeep,EAux,EHorn,0,&lt;/P&gt;&lt;P&gt;EBeep,EBeep,EHnAx,EHorn,1,&lt;/P&gt;&lt;P&gt;EBeep,EBeep,EWait,EHorn,0,&lt;/P&gt;&lt;P&gt;EBeep,EBeep,ELoop,EHorn,0,&lt;/P&gt;&lt;P&gt;EBeep,EBeep,ELPxx,EHorn,0&lt;/P&gt;&lt;P&gt;EBeep,EBeep,EStop,EHorn,0,&lt;/P&gt;&lt;P&gt;EBeep,EHorn,EBeep,EAux,0,&lt;/P&gt;&lt;P&gt;EBeep,EHorn,EHorn,EAux,0,&lt;/P&gt;&lt;P&gt;EBeep,EHorn,EAux,EAux,1,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;etc. FYI (not relevant, but to explain), the 1st three entries are what went before, now and after; the last two entries are what we then do.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my switch statement (Where EVinTab is a worked out offset)...&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt; switch (IncTable [EVinTab] [3])&lt;/P&gt;&lt;P&gt; {&lt;/P&gt;&lt;P&gt; case EBeep:&lt;/P&gt;&lt;P&gt;break;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;etc&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, if I want a result residing in the first 256 bytes all is dandy. If it's a higher byte it vectors to the correct case statement but doesn't execute it.&amp;nbsp; Go figure.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I make the table unsigned shorts it all works fine, but why should I need to do that?&amp;nbsp; I don't really have the memory to give a table of bytes twice&lt;/P&gt;&lt;P&gt;the allocated storage to get the compiler to work correctly.&amp;nbsp; I don't see why I should have to do that either. ATEOTD it's a big table of single bytes,&lt;/P&gt;&lt;P&gt;surely they don't need to be defined as shorts for the compiler to figure out to use 16bit math?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thoughts gratefully received.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jun 2014 15:05:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Compiler-problem-with-large-table-Switch-statements/m-p/317435#M10959</guid>
      <dc:creator>jwp</dc:creator>
      <dc:date>2014-06-11T15:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: Compiler problem with large table Switch statements</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Compiler-problem-with-large-table-Switch-statements/m-p/317436#M10960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello John:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you specify what MCU device and CodeWarrior version are you using? This information serves to investigate the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;Jorge Gonzalez&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jun 2014 00:00:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Compiler-problem-with-large-table-Switch-statements/m-p/317436#M10960</guid>
      <dc:creator>Jorge_Gonzalez</dc:creator>
      <dc:date>2014-06-12T00:00:41Z</dc:date>
    </item>
  </channel>
</rss>

