Ahhh... the LOOKUP and LOOKUP2 statements impliment the RETLW method for you. Lots cleaner.

Several problems: LOOKUP2 will return words, but has a limit of 85 values (and wastes 50% more room then LOOKUP). LOOKUP1 will fit 255 values, but they are only a byte each (but 1 byte takes 1 program location).

255 is usefull, but 256 would be lots nicer. Using 255 locations just need a work-around for the 256th value, simple in a SELECT-CASE form.

SO... not the worst, each value gets looked up for it's exact value. You would expect 1024 word lookups to fit in 2K of program memory.

Ready for it?

BUT !!!

The LOOKUP statement needs to start on a even 256 address boundary (don't ask why, it's an assembler issue). To do this, PBP seems to just waste code space till it gets to the next boundary.

I tried a sample program compiled for a PIC16F88, which has a 4K word codespace. The program did not fit. I looked at the disassembly I saw the problem was with this wasted codespace.

Since you have 125K it will fit, and hopefully you can accept the wasted space (basically, you'll need 2:1 to fit the lookups).

Sample code:

Code:
    D2A_Result      var word    ' raw data from D2A conversion
    D2A_Conversion  var word    ' converted result
    ' read the D2A, place Result in D2A_result
    
    select case  D2A_result 
        case is <256
            lookup D2A_result.byte0,                     _
                [$00, $00, $00, $00, $00, $00, $00, $00, _  ' 0-7 lo bytes
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 8-15 lo bytes
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 16
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 24
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 32
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 40
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 48
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 56
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 64
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 72
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 80
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 88
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 96
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 104
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 112
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 120
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 128
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 136
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 144
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 152
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 160
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 168
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 176
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 184
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 192
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 200
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 208
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 216
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 224
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 232 
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 240
                 $00, $00, $00, $00, $00, $00, $00],     _  ' 248 - 255
                D2A_Conversion.byte0
            lookup D2A_result.byte0,                     _
                [$00, $00, $00, $00, $00, $00, $00, $00, _  ' 0-7 hi bytes
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 8
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 16
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 24
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 32
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 40
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 48
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 56
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 64
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 72
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 80
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 88
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 96
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 104
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 112
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 120
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 128
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 136
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 144
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 152
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 160
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 168
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 176
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 184
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 192
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 200
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 208
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 216
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 224
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 232 
                 $00, $00, $00, $00, $00, $00, $00, $00, _  ' 240
                 $00, $00, $00, $00, $00, $00, $00],     _  ' 248 - 255
                D2A_Conversion.byte1
        case 256
            D2A_Conversion.byte0 = $00
            D2A_Conversion.byte1 = $00
        case is < 512
            ' same as before, 2 LOOKUP tables
        case 512
            D2A_Conversion.byte0 = $00
            D2A_Conversion.byte1 = $00
        case is < 768
            ' same as before, 2 LOOKUP tables
        case 768
            D2A_Conversion.byte0 = $00
            D2A_Conversion.byte1 = $00
        case else
            ' this case handles 769 to 1023
            ' same as before, 2 LOOKUP tables
    end select
If you do run out of codespace, let me know and I'll help with some asm code for this.