Subroutine placement - must they come first?


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: Subroutine placement - must they come first?

    My ignorance is on clear display here so please be gentle.
    I have a system of two PIC16F88 and three 18F4620 which all chatter amongst themselves over a multiwire parallel bus. Some of the code takes up over 63000 bytes on a PIC 18F4620.
    Currently all the subroutines are placed after the hardware and variable declarations. I would like to have the subroutines at the bottom of the code if possible for simpler reading.

    I recall some earlier (PBP2.xx?) comments that subroutines should be at the top of the program but is there any more explicit advise for the 16F88 or the 18F4620. Bruce's comments pass over my head.

    Cheers
    BrianT

  2. #2
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Subroutine placement - must they come first?

    You can put subroutines anywhere you like and PBP worries about page swaps for you. If, however, you have real time or compiled code size issues, putting them at the beginning can help optimize. There are also special issues when crossing page boundaries that PBP *usually" takes care of - a notable exception is mentioned above.

    I always put my subroutines at the end for readability. in 99% of cases this is fine.
    These days I like to use 18F parts which tend to have a better sense of humour about these things, as well as usually being faster and having more memory. (at slightly highter cost)

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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