I'm writing a program, where I have to use
about 30 times. Should I make this as subroutine, will it be more space efficient, or compiler takes care of that?Code:sound xma,[125,10]
pause 100
Printable View
I'm writing a program, where I have to use
about 30 times. Should I make this as subroutine, will it be more space efficient, or compiler takes care of that?Code:sound xma,[125,10]
pause 100
Henrik could give more detailed answer, in the meantime...
A loop of 2 or 3 is structured but not always smaller in code (especially when short like yours).
But 30 times, I'd go with a loop.
You can always compile both ways and check code size (Microcode Studio posts it at the bottom).
Robert
Hi,
What happend to simply trying a couple of things yourself and see instead of just asking. I just tried it here and it took less than five minutes to try both ways and write this reply.
Same routine repeated 30 times: 458 bytes
Subroutine and 30 GOSUBs: 201 bytes
This was compiled for a 16F877A whcih is the device you had questions about the other day. And no, the compiler doesn't decide for you - it's up to you as the programmer.
/Henrik.
YAY! I guessed right!
Thanks!
I've tried to look at microcode studio displayed code size, but it does not seems to be in relation with actual code - I've added say 20 lines of new code, but sometimes size gets increased by only 1-2 words, sometimes - 200.