Changing position of program code


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    I know about the compiler warnings. I have now re-arranged some code and removed a subroutine, it is now 4.7k and does not have problems.
    Thanks for the comments.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink You are not dreaming !!!

    Hi, Aerostar

    I've already noted some troubles as you describe ... diseappearing when subs are re-arranged !!!

    Generally when subroutines are placed at the end of the program , not so far from boundary limits ... ( If - Then tests not working i.e. )

    I wrote a thread about that in those columns ... but no definitive answer !!!

    Can't find a satisfying explanation to that ...

    Alain
    Last edited by Acetronics2; - 13th December 2006 at 12:35.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics
    Hi, Aerostar

    I've already noted some troubles as you describe ... diseappearing when subs are re-arranged !!!

    Generally when subroutines are placed at the end of the program , not so far from boundary limits ... ( If - Then tests not working i.e. )

    I wrote a thread about that in those columns ... but no definitive answer !!!

    Can't find a satisfying explanation to that ...

    Alain

    Now that's different...I've always put my sub's at the beginning of the program and jumped over them and haven't had a problem. Huh... even more unsatisfying isn't it?
    JDG

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default

    On older version of PBP there was an issue with the placement of sub's. I think it was prior to 2.32. After that there was no limit as to where one can put his sub's. BUT, I found that rearranging the subs, there was a great improvment on the final code size.

    I suppose this is explained considering the boundary limits and the asm commands used by the compiler.

    Ioannis

  5. #5
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    So in this case, where do we put the subs then?

    Based on what criteria do we arrange the subs?


    ---------------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default

    Hi Sayzer. Well, now there is no official directive as to where is better placed a sub. According to old practice, on top. But this does not affect in any way the execution.

    I only pointed out that if one has 5 sub's for example, and have different sizes, rearranging the order of them is affecting the final code size. I think is because a bigger sub might fall between two pages while others won't.

    After a little experimenting you can find that your code might reduce up to 20% or more! Also if you change your variables to be placed on BANK0 also may help. Especially if there are arrays in the program. I had a program reduced from 7540 bytes to 6200 using the above!

    Ioannis

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink THE Basic weakness ...

    Hi, Sayzer

    You meet here The big Basic Programmer's lack of project definition ...

    Basic enables you lots of jumps and come back ... But the first thing is to write a neat logical organigram ...

    Like It was to be done with "old dinausaurs " programming langages like Fortran ...

    So, the thing to do is put the job in a correct order to have the minimum GOTOs and GOSUBs ...

    No so easy ... when the project grows more and more !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. DS1307 and a LED array, need ideas
    By peu in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 30th December 2009, 18:45
  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. Code: Why is this code greater than 2000 words?
    By DrDreas in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 1st June 2007, 19:51
  5. Replies: 7
    Last Post: - 25th July 2006, 15:11

Members who have read this thread : 0

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