Jump to content

Search the Community

Showing results for tags 'pcl'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • PIC Embedded Programming
    • BoostC and Chameleon compilers programming
    • BoostC porting source code
    • BoostC++ compiler programming
    • BoostBasic compiler programming
    • Assembler programming PIC
    • Novo RTOS Programming
    • Hardware PIC
    • Enhancement Requests
    • Bug Reports

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL







Found 1 result

  1. How can I implement a very efficient "jump table" using BoostC? I am trying to implement a jump table equivalent to this (the code needs to be fast): pcl += value; goto label1; goto label2; goto label3; etc. I've run into several issues: 1. First I tried function pointers, but they generate bulky code so now I am just trying to add an offset to pcl which will skip to a goto 2. The compiler is removing what it thinks is "dead code" (after the first goto), even with optimization turned off ("-O0") 3. After it removes the "dead code" gotos, it sees unreachable code (the target code fragments) so it removes those also. I have tried this with BoostC 7.10, 7.051 and 7.04, with the same results. Target device is PIC16F1827, '1823, or '688, but I don't think that matters. O/S: Windows XP, but I don't think that matters. Below is my sample code: -------- //BoostC dead code removal can't be turned off //this happens with 7.10, 7.051 and 7.04 also (not tested prior to that) #include <system.h> //do not use this line for libraries typedef unsigned char uint8; #pragma OPTIMIZE "0" //this doesn't avoid "dead code" removal void main(void) { uint8 var1, var2; var1 = 1+2; //example; calculate jumptable offset here pcl += var1; //pclath is assumed to already be set correctly //the following statements are being removed even with optimization turned off: goto here1; goto here2; goto here3; goto here4; //below are example code fragments: here1: porta = 1; return; //the following are being removed unless a conditional "goto" to them is added elsewhere: here2: porta = 2; return; here3: porta = 3; return; here4: porta = 4; return; } -------- I can defeat the dead code removal by using code such as the following: if (never_zero == 0) goto here1; if (never_zero == 0) goto here2; if (never_zero == 0) goto here3; if (never_zero == 0) goto here4; but this is bulky because it takes 2 instructions for each jumptable entry, and it also needs a left-shift of the jumptable offset variable before it is added to pcl (which is even more overhead). This topic is related to an old post which implied that asm statements would help: http://forum.sourceb...p?showtopic=680 I tried using an asm block: asm { goto here1; goto here2; goto here3; goto here4; } and this preserves the jumptable itself, but the target code fragments are still being removed and then the linker complains that it cannot find the labels - linker error is: Internal Error: Unable to resolve label ID:268435717 - 0x10000105 Turning off linker optimization ("-O0") avoids this error, but that is a global switch and I do not wish to turn off optimization for the entire module. Any other suggestions of how to solve this? thanks don
  • Create New...