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]

  The multiplex interrupt, interrupt 2FH (decimal 47), is used to
  communicate with memory-resident programs. This interrupt wasn't used in
  DOS version 1, but in version 2 the RAM-resident print spooler PRINT used
  it. In DOS versions 3.0 and later, the protocol for using interrupt 2FH
  was standardized to allow multiple memory-resident programs to share the
  interrupt. (That's why this interrupt is called the multiplex interrupt.)

  --------------------------------------------------------------------------
  NOTE:
    Most of the material in this chapter applies to all versions of DOS;
    however, interrupt 2FH is available only with DOS versions 3.0 and
    later.
  --------------------------------------------------------------------------

  To use the multiplex interrupt, you must write a memory-resident TSR
  program that contains an interrupt handler for interrupt 2FH. (Use the DOS
  Terminate-and-Stay-Resident service to do this.) The transient portion of
  the TSR program must copy the address of the previous interrupt 2FH
  handler from the interrupt 2FH vector (0000:00BCH) to a variable in the
  resident portion. The transient portion then updates the interrupt 2FH
  vector with the address of the resident portion's interrupt 2FH handler so
  that when interrupt 2FH is subsequently executed, the TSR's handler gets
  control.

  When interrupt 2FH is executed, the resident interrupt 2FH handler does
  the following:

  IF      AH=IDnumber
  THEN    process the value in AL
          return from the interrupt (IRET)
  ELSE    jump to the previous interrupt 2FH handler

  This simple logic lets several memory-resident programs use the multiplex
  interrupt to communicate. The key is that every memory-resident program
  must have a unique ID number. Your program's interrupt 2FH handler should
  recognize one of the 64 values between C0H and FFH. (There are 256
  possible ID numbers, of course, but Microsoft and IBM reserve numbers 00H
  through BFH for use by DOS utilities.)

  When your program's interrupt 2FH handler gains control, it must first
  check the value in register AH. If the value in AH matches the program's
  ID number, the handler looks in AL to decide what to do next. If the
  values don't match, the handler simply jumps to the address of the
  previous interrupt 2FH handler.

  The interrupt 2FH handler considers the value in AL to be a function
  number and processes it accordingly, as described in the following
  paragraphs:

  Function 00H has a special meaning. It instructs the interrupt handler to
  return one of two values in AL:

  .  A value of FFH indicates that an interrupt 2FH handler is resident in
     memory and available to process other function numbers.

  .  A value of 01H indicates that the ID number in AH is in use.

  So, to detect whether a particular TSR program is installed in memory, a
  program executes interrupt 2FH with the TSR's ID number in AH and with AL
  = 00H. If the TSR is present in memory, it returns AL = FFH. If another
  TSR is using the ID number for its own purposes, that TSR returns AL =
  01H. Otherwise, any interrupt 2FH handlers in memory simply ignore the
  interrupt, causing the interrupt to return AL = 00H.

  The best-documented example of how to use the multiplex interrupt is the
  PRINT program supplied with DOS versions 3.0 and later. By examining how
  PRINT uses the multiplex interrupt, you can make better use of this
  interrupt in your own memory-resident programs.

  PRINT's multiplex ID number is 1. Any time interrupt 2FH is executed with
  this ID number in AH, PRINT's memory-resident interrupt handler processes
  the interrupt. Because six different functions are defined by PRINT (see
  Figure 15-4), a call to PRINT consists of executing interrupt 2FH with AH
  = 01H and a function number in AL.

  Each time you run PRINT, the program executes interrupt 2FH with AH = 01H
  and AL = 00H. The first time you run the program, the value returned in AL
  by the interrupt is 00H, so the program installs itself in memory. When
  you invoke PRINT a second time, the value returned in AL as a result of
  executing the multiplex interrupt with AH = 01H is FFH. This value is
  placed there by the memory-resident copy of PRINT, so the second
  invocation of the program knows not to install itself in memory.

  The second and subsequent invocations of PRINT can request any of five
  different functions by passing a function number to the first,
  memory-resident copy of the program. You could also use these functions in
  your own programs by placing the value 01H (PRINT's multiplex ID) in
  register AH, the function number in register AL, and then issuing
  interrupt 2FH.

  Function Number                      Description
  --------------------------------------------------------------------------
  00H                                  Get installed status.
  01H                                  Submit file to print.
  02H                                  Remove file from print queue.
  03H                                  Cancel all files in print queue.
  04H                                  Hold print queue.
  05H                                  Release print queue.
  --------------------------------------------------------------------------

  Figure 15-4.  PRINT functions defined through the multiplex interrupt.

  Function 01H submits a file to the print spooler for printing. To tell
  PRINT what is to be printed, you set the register pair DS:DX to point to a
  5-byte area called a submit packet. The first byte of the submit packet is
  a level code (which should be 0). The remaining 4 bytes of the submit
  packet are the segmented address of an ASCIIZ string (see page 350) that
  defines the pathname of the file to be printed. The pathname must be a
  single file. The global filename characters * and ? are not allowed.

  When a file is submitted using this function, it is added to the end of
  the queue, or list, of files to be printed. The files are printed in turn
  and are dropped from the queue after they're printed.

  Function 02H cancels individual files queued for printing. The register
  pair DS:DX points to the ASCIIZ string that defines which file is to be
  removed from the queue. In this case, the global filename characters * and
  ? can be used. In function 02H, DS:DX points directly to the filename
  string, rather than to a submit packet that points to the string.

  Function 03H cancels all files queued for printing. For both functions 02H
  and 03H, if the file currently being printed is canceled, PRINT stops
  printing the file and prints a short message to that effect.

  Function 04H gives programs access to the print queue so they can inspect
  it. The queue is frozen when this function is requested, so you don't have
  to worry about the list changing while you inspect it. Issuing any other
  PRINT function call will unfreeze the queue. Function 04H returns a
  pointer in the register pair DS:SI that points to a list of filenames
  queued for printing. Entries in the list are strings with a fixed length
  of 64 bytes. The end of the list is indicated by an entry that begins with
  a zero byte.

  The queue freeze imposed by function 04H doesn't need to halt the printing
  operation. But function 04H will suspend the removal from the queue of a
  file that is finished printing.

  Function 05H is essentially a null function that does nothing but unfreeze
  the queue of filenames frozen by function 04H. (The other four functions
  can do this, too.)

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