subroutine

(in computers) a section of a program which can be called up as required from various points in the main program, returning the user to the point at which it was called up.