The ExitProcess function
The ExitProcess function terminates the process, returning the exit code passed in the AL register. This makes it possible to terminate the program correctly and pass information about the result of its execution.
Parameters: AL: return code.
Return value: AL: return code (remains unchanged).
Flag state: The function does not modify the flags.
Program source code
An example program for the Intel 8086 assembler demonstrating the use of the ExitProcess function to terminate the process with a return code.
title .model small .stack 100h code segment public ; Start of the code segment assume cs:code include Handyfar.inc ; Include the file with functions main proc ; Start of the main procedure call SetDataSegment ; Call the SetDataSegment procedure xor al, al ; Clear the al register call ExitProcess ; Call the ExitProcess procedure main endp ; End of the main procedure code ends ; End of the code segment end main ; End of file. The main procedure is the entry point
Return code: 0
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".