Dispatch Table Mechanism

All API functions are accessed using a two-part number. A one-byte class number in the AH register and a one-byte function number in the AL register combine to form the Class/Function number in the AX register.

The Class table is an array of far pointers 128 elements deep (from 0h to 7Fh). If a particular class is available, the associated element in the class table points to the function table. For unimplemented classes, the pointer value is 0, that is both the segment and offset values are 0.

The Function table is composed of two parts, the Function Table header and the Function offsets. The Function Table header holds bank switching, Function Code Segment value, the starting and ending Function numbers available in the table, and other related information.

The function tables for individual classes are implemented as a linked list. A function table can be overridden by another function table, allowing the functions in the overriding function table to be invoked instead of the original functions. API calls can also invoke the overridden functions, which is discussed in "Using Function Table Enabling and Disabling" on page 7-192.

When an API call is made, the following procedure is invoked

  1. Get function table pointer from class table.
  2. If function table pointer is 0, set APIError and return to caller.
  3. Check function table header to determine if the function is present in the table.
  4. If the function is present, invoke the function and on return from the function, return to caller.
  5. Else, get linked function table pointer from function table header, and repeat from step 2.

In the event that the Class/Function is not found, a global variable in the System Manager, APIError, is set to the Class/Function which failed.