Code:
static void far(* __xms_driver)(void) = 0; //it stores the xms driver entry function address
bool xmsInit(void) //get the xms driver entry function
{
union REGS r;
struct SREGS s;
unsigned long driver_entry = 0;
if(__xms_driver != 0) return true;
r.x.ax = 0x4300;
int86(0x2f, &r, &r);
if(r.h.al != 0x80)
return false;
segread(&s);
r.x.ax = 0x4310;
int86x(0x2f, &r, &r, &s);
driver_entry = s.es;
driver_entry <<= 16;
driver_entry += r.x.bx;
__xms_driver = (void (far*)())driver_entry;
return true;
}
bool __xms_mem_move(struct __WXMS_TAG far* xms_ptr)
{
int segs, offs, status;
int ds_, si_;
segs = FP_SEG(xms_ptr);
offs = FP_OFF(xms_ptr);
ds_ = _DS;
si_ = _SI;
_AH = 0xb;
_DS = segs;
_SI = offs;
__xms_driver(); //crashed here!!!!!!!!!!!!!!!!!!! divided by zero
status = _AX;
_SI = si_;
_DS = ds_;
return (status == 1)?(true): (false);
}
compiler is TC2, memory model is large, i really dont know what causes the program crashed