XMS Usage with Compact, Large, or Huge Memory ModelLast reviewed: July 17, 1997Article ID: Q76064 |
6.00 6.00a 6.00ax 7.00 | 1.00 1.50
MS-DOS | WINDOWSkbprg
The information in this article applies to:
SUMMARYThe "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 INFORMATIONThe 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 labelsBelow 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 0unsigned 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 EndnoXMS: mov xms_version, 0 mov status, axEnd: } 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
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |