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 58H (decimal 88) gets or sets the method DOS uses to allocate
  free memory to programs. You can choose from three different memory
  allocation strategies. (See Figure 17-16.) Each strategy assumes that
  memory resources are broken into blocks of various sizes and that each
  block can be randomly allocated to a program or freed, depending on the
  specific requirements of DOS and of each program. You might think that all
  free memory would be located in one large block just above where a program
  ends, but terminate-and-stay-resident programs and device drivers can
  reserve memory blocks and thereby fragment available memory into two or
  more smaller blocks.

  Value in Function 58H                Strategy
  --------------------------------------------------------------------------
  0                                    First fit
  1                                    Best fit
  2                                    Last fit
  --------------------------------------------------------------------------

  Figure 17-16.  DOS memory allocation strategies.

  When DOS responds to a request for memory allocation, it searches through
  a list of free-memory blocks, starting at the lowest available address and
  working upward. With the first-fit strategy, DOS allocates the first free
  block of memory large enough to accommodate the memory- allocation
  request. With the last-fit strategy, DOS allocates the last free block in
  the list that is large enough. With the best-fit strategy, DOS searches
  the entire list and allocates the smallest block that is large enough. DOS
  uses the first-fit strategy by default.

  To obtain the allocation strategy from DOS, call function 58H with AL =
  00H. DOS reports the current allocation strategy (00H, 01H, or 02H) in AX.
  To set the allocation strategy, call this function with AL = 01H and the
  desired strategy (00H, 01H, or 02H) in BX. The only error detected by this
  function occurs when you call it with AL > 01H, in which case the carry
  flag is set and AX contains an error code of 01H (invalid function). This
  function does not validate the value you pass in BX, so be careful to use
  a valid value (00H, 01H, or 02H) when you set the allocation strategy.

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