This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to avoid the switch code

I have the impression that the routine that process a switch statement is (justifiably?) complicated and slow.

I have a case with a lot of case statements.

To "help the compiler" the cases are 0, 2, 4... to allow the use of JMP @a+dptr.

I can see a way of going to a51 for the switch and then back to c for the code, but that would be almost unreadable.

Has anyone found a fast and readable way to do something like this?

Erik

  • I have the impression that the routine that process a switch statement is (justifiably?) complicated and slow.

    There are three different ways the compiler generates switch/case blocks. The method used depends on the number and structure of the cases.

    The compiler only uses a library routine when it cannot determine the structure of the case values.

    Refer to http://www.keil.com/support/docs/1316.htm for more detail on how to get the compiler to generate a jump table.

    Jon