Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

lookup table in hitech C compiler

Status
Not open for further replies.

ismu

Full Member level 2
Full Member level 2
Joined
May 12, 2009
Messages
145
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Location
nil
Activity points
2,340
i want to add 1024 nos of integer in to a look up table , i used as


const unsigned int look[1024]={0x1234,0x2EF3,0x3FFF,........};

So in hex its should be near to 1kB+some Byte size ,but actually my code size is came as 2KB+som byte , if am using integer size as 2048 then code size is coming 4KB ,


please help me how can i reduce the code size
 

You are storing 16 bit integers (so 2 bytes per value), what size would you expect a 1024 element array of 16 bit values to be?

An similar array of unsigned char would occupy 1KiB, but you wont fit 2EF3 in a unsigned char on any common processor (Some DSP have 32 bit words for char, short and it but you clearly are not using such).

Regards, Dan.
 
  • Like
Reactions: ismu

    ismu

    Points: 2
    Helpful Answer Positive Rating
PIC16F73 flash is 4K words ,
i compiled my code so now code side is 1K words ,
After this i did add below lookup table:

Code:
constant unsigned int look[1024] = {0x1234,  0x2EF3,  0x3FFF,........};

and compiled it , so now code size 3K words ,
Actually 1024 nos of cont int should be = 1K words
prevoius code size =1K words
so totally =2K words should be there, but it showing 3K words [1K for prevous +2K for cont =3K].
i checked the hex file , in that they arraigned all constat as :
....................
...................
.................
3412 3434 342E 34F3 343F 34FF 3476 3420
3407 3411 3428 3430 34F7 3400 3476 3420
3407 3415 3408 3430 34F7 3400 3476 3420
3487 3410 3450 3430 34F7 3400 3476 3420
3487 3414 3408 3430 34F7 3400 3476 3420
3407 3411 3450 3430 34F7 3400 3476 3420
3407 3415 3408 3430 34F7 3400 3476 3420
3487 3410 348C 3430 34F7 3400 3476 3420
3487 3414 3408 3430 34F7 3400 3476 3420
3407 3411 348C 3430 34F7 3400 3476 3420
3407 3415 3408 3430 34F7 3400 3476 3420
342E 3410 3431 3416 3486 341B 3451 3429

.............
.......
...
.

ion this first two byte 34 is commen for all actual intruction command for 34 is "retlw" ,,
ie 0x3412 is retlw 0x12 ;
like this they are using retlw for all content int , i think thats why the code size is taking double size
is ther any way reduce the size ?
 
Last edited by a moderator:

Code size reduction may not be rendered directly on executable code, once refers solely to a specific formatting for store binary code that will be stored on program memory. You must take more information about data nature that will be loaded into that array, in order to check if there exists some cross-corelation which could allow apply some kind of compress encoding.



+++
 

As far as I know the only way to read data from code space in a PIC16, like in a table, is to use the retlw xx instruction. At least it was in the old days, it may be changed in the newer versions of the PIC16.

This mean one word for each byte you want to retrieve.
 

Yep, the small pics always were a bit of an odd cousin to anything sane out there, they are basically harvard architecture with very limited ways to cross the data/code divide, retlw being the standard one for this useage.

Best bet might be seeing if you can generate the required numbers either in software or by using something like run length or huffman coding on a smaller table of inputs (The dictionary can be precomputed of course).

Regards, Dan.
 
  • Like
Reactions: ismu

    ismu

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top