XMS Usage with Compact, Large, or Huge Memory Model

Last reviewed: July 17, 1997
Article ID: Q76064
6.00 6.00a 6.00ax 7.00 | 1.00 1.50
MS-DOS                 | WINDOWS
kbprg

The information in this article applies to:

  • Microsoft C for MS-DOS, versions 6.0, 6.0a, and 6.0ax
  • Microsoft C/C++ for MS-DOS, version 7.0
  • Microsoft Visual C++ versions 1.0 and 1.5

SUMMARY

The "R6001: Null pointer assignment" error may be encountered when writing XMS functions in the compact, large, or huge memory model with inline assembly. The problem will appear if the variables used in the inline assembly are global.

MORE INFORMATION

The XMS comes with a library that works only with the small memory model. A programmer who wants to implement the XMS with another memory model must write his or her own library routines.

If you use the sample code provided in the XMS to find the address of the XMS driver with the compact, large, or huge memory model, you must make sure that all variables used in the inline assembly code are declared as local variables.

If you do not use local variables, you will get the "R6001: null pointer assignment" error.

For more information on the problem with inline assembly accessing global data, please query on the following words:

   inline and assembly and incorrectly and accesses and far and labels

Below is a sample program that finds the address of the XMS driver, uses that address to get its version, and then displays it. The program works with all memory models.

Sample Code

/***************************************************
 LXMS.C : Sample program to get XMS driver address
          and make a call to get its version. This
          sample works with the large memory model
          through inline assembly.

          The trick here is to define all variables
          used in the inline assembly as local.

****************************************************/

#include <stdlib.h>
#include <stdio.h>
#include <dos.h>

#define GET_VERSION 0

unsigned xms_call( void (_far *xms_driver)(),
                   unsigned call_number )
{
   _asm
   {
      mov ax, call_number
      call far ptr [xms_driver]
      mov  call_number, ax
   }
   return( call_number );
}

void main ( void )
{
   unsigned int status;
   void (_far *xms_driver) ( void );
   unsigned int xms_version;

   status = 0;
   _asm
   {
      mov ax, 4300h
      int 2Fh
      cmp al, 80h
      jne noXMS

      ;---- Get Driver Address for Later Requests ---

      mov ax, 4310h
      int 2Fh
      mov word ptr [xms_driver], bx
      mov word ptr [xms_driver+2], es
      jmp End

noXMS:
      mov xms_version, 0
      mov status, ax
End:
   }
   xms_version = xms_call( xms_driver, GET_VERSION );
   if(!xms_version) status = 80 ;
   if(!status)
     printf("\n XMS Driver %x Detected.\n",xms_version);
}


Additional reference words: kbinf 1.00 1.50 6.00 6.00a 6.00ax 7.00 extended
memory
KBCategory: kbprg
KBSubcategory: CLngIss
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.