Subroutine

From HomoExcelsior

Jump to: navigation, search

1. A set of programming instructions designed to perform a specific,

well

defined task. 2. A routine, function, procedure, method.


One calls a routine to transfer control of the code execution to a new point in memory temporarily. The new code path is expected to return control to the place in memory immediately following the instruction which caused the call to the subroutine initially.


Most CPUs have several machine code instructions for calling subroutines, such as jump and return. The jump instruction may store the current position in memory on a stack so that the "return from jump" can return to the code section which made the "subroutine call" (jump).


Some computer programming languages distinguish between subroutine which return values (often called functions), and those which do not (often called procedures).




User groups