PDA

View Full Version : GOSUB to do a pause?



tcbcats
- 11th August 2004, 04:01
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

Dwayne
- 11th August 2004, 04:15
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

tcbcats
- 11th August 2004, 07:15
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

Dwayne
- 11th August 2004, 15:05
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

NavMicroSystems
- 11th August 2004, 15:21
Excuse my question, but doesn't tcbcats have a compiler?