The question was how can subroutines make programs run faster.
rblopena, you are right, you can save CPU time by using subroutines as long as they are not called contuinously. When subroutines are not called then subroutines use no CPU time. The main scan of a well organinzed program may consist mainly of conditional calls to subroutines.
I routinely put the inintialization code in a subroutine that gets called only when the first scan is active. The rest of the time this initialization subroutine has no affect on the program or the scan time. This is much better than putting the initialization code in the main loop where is get scanned and consumes CPU time.
Seppo is correct that there is extra overhead in calling a subroutine. The program will execute more slowly if the subroutine is called every scan. I would be faster to put the code in-line in theis case. However, it may make the main program to long a look disorgranized.
CMF, is correct that jumps over sections of code will save time, but I like the concept of conditionally call subroutines better.
Eric, the DIFU/D is just a way to keep from continously call a subroutine. This is one way to make sure a subroutine gets called only when it required. Another trick I have used to to have the subroutine clear the bit that activated it. Seppo must use this trick if he doesn't use one shots.