This Include File can measure the size of any block of code, it can provide information about the size of the PBP Library, User code size (excluding the Library), Total code size, and various individual blocks of code and those blocks can now be nested. And best of all, it displays the information in the MicroCode Studio results window, instead of having to dig thru the .LST file.
Using it looks something like this ...
From that you can see that the LCDOUT command used 42 WORDs.
But, there are 2 parts to the amount of code used with PBP. The other part is the Library. By adding a LibrarySize command, you can see how much library code the LCDOUT command used. The UserSize command shows the total amount of User Code used (everything but the Library). And TotalSize is the size of everything (including the Library).
Those results show that along with the 42 words of code used by the LCDOUT statement, 107 words were added to the library. That code only gets added once. If you use another LCDOUT statement, it only adds the code used by the statement itself, and nothing more gets added to the library.
StartSize and EndSize are given 'Unique names and both MUST match exactly (case sensitive). Start/End segments can be "Nested" or they can "Overlap", doesn't really matter.
INCLUDE "CodeSize.pbp" DEFINE Measure 1 row VAR BYTE temp VAR BYTE @ StartSize(Select) SELECT CASE row @ StartSize(Case1) CASE 1 : temp = $80 @ EndSize(Case1) CASE 2 : temp = $C0 CASE 3 : temp = $90 CASE 4 : temp = $D0 END SELECT @ EndSize(Select) @ StartSize(Lookup) LOOKUP row,[$80,$80,$C0,$90,$D0],temp @ EndSize(Lookup) @ LibrarySize
Which gives these results ...
And now you can see that the Lookup statement took half as much code space as the Select to do the same job. Neither the SELECT CASE or LOOKUP statements added any code to the Library, so it shows 1 WORD (goto INIT).
When using either UserSize or TotalSize, they MUST be the LAST lines in the program.
It will work with any 18F or 14-bit chip. With 18F's it displays results in both BYTEs and WORDs, and the result may differ from the size reported by MPASM because MPASM includes Config words in the total, and doesn't count locations that were skipped with ORG statements. This program shows the Real size.
These routines DO NOT use any code space (flash) or variable space (RAM). So you can safely include it in your program and simply turn it ON/OFF whenever desired.
The results can be turned On/Off by either commenting the DEFINE Measure 1 line, or changing its value to 0. When it's turned off, no messages will be displayed.
Download the file below and un-zip it to your PBP folder (the one with PBPW.EXE or PBPX.EXE). There is only 1 file in the .zip "CodeSize.pbp".
File to Download:
CodeSize