Organizing your code into procedures that execute specific tasks divides large programs into manageable units, allows for separate testing, and makes code more efficient for repetitive tasks.
Assembly-language procedures are comparable to functions in C; subprograms, functions, and subroutines in Basic; procedures and functions in Pascal; or subroutines and functions in FORTRAN.
Two instructions control the use of assembly-language procedures; CALL pushes the return address onto the stack and transfers control to a procedure, and RET pops the return address off the stack and returns control to that location.
The PROC and ENDP directives mark the beginning and end of a procedure. Additionally, PROC can automatically
Preserve register values that should not change but that the procedure might otherwise alter
Set up a local stack pointer, so that you can access parameters and local variables placed on the stack
Adjust the stack when the procedure ends
Sections 7.3.1 through 7.3.3 give information on techniques for calling procedures and accessing parameters. Sections 7.3.4 through 7.3.5 show how to allocate and access local variables and parameters.
Sections 7.3.6 and 7.3.7 introduce new directives in MASM 6.0 to further automate calling procedures and passing arguments. The PROTO directive allows you to declare prototypes for your procedures. INVOKE handles procedure calls and stack cleanup. Section 7.3.8 describes the automatic stack setup and cleanup generated with PROC.