PreviousNext
Computed goto with a table limit
Help > Appendix > Code Optimization > Computed goto with a table limit

FLASH-                        RAM-               Speed+

 

void  Table ( uns8 index @ W )
{

#define MAX   2


  // Is index @ W > MAX?
  index = MAX - index;
  if ( !Carry )
       return;     // Above table limit

 

  skip( index );   // Reverse order because of previous subtraction
#pragma computedGoto 1

  goto _label2;    // or e.g. return 0xEF

  goto _label1;    // or e.g. return 0xCD
  goto _label0;    // or e.g. return 0xAB
#pragma computedGoto 0

 

label0: // If the last used label is the 1st one then one goto instruction is avoided

...