Tc2中如何具体的使用1M以上XMS内存?非常感谢您的回答!
rdr 2000-02-18 08:43:00 我找来如下函数,但不会具体使用,万分感谢!
#include <dos.h>
#include <stdio.h>
static void far (*XMS_Faction)();
static void get_xmsentry(void)
{ _AX=0x4310; geninterrupt(0x2f);
XMS_Faction=(void far *)MK_FP(_ES,_BX);
}
int xmsinstalled(void)
{ int a; _AX=0x4300; geninterrupt(0x2f); a=_AL;
if(a!=0x80){ cputs("NO MXS Installed !");return 0;}
get_xmsentry(); return a;
}
int xmssize(unsigned int b) /* b:kb */
{ _AH=8;XMS_Faction();
if(_AX<b)return 0;/* NO Enough XMS for block ! */
else return _AX;/* return MaxSize of XMS */
}
unsigned int xmsalloc(unsigned int b) /* b: kb */
{ unsigned int a;
_DX=b;_AH=9;XMS_Faction(); a=_DX;
if(_AX!=1) return 0;
return a;
}
void xmsfree(unsigned int describ_word)
{ _DX=describ_word; _AH=0x0a; XMS_Faction(); }
/*
int xmsmove(struct para_table *q)
{ unsigned seg,off;
seg=FP_SEG((void far *)q); off=FP_OFF((void far *)q);
_DS=seg; _SI=off; _AH=0x0b; XMS_Faction();
if(_AX!=1) return 0;
return 1;
}
unsigned moveblocktoxms(char far *source,unsigned len,unsigned block,long blockoff)
{ struct para_table p;
p.block_length=len; p.source_handle=0;
p.source_addr.i[0]=FP_OFF(source); p.source_addr.i[1]=FP_SEG(source);
p.targ_handle=block; p.targ_addr.t=blockoff;
return xmsmove(&p);
}
unsigned moveblocktomem(char far *targ,unsigned xms_handle,
unsigned block_len,long blockoff )
{ struct para_table p;
p.block_length=block_len; p.source_handle=xms_handle;
p.source_addr.t=blockoff; p.targ_handle=0;
p.targ_addr.i[0]=FP_OFF(targ); p.targ_addr.i[1]=FP_SEG(targ);
return xmsmove(&p);
}
*/
main()
{
unsigned int bs,ai=0,ax=0,dx=0;
bs=100;
ai=xmsinstalled();
ax=xmssize(bs); /* b:kb */
dx=xmsalloc(bs); /* b: kb */
xmsfree(bs);
}