Compiler problem with large table Switch statements

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Compiler problem with large table Switch statements

ソリューションへジャンプ
910件の閲覧回数
jwp
Contributor I

Hi All

 

First post here, so hopefully I'm doing this right?! :-)

 

this may be me being stupid (entirely possible!), but I'm having a problem with using Switch on tables of greater than 256 bytes

 

This is using the latest (just downloaded) version of Codewarrior and 'C' of course...

 

To explain...

 

I have a look up table which is 448 rows deep and 5 bytes wide (2,240 bytes in all)... it looks like this...

 

unsigned char const IncTable [448] [5] =

{

EBeep,EBeep,EBeep,EHorn,0,

EBeep,EBeep,EHorn,EHorn,1,

EBeep,EBeep,EAux,EHorn,0,

EBeep,EBeep,EHnAx,EHorn,1,

EBeep,EBeep,EWait,EHorn,0,

EBeep,EBeep,ELoop,EHorn,0,

EBeep,EBeep,ELPxx,EHorn,0

EBeep,EBeep,EStop,EHorn,0,

EBeep,EHorn,EBeep,EAux,0,

EBeep,EHorn,EHorn,EAux,0,

EBeep,EHorn,EAux,EAux,1,

 

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.

 

This is my switch statement (Where EVinTab is a worked out offset)...

 

switch (IncTable [EVinTab] [3])

{

case EBeep:

break;

 

etc

 

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.  Go figure.

 

If I make the table unsigned shorts it all works fine, but why should I need to do that?  I don't really have the memory to give a table of bytes twice

the allocated storage to get the compiler to work correctly.  I don't see why I should have to do that either. ATEOTD it's a big table of single bytes,

surely they don't need to be defined as shorts for the compiler to figure out to use 16bit math?

 

Any thoughts gratefully received.

 

Best

 

John

ラベル(1)
0 件の賞賛
返信
1 解決策
773件の閲覧回数
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello John:

Can you specify what MCU device and CodeWarrior version are you using? This information serves to investigate the problem.

Regards!

Jorge Gonzalez

元の投稿で解決策を見る

0 件の賞賛
返信
1 返信
774件の閲覧回数
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello John:

Can you specify what MCU device and CodeWarrior version are you using? This information serves to investigate the problem.

Regards!

Jorge Gonzalez

0 件の賞賛
返信