Changing position of program code


Closed Thread
Results 1 to 18 of 18
  1. #1

    Default Changing position of program code

    I want to start some code at a page boundary, I cannot see a command in PBPRO to do this, I am using PB2.43, 16f876a, and there does not seem to be anything after using the search in this and the old list. Perhaps I am not putting in the correct words !.

    eg code
    org 1000h
    code

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


    Did you find this post helpful? Yes | No

    Default

    It's kinda dangerous but you can use

    @ ORG 1000h
    your code here
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    Why someone would want to start a code at page boundary?

    May be I need to learn that.

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

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Thanks for the reply, I will try it out tomorrow.

    I am trying to debug some code which appears to fall over around the 1000h boundary, so by making some of the code start after the boundary and not cross it I can then perhaps make a more educated guess as to what I have done wrong.

  5. #5
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aerostar
    Thanks for the reply, I will try it out tomorrow.

    I am trying to debug some code which appears to fall over around the 1000h boundary, so by making some of the code start after the boundary and not cross it I can then perhaps make a more educated guess as to what I have done wrong.
    Do you have any BRANCH instructions in there ?
    Keith

    www.diyha.co.uk
    www.kat5.tv

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aerostar
    Thanks for the reply, I will try it out tomorrow.

    I am trying to debug some code which appears to fall over around the 1000h boundary, so by making some of the code start after the boundary and not cross it I can then perhaps make a more educated guess as to what I have done wrong.

    If you're getting the 'cross page boundary' warning, that's all it is... a warning. PBP takes care of business for you.
    Nothing to worry about.
    JDG

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Yea, why?

    Quote Originally Posted by sayzer
    Why someone would want to start a code at page boundary?

    May be I need to learn that.

    ---------------------
    I gotta parrot sayzer, why is that important? Are you trying to find out what code to leave off in order to use a pic with less space?
    JS.


    Curiousity killed the cat
    Satisfaction brought him back.

  8. #8


    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.

  9. #9
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    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 " !!!
    *****************************************

  10. #10
    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

  11. #11
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    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

  12. #12
    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

  13. #13
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    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

  14. #14
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    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 " !!!
    *****************************************

  15. #15
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    Did you find this post helpful? Yes | No

    Default

    Just a note: what I described at #13 has nothing to do with GOTO's. Just the order of the sub's. If this is going on top of the other has an immediate impact on code size produced.

    Ioannis

  16. #16
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Cool ahhhh

    Hi Ioannis,acetronics,
    I knew aerostar had a reason, now I know why. I learned something again today! Thanks,
    JS


    edit
    FORTRAN ? Now we're talkin OLD I remember studying my dad's fortran manuals in 1968? I think Dr. Peabody used that to program the wayback machine!

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics
    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

    I always thought that programming structure addresses a programmer who is looking at the code from outside. So that when you write a code, another programmer from outside can understand your coding and logic relatively easier.

    If you write a code that is mixed all over, a new comer will not understand the logic flow.

    But, despite all, now, I learn that the structure also has a direct effect on the code size.

    I just made some tests, moved the subs around in a code.
    The code size indeed drops.


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

  18. #18
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    Did you find this post helpful? Yes | No

    Default

    I know what I will suggest is not much of a help, but generally the big sub's is better to be placed on top of each memory page. If you cannot find how long a sub may take, then compile it in a new program file, after compilation check the length and move the sub to a better position at the final program.

    Then the rest of the page can be filled with a smaller sub.

    If anyone has a better suggestion, please, one step forward.

    Ioannis

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 : 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