The CCS compiler for mid-range PICs seems to fail with constant lookup tables that span more than 256 bytes. Here is an example for the PIC
16C73B:const int16 PTable[] = {1,2,3... //256 16-bit entries, compiles to:
0059: BCF 0A.0 005A: BCF 0A.1 005B: BCF 0A.2 ;clearing low 3 bits of PCLATH 005C: ADDLW 60 ;add index to table base address 005D: BTFSC 03.0 ;check for carry from previous addition 005E: INCF 0A,F ;handle crossing one page boundary 005F: MOVWF 02 ;computed goto by setting PC from PCL and PCLATH 0060: RETLW 01 0061: RETLW 00 ;PTable[0] = 0001 0062: RETLW 02 0063: RETLW 00 ;PTable[1] = 0002 0064: RETLW 03 0065: RETLW 00 ;PTable[2] = 0003As you can see, the table access code only handles crossing one page boundary. But if PTable has more than 128 elements, there will be at least two page boundaries to cross. The code that calls this access function just loads the index times two into the w register and calls
0059. No provision is made for overflow in this shift, even if the index is an int16.I don't mind doing my own #ASM version of table lookup, but I can't find out how to take the code address as a literal in CCS in-line assembler, so I am sort of stumped.
-Robert Scott Ypsilanti, Michigan (Reply through this forum, not by direct e-mail to me, as automatic reply address is fake.)