GOSUB to do a pause?


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2003
    Location
    San Diego
    Posts
    35

    Default GOSUB to do a pause?

    I have about 20 "PAUSE 20" calls in my program. If I change the code to do the pause with a gosub like this...
    *******************
    gosub time20

    time20:
    pause 20
    return
    ******************

    Do I gain code space in doing the pause with a sub and just calling it each time?

    Basically I need to know if the single "pause 20" is longer or shorter than using a "sub" to do the same simple task.

    Is the simple call of the pause 20 vs the gosub call + the going and returning really any shorter?

    Thanks,
    tcbcats

  2. #2
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello TCBcat,

    TBC>>Is the simple call of the pause 20 vs the gosub call + the going and returning really any shorter?<<

    You will not save code space. It may make your program easier to read...

    What you can do, is write a short program to do just that...

    If your gosube was doing more than just a "pause", then you have a greater chance of saving code space.

    It takes asm to place a marker, call a branch, and return to the marker. Since your subroutine is only doing one thing...."pause X" you lose.

    DWayne
    Last edited by Dwayne; - 11th August 2004 at 04:22.
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  3. #3
    Join Date
    Dec 2003
    Location
    San Diego
    Posts
    35


    Did you find this post helpful? Yes | No

    Smile Thanks for the info

    Thanks for the response....
    I thought the code space was almost the same since I was only doing the pause and nothing else.

    I'm not out of code space.... just needed to know if I was on the correct track..
    Cheers,
    tcbcats

  4. #4
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello TcBcats,

    TBC>>Thanks for the response....
    I thought the code space was almost the same since I was only doing the pause and nothing else.

    I'm not out of code space.... just needed to know if I was on the correct track..<<

    I wrote a very simple program that used only pause.

    Without the gosub, I got 50 bytes.
    With the Gosub, I got 52 bytes.

    Granted this was *only* one gosub. I guess I could have modified it to do 3 or 4 gosubs, and checked without a gosub too.
    Then i could have compared the size of the files and found out if multiple gosubs would save you space, and how much space.

    I may go to compilespot.com and check it out later today...during my lunch hour or something...

    I know in my borland compilers, it "compresses" the code if you have multilple duplicating things. I seriously doubt if PBP does <g>.

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  5. #5
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Excuse my question, but doesn't tcbcats have a compiler?

Similar Threads

  1. Graphic LCD with PICbasic pro
    By amindzo in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 25th November 2012, 11:45
  2. Old and beyond help ?
    By DavidFMarks in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 11th December 2008, 15:23
  3. shifting problem
    By helmut in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 31st August 2007, 06:11
  4. Output PIC module
    By freelancebee in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th September 2005, 20:10
  5. ds1307 from f877 to f452 not work
    By microkam in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th July 2005, 00:02

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