Assembly Language Help (alang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
Int 21h Function 4Ch
 Summary Example                         Up Contents Index Back
────────────────────────────────────────────────────────────────────────────
 
     This function performs the following actions:
 
        ■ All memory belonging to the process is released.
 
        ■ File buffers are flushed and any open handles for files or
          devices owned by the process are closed.
 
        ■ The termination handler vector (Int 22h) is restored from
          PSP:000Ah.
 
        ■ The CTRL+C handler vector (Int 23h) is restored from
          PSP:000Eh.
 
        ■ The critical-error handler vector (Int 24h) is restored from
          PSP:0012h.
 
        ■ Control is transferred to the termination handler.
 
     If the program is returning to COMMAND.COM, control transfers to
     the resident portion and the transient portion is reloaded if
     necessary. If a batch file is in progress, the next line of the
     fil` is fetched and interpreted; otherwise, a prompt is issued
     for the next user command.
 
     This is the preferred method of termination for application
     programs because it allows a return code to be passed to the
     parent program and does not rely on the contents of any segment
     register. Other methods of performing a final exit are Int 20h,
     Int 21h Function 00h, Int 21h Function 31h, and Int 27h.
 
     Any files that have been opened using FCBs and modified by the
     program should be closed before program termination; otherwise,
     data may be lost.
 
     The return code can be retrieved by the parent process with Int
     21h Function 4Dh (Get Return Code). It can also be tested in a
     batch file with an IF ERRORLEVEL statement. By convention, a
     return code of zero indicates successful execution, and a nonzero
     return code indicates an error.
 
     [Version 3.0+]
     If the program is running on a network, it should remove all locks
     it has placed on file regions before terminating.
                                    -♦-