Searching \ for 'PIC code squeezing (was: detecting dead PIC code s' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'PIC code squeezing (was: detecting dead PIC code s'.

Truncated match.
PICList Thread
'PIC code squeezing (was: detecting dead PIC code s'
1998\03\31@072924 by wwl

picon face
>> Greetings,
>>         Well, I have managed to completely fill a PIC14000 and
>> am now looking through the listings trying to find dead code
>> segments -- like floating point subroutines that are never
>> called and can be commented out of the code to reclaim more
>> space.
Here are a few of my favorite 'instant' code-squeezing methods, none
of which require a great deal of analysis of code (and therefore
useful when going back to code written a long time ago & trying to
squeeze a few small mods..).

Any sequence of
call xxx
movlw yyy
can usually be shrunk by omitting the MOVLW and RETLW'ing yyy in
subroutine xxx (obviously as long as other calls don't use a returned
W value from that routine). Obviously if the same value of yyy is used
more than once, use this value so you can lose more than one MOVLW.

Any sequence of more than two  instructions which is used more than
once can be shortened by putting it in a subroutine - the code
structure may not look pretty but when you're that short of space,
ANYTHING GOES & to hell with pretttiness! Remember that putting it in
a subroutine also allows the RETLW trick above.
This is very amenable to someone writing a utility to search and
tabulate all such repeats - any takers?

Any subroutine which is called only once can usually be put in-line
(see comment above regarding structure!) . If you want it to be more
readable, put the code in a macro.

Remember that some SFRs and bits in SFRs can often be used as RAM -
ADRES is my usual favorite, as  it only gets overwritten by an adc
conversion.

I'm probably stating the obvious to most programmers, but just in
case... (and this applies to almost any processor)- any code that goes

call xxx
return
can be replaced by
goto xxx


    ____                                                           ____
  _/ L_/  Mike Harrison / White Wing Logic / spam_OUTwwlTakeThisOuTspamnetcomuk.co.uk  _/ L_/
_/ W_/  Hardware & Software design / PCB Design / Consultancy  _/ W_/
/_W_/  Industrial / Computer Peripherals / Hazardous Area      /_W_/


'PIC code squeezing (was: detecting dead PIC code s'
1998\04\08@081647 by Larry G. Nelson Sr.
flavicon
face
At 12:31 PM 3/31/98 GMT, you wrote:
>>> Greetings,
>>>         Well, I have managed to completely fill a PIC14000 and
>>> am now looking through the listings trying to find dead code
>>> segments -- like floating point subroutines that are never
>>> called and can be commented out of the code to reclaim more
>>> space.
>Here are a few of my favorite 'instant' code-squeezing methods, none
>of which require a great deal of analysis of code (and therefore

Another trick is to use goto $+1 in place of 2 nop instructions in a row
used to generate a 2 instruction delay.
Larry G. Nelson Sr.
.....L.NelsonKILLspamspam@spam@ieee.org
http://www.ultranet.com/~nr

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...