How to use inport and outport in BCB?
1998-09-13 00:00:00



In Standard Win32 Platform, it is not allow to use inport and outport. It should be instead by writing Device Driver. But, we can use asm in Windows 95/98 to do this:

File List bcbio.h :

void outportb(unsigned short int port,unsigned char value)
{
__emit__(0x8b,0x95,&port);
//mov edx,*(&port);
__emit__(0x8a,0x85,&value);
//mov al,*(&value);
__emit__(0x66,0xee);
//out dx,al;
}

void outportw(unsigned short int port,unsigned short int value)
{
__emit__(0x8b,0x95,&port);
//mov edx,*(&port);
__emit__(0x66,0x8b,0x85,&value);
//mov ax,*(&value);
__emit__(0xef);
//out dx,ax;
}

unsigned char inportb(unsigned short int port)
{
unsigned char value;
__emit__(0x8b,0x95,&port);
//mov edx,*(&port);
__emit__(0x66,0xec);
//in al,dx;
__emit__(0x88,0x85,&value);
//mov *(&value),al;
return value;
}

unsigned short int inportw(unsigned short int port)
{
unsigned short int value;
__emit__(0x8b,0x95,&port);
//mov edx,*(&port);
__emit__(0xed);
//in ax,dx;
__emit__(0x66,0x89,0x85,&value);
//mov *(&value),ax;
return value;
}