Greetings All,

Please forgive me for crossposting the following (it's also posted to the 
newsgroup codewarrior.palm), but I wanted to get maximum exposure to this. 
Also I was curious if PODS 1.1 can handle these types of huge switch 
statements without choking...

-------------------

I've come across a somewhat disappointing problem with CW9.3 with regards to 
PNO development that I was hoping someone might know a workaround for. Let's 
say I was given a 10-bit integer X that I wanted to do a switch on for all 
1024 cases. Setting this up as a jump table in C is easily done:

switch (X & 0x3ff)
{
    case 0: do_something_0... ;  break;
    case 1: do_something_1... ;  break;
   ...
    case 1023: do_something_1023 ;  break;
}

The PNO compiler of CW 9.3 correctly converts this to an efficient 
pc-relative jump table without much effort.

The problem that I'm seeing is if this jump table is extended to encompass a 
13-bit integer (8192 unique cases) or larger. The PNO compiler in CW9.3 
chokes on this totally, regardless of the complexity of the 
do_something_xxxx entries. They could be as simple as adding 1 to a local 
variable, and the compiler will still choke to the point of crashing 
completely and bringing the CW IDE down with it.

I tried to do a work around with inline assembly as follows:

void assmebly_jump_table(UInt16 X)
{
    asm
    {
        : assembly code to set up a pc_relative jump to a table of branches 
to C code
        b case_0
        b case_1
        ...
        b case_8191
    }

    case_0: do_something_0... ; goto jump_end;
    case_1: do_something_1... ; goto jump_end;
    ...
    case 8192: do_something_8191... ; goto jump_end;


jump_end:
    do_finish_up_code;
    return;
}

The compiler can handle the large inline assembly portion just fine, but 
then I encounter a different problem with the PNO compiler. Since the 
compiler essentially ignores everything that happens in the inline assembly 
portion of the function with regards to how it compiles the C code, it never 
sees all the different branches to each code case. Since it isn't aware that 
there is a possibility of branching to anything other than the case_0, it 
dead strips all remaining cases, and I can't figure out a way to keep it 
from doing this...

So anyway, after all that, does anyone have any idea how t get around this?

Regards,
-Robert Hildinger
rh_public AT mobilevoodoo DOT com



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to