If you want to shrink your code, the best way is to see if you can use the internal ressource instead of the PBP pre-made function.
By example, instead of using ADCIN, write/read directly to the register, same for HSEROUT, HSERIN and how much others.
For a simple HSEROUT
compile 89 wordsCode:DEFINE LOADER_USED 1 DEFINE OSC 20 RCSTA =$90 TXSTA =$24 SPBRG= 129 ' 9600 Bauds aVar var BYTE[7] a var byte avar[0]="H" avar[1]="E" avar[2]="L" avar[3]="L" avar[4]="O" AVAR[5]=13 AVAR[6]=10 A=0 start: REPEAT TXREG=AVAR[A] NotEmpty: if TXSTA.1=0 then notempty A=A+1 UNTIL A=7 A=0 PAUSE 500 goto start
compile 103 words.Code:DEFINE LOADER_USED 1 DEFINE OSC 20 RCSTA =$90 TXSTA =$24 SPBRG= 129 ' 9600 Bauds aVar var BYTE[7] avar[0]="H" avar[1]="E" avar[2]="L" avar[3]="L" avar[4]="O" AVAR[5]=13 AVAR[6]=10 start: HSEROUT[STR AVAR] PAUSE 500 goto start
almost the same as the previous but using PBP DEFINE HSER compile 95 wordsCode:DEFINE LOADER_USED 1 DEFINE OSC 20 DEFINE HSER_RCSTA 90h DEFINE HSER_TXSTA 24h DEFINE HSER_SPBRG 129 ' 9600 Bauds aVar var BYTE[7] avar[0]="H" avar[1]="E" avar[2]="L" avar[3]="L" avar[4]="O" AVAR[5]=13 AVAR[6]=10 start: HSEROUT[STR AVAR] PAUSE 500 goto start
No big improvement so far... i should find a better example next time
BTW it's always case by case. Scroll your program and look wich statement you call the most, do a SUB with them and TADA. Just be sure to avoid too much nested gosub and it should gives you good results.
BUT there's always a midpoint between a readable code, and a tight one. Choose your own comfort zone and work with.





Bookmarks