Microsoft KB Archive/76064

{|
 * width="100%"|

XMS Usage with Compact, Large, or Huge Memory Model

 * }

Q76064

-

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, 1.5

-

SUMMARY
The &quot;R6001: Null pointer assignment&quot; 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 &quot;R6001: null pointer assignment&quot; 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. 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(&quot;\n XMS Driver %x Detected.\n&quot;,xms_version); } Additional query words: kbinf 1.00 1.50 6.00 6.00a 6.00ax 7.00 extended memory
 * 1) include 
 * 2) include 
 * 3) include 
 * 4) define GET_VERSION 0
 * 1) define GET_VERSION 0

Keywords : kb16bitonly

Issue type :

Technology : kbVCsearch kbAudDeveloper kbvc150 kbvc100