The code below is adopted from the works of Niloy Mondal, another Assembly/C programmer.
#include stdio.h /*enclose the libraries between < > */
_AX=0; //file register with 0
geninterupt(0x33); //generate 33h interrupt
//check the return values now
if (_AX == 0)
printf("Mouse is not installed. ");
printf ("Mouse is installed. ");
After typing this program in C, compile and run this. It will determine if your mouse is physically connected to your PC or not.