code size VS speed optimization setting?


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429

    Default code size VS speed optimization setting?

    Does PBP have a code size vs. speed optimization setting? I know some compilers have this option but I wasn't sure about PBP.

    Basically i need the compiled code to be as small as possible, but execution speed isn't overly critical.

    Is there a setting for this?

    Thanks
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I have never heard of a setting like for that. I think it all depends on the person using the keyboard.

    Small code is done with many sub routines. Say you are using an ADC. If you need to read the ADC many times, have a GOSUB or GOTO a LABEL with everything in that routine instead of rewriting it several times. If that routine has five lines to read the ADC and write it to EEPROM or some place else, then the one GUSUB here and there will end up saving some lines of code. In other words, do not repeat yourself.
    HTH
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    yeah ive written a program nearly 3000 lines long, and ive hit the end of the 32k of code space my PIC has. I pulled all the strings out into EEPROM and that saved some space, but im likely to run out again soon. I've done the most obvious things to save space.

    *edit* i guess the only thing left to do is go thru all 3000 lines looking for where i can make it more efficient... *sigh* that will be a chore
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Just a thought...
    Move some of the routines over to another PIC, Maybe something that has some heavy calculations. PIC#1 sends data to PIC#2 for calcs, when finished PIC#2 sends data back to PIC#1. Sort of like an interrupt.
    Dave
    Always wear safety glasses while programming.

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kamikaze47 View Post
    yeah ive written a program nearly 3000 lines long, and ive hit the end of the 32k of code space my PIC has. I pulled all the strings out into EEPROM and that saved some space, but im likely to run out again soon. I've done the most obvious things to save space.
    *edit* i guess the only thing left to do is go thru all 3000 lines looking for where i can make it more efficient... *sigh* that will be a chore
    Have you tried moving the most commonly used variables to BANK 0? (only applies if you're using a 16Fxxx series PIC, doesn't do anything on an 18Fxxx series)

  6. #6
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    using an 18F4550

    I would just get a pic with more code space. but i need the USB functionality of the 4550.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kamikaze47 View Post
    using an 18F4550
    I would just get a pic with more code space. but i need the USB functionality of the 4550.
    Repeat...Until uses less space than a For...Next, about 3 bytes for each one...

    Multiplies and Divides by power's of 2 can be replaced by shifts << and >> ...

    For...Next loop that are (for instance) "0 to 7" take up less space than "1 to 8", again, only a few worth...

  8. #8
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    thanks for the tips

    i'll go thru my code

    *cringe*
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

Similar Threads

  1. decoding quadrature encoders
    By ice in forum mel PIC BASIC Pro
    Replies: 93
    Last Post: - 28th February 2017, 09:02
  2. Problem runing my code
    By Mus.me in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 1st December 2009, 20:36
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  4. pic18F code size problem???
    By dogi in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 7th March 2005, 21:52
  5. Need help, high speed D/A converter, see code
    By rpatel in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 20th December 2004, 01:33

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