I was recently wondering why my program got so big, so here's a bash line which 
will give a number which can be sometimes interesting:

cat MyProgram.asm | grep " db " | cut -d 0 -f 2- | fold -1 | grep -c x

It outputs the number of bytes used in constant tables (for PIC18 cores, for 
smaller cores this line would have to be modified).


print_string(serial,"This is a text I will output again.")
print_string(serial,"This is a text I will output again.")
print_string(serial,"This is a text I will output again.")
print_string(serial,"This is a text I will output again.")
print_string(serial,"This is a text I will output again.")

This piece of code generates five tables in flash memory, all containing the 
same data. While it is convenient, it is more efficient to declare a constant:

const byte repeat_text[]="This is a text I will output again."


print_string(serial,repeat_text)
print_string(serial,repeat_text)
print_string(serial,repeat_text)
print_string(serial,repeat_text)
print_string(serial,repeat_text)


This second version saves a lot of code memory. 


Using the bash line above, you can get a hint if it could be worth to search 
for such possible optimizations in your program.

Greets,
Kiste

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/jallib?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to