mov dx, MemSize ;number of paragraphs to keep
mov al, ReturnCode ;code returned by terminating program
mov ah, 31h ;Keep Program
int 21h
Keep Program (Function 31h) ends the current program by returning control to its parent program but leaves (keeps) the program in memory and preserves the program's resources, such as open files and allocated memory.
MemSize
Specifies the number of paragraphs of program code and data to keep in memory. If this parameter is less than 6, the function sets it to 6 before reallocating program memory.
ReturnCode
Specifies the code that is returned to the parent program. If the program terminates normally, ReturnCode should be 00h.
This function does not return.
This function carries out the following actions:
Reallocates program memory to the amount specified by MemSize. Program memory includes only the program segment prefix (PSP) and program data and code. The reallocation does not affect the program's environment block, nor does it affect the memory allocated by the program after it was loaded.
Flushes the file buffers but leaves files open. Any locked regions in the open files remain locked.
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).
After completing these actions, this function transfers execution control to the address specified by offset 0Ah in the PSP.
Function 4B00h Load and Execute Program
Function 4Ch End Program
Function 4Dh Get Child-Program Return Value
Interrupt 22h Termination Address
Interrupt 23h CTRL+C Handler
Interrupt 24h Critical-Error Handler