Installs TSR (terminate-and-stay-resident) programs in memory, using system call 0x31.
#include <dos.h>
void _dos_keep( unsigned retcode, unsigned memsize );
retcode | Exit status code | |
memsize | Allocated resident memory (in 16-byte paragraphs) |
The _dos_keep routine installs TSRs (terminate-and-stay-resident programs) in memory, using system call 0x31.
The routine first exits the calling process, leaving it in memory. It then returns the low-order byte of retcode to the parent of the calling process. Before returning execution to the parent process, _dos_keep sets the allocated memory for the now-resident process to memsize 16-byte paragraphs. Any excess memory is returned to the system.
The _dos_keep function calls the same internal routines called by exit. It therefore takes the following actions:
Calls any functions that have been registered by atexit or _onexit calls.
Flushes all file buffers.
Restores interrupt vectors replaced by the C startup code. The primary one is interrupt 0 (divide by zero). If the emulator math library is used and there is no coprocessor, interrupts 0x34 through 0x3D are restored. If there is a coprocessor, interrupt 2 is restored.
Do not use the emulator math library in TSRs unless you are familiar with the startup code and the coprocessor. Use the alternate math package if the TSR must do floating-point math.
Do not run programs that use _dos_keep from inside the Microsoft Programmer's WorkBench environment, since doing so causes subsequent memory problems. The _dos_keep function terminates the program when executed in the Programmer's WorkBench environment.
None.
Standards:None
16-Bit:DOS
32-Bit:None