Every procedure block opened with the PROC directive must be ended with the ENDP directive.
Syntax
procedure-name ENDPRemarks
If the ENDP directive is not used with the PROC directive, an error occurs. An unmatched ENDP also causes an error.
Note: See the PROC directive in this chapter for more detail and examples of ENDP use.
PUSH AX ; Push third parameter PUSH BX ; Push second parameter PUSH CX ; Push first parameter CALL ADDUP ; Call the procedure ADD SP,6 ; Bypass the pushed parameters . . . ADDUP PROC NEAR ; Return address for near call ; takes two bytes PUSH BP ; Save base pointer - takes two more ; so parameters start at 4th byte MOV BP,SP ; Load stack into base pointer MOV AX,[BP+4] ; Get first parameter ; 4th byte above pointer ADD AX,[BP+6] ; Get second parameter ; 6th byte above pointer ADD AX,[BP+8] ; Get third parameter ; 8th byte above pointer POP BP ; Restore base RET ; Return ADDUP ENDP
In this example, three numbers are passed as parameters for the procedure ADDUP. Parameters are often passed to procedures by pushing them before the call so that the procedure can read them off the stack.