Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteiTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
TSR stands for “terminate and stay resident”: a DOS program ends its initial run and returns control to its parent, while keeping selected code and data in memory for later use. In MS-DOS, the documented method is Interrupt 21h function 31h.
What does “terminate and stay resident” mean?
The phrase describes two things happening together. The program’s first execution ends, so DOS can run the parent program or return to the command prompt; meanwhile, a portion of the program remains allocated in memory. “Terminate” therefore does not mean that all of the program’s memory is immediately released.
The retained code can later provide a service or respond to an event. A TSR might install an interrupt handler or expose another entry point that software can invoke after the initial setup has finished. The term is a historical DOS programming concept, not a description of an ordinary modern application remaining open in the background. Programmer’s WorkBench glossary: TSR (Defined)
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →How does a TSR work?
- Install: The program initializes and may install an interrupt handler or set up another way for later code to reach it.
- Keep the resident portion: It leaves only the memory needed for future work allocated; setup code that is no longer needed does not have to remain resident.
- Return to DOS: It terminates its initial execution and gives control back to its parent.
- Respond later: A later interrupt, software call, or other entry point can transfer control to the resident code.
This separation explains the apparent contradiction in the name: the program stops running in the usual foreground sense, but selected parts remain available. The particular activation path depends on how the TSR was designed and installed.
#1 Best Overall
Which DOS service keeps a program resident?
INT 21h function 31h
MS-DOS documents INT 21h function 31h as its terminate-and-stay-resident service. The caller sets AH to 31h; AL carries the return code passed to the parent, and DX specifies how many paragraphs of memory to retain. The service terminates the running program while keeping the specified amount resident. Assembly Language Help: INT 21h Function 31h
Microsoft’s MASM 6.1 Programmer’s Guide identifies function 31h as an MS-DOS service invoked through Interrupt 21h. These are historical MS-DOS interfaces; consult documentation for the specific DOS version when implementing low-level code. Microsoft, MASM 6.1 Programmer’s Guide (1992)
INT 27h
INT 27h is an older terminate-and-stay-resident method. Microsoft’s MASM guide says it was present in then-current MS-DOS versions, but cautions that Microsoft could not guarantee future support and did not recommend relying on it. That statement is a historical recommendation in the guide, not a claim about the behavior of current operating systems.
What were TSR programs used for?
TSRs could remain in memory to make a service available to other programs or to respond to an event. Microsoft’s MS-DOS Programmer’s Reference gives PRINT.EXE as an example: it maintains a print queue and provides functions that other programs can call. Archived Microsoft assembly documentation also illustrates a TSR using a timer interrupt, while the Programmer’s WorkBench glossary describes pop-up utilities as a general use. Microsoft, MS-DOS Programmer’s Reference, Including Version 5 (1991) · Microsoft KnowledgeBase archive: Q39524, TSR in Assembly (last modified 1989-01-12)
Rank #3
- Used Book in Good Condition
The common idea is availability after installation: instead of loading the utility from disk each time, DOS software could reach code that had already been left resident.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

