Function 4Ch End Program

mov al, ReturnValue ;program-defined return value

mov ah, 4Ch ;End Program

int 21h

End Program (Function 4Ch) terminates the current program and returns control to its parent program.

Parameter

ReturnValue

Specifies a return value. If the terminated program was started by Load and Execute Program (Function 4B00h), the parent program can use Get Child-Program Return Value (Function 4Dh) to retrieve this value.

Return Value

This function does not return.

Comment

This function performs the following actions:

Flushes the file buffers and closes files, unlocking any regions locked by the program.

Restores Termination Address (Interrupt 22h) from offset 0Ah in the PSP (pspTerminateVector field).

Restores the address of CTRL+C Handler (Interrupt 23h) from offset 0Eh in the PSP (pspControlCVector field).

Restores the address of Critical-Error Handler (Interrupt 24h) from offset 12h in the PSP (pspCritErrorVector field).

Frees any memory owned by the terminating program.

After completing these actions, this function transfers control to the address specified by offset 0Ah in the PSP.

See Also

Function 00h Terminate Program
Function 31h Keep Program
Function 4Dh Get Child-Program Return Value
Function 5Ch Lock/Unlock File
Interrupt 22h Termination Address
Interrupt 23h CTRL+C Handler
Interrupt 24h Critical-Error Handler