When DOS takes control after a function call, it switches to an internal stack. Registers which are not used to return information (other than AX) are preserved. The calling program's stack must be large enough to accomodate the interrupt system - at least 128 bytes in addition to other interrupts.
DOS actually maintains three stacks -
stack 1: 384 bytes (in DOS 3.1) for Int/25 and Int/26, as well as Dos Functions Int/21f/00, Int/21f/0D and up.
stack 2: 384 bytes (in DOS 3.1) for Int/21f/01 through Int/21f/0C.
stack 3: 48 bytes (in DOS 3.1) for functions 0Dh and above. This stack is the initial stack used by the Int/21 handler before it decides which of the other two to use. It is also used by Int/21f/59 (get extended error), and 01h to 0Ch if they are called during an Int/24 (critical error) handler. Int/21f/33 (get/set break flag), Int/21f/50 (set process ID), Int/21f/51 (get process ID) and Int/21f/62 (get PSP addr) do not use any DOS stack under DOS 3.x (under 2.x, 50h and 51h use stack 2).
IBM and Microsoft made a change back in DOS 3.0 or 3.1 to reduce the size of DOS. They reduced the space allocated for scratch areas when interrupts are being processed. The default seems to vary with the DOS version and the machine, but 8 stack frames seems to ring a bell. That means that if you get more than 8 interrupts at the same time, clock, disk, printer spooler, keyboard, com port, etc., the system will crash. It seems to happen usually on a network. The CONFIG.SYS DOS\Commands -STACKS=16,256 means allow 16 interrupts to interrupt each other and allow 256 bytes for each for scratch area. Eight is marginal.
DOS 3.2 does some different stack switching than previous versions. The interrupts which are switched are:
Int/02, Int/08, Int/09, Int/0A, Int/0B, Int/0C, Int/0D, Int/0E,Int/70, Int/72, Int/73, Int/74, Int/75, Int/76, Int/77.
DOS 3.2 has a special check in the initialization code for a PCjr and doesn't enable stack switching on that machine.
Comments: