Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Peter Norton Programmer's Guide - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

  Function 31H (decimal 49) terminates a program and leaves part of the
  program resident in memory. Except for the fact that function 31H lets you
  reserve memory for a memory-resident program, its function is the same as
  that of the program termination function (function 4CH). You call
  function 31H with a return code value in AL and with the number of
  paragraphs of memory to reserve for the program in DX.

  Before you use function 31H, you should generally carry out the following
  steps:

  1.  Call function 30H to verify that the DOS version is 2.0 or later.
      Function 31H isn't supported in DOS version 1.

  2.  Call function 49H to free the memory allocated to the program's
      environment block. (The word at offset 2CH in the program's PSP
      contains the paragraph address of the environment block.)

  3.  Determine the amount of memory to reserve for the resident program.
      This value must include the 16 paragraphs reserved for the program's
      PSP in addition to contiguous memory reserved for the program itself.
      This value does not include memory allocated dynamically by the
      program using function 48H.

  4.  Call function 31H to terminate the program.

  Like function 4CH, function 31H restores the interrupt vectors for
  interrupts 22H (Terminate Address), 23H (Ctrl-C Handler), and 24H
  (Critical Error Handler) to the DOS default values; therefore, you cannot
  use this function to install memory-resident handlers for these
  interrupts.

  Function 31H is much more flexible than the Terminate-and-Stay-Resident
  service supported through interrupt 27H. You should always use function
  31H in your TSR programs unless you are concerned about maintaining
  compatibility with DOS version 1.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson