How much code space do PBP statements use.


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Nice catch Darrel. Will be really handy for me
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    Join Date
    Jul 2005
    Posts
    65


    Did you find this post helpful? Yes | No

    Thumbs up

    Hey Darrel

    Its really nice one

    If mecanique saw this code, it will be easy to add those nice green bars as in Proton IDE... Any way, may be they haven't seen code yet

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default CodeSize - Update

    Version 2.0

    This include file adds several more abilities to the idea in post#1.   MPASM Required

    Along with measuring the size of a 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 result in the MicroCode Studio window, instead of having to dig thru the .LST file.


    Using a similar example to post#1 ...
    It looks something like this ...

    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3134" /> <!-- Name:  Test1.JPG
Views: 5384
Size:  50.5 KB -->

    From that you can see that the LCDOUT command used 42 WORDs.

    But again, there are 2 parts to 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).

    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3135" /> <!-- Name:  Test2.JPG
Views: 5654
Size:  65.5 KB -->

    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.

    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.

    Code:
    INCLUDE &quot;CodeSize.pbp&quot;
    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 ...

    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3136" /> <!-- Name:  Results3.JPG
Views: 5267
Size:  26.8 KB -->

    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.

    Download the file below and un-zip it to your PBP folder (the one with PBPW.EXE).
    There is only 1 file in the .zip "CodeSize.pbp".
    Attached Files Attached Files
    Last edited by ScaleRobotics; - 3rd March 2012 at 17:03.
    DT

  4. #4
    Join Date
    Feb 2009
    Location
    Southern California
    Posts
    86


    Did you find this post helpful? Yes | No

    Default

    Great piece of code, I just tried it out and got a slightly different result than expected based on your screen shots. After compiling my Results box showed the results for both words and bytes.



    I figured you upgraded the program since you took the shots and actually considered modifying your program to allow a "DEFINE Measure 2" to allow just the words to be displayed. While poking around your file I realized your code already allows for both types of display based on if BSR was defined. I'm not clear on what this is or why my code meets the requirements. Could you explain it to me. I could easily just change it to print what I want, but wanted to understand it more.

    I'm getting ready for a major code overhaul using your interrupts, so I'm sure you'll be hearing from me again. (By getting ready I mean doing everything I can think of short of actually starting to code including spending most of the last 3-4 days reading every thread on this list I can find relating to my needs.)

    Thanks, David

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    It's because you're using a 18F and compilation method/results may differ a little bit Between 16F and 18F as they don't have the same Library, not the same instruction set/core too + something that I missed
    Last edited by mister_e; - 13th February 2009 at 22:38.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 09:26
  2. Changing Swordfish code to PBP
    By Ron Marcus in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 29th April 2008, 02:28
  3. 4 Chanel Dmx512 ready assembly code to PBP ?
    By syscoder in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 22nd March 2007, 00:55
  4. Compiler differences between PBP 2.33 & 2.46
    By nikopolis in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd May 2006, 20:01
  5. Need more code space
    By ghutchison in forum General
    Replies: 1
    Last Post: - 12th February 2005, 21:54

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts