I/O Port Access in Microsoft Visual C++
11:13 AM // 0 comments // Sajib Barua // Category: Interfacing //Microsoft Visual C/C++ provides access to the I/O ports on the 80x86 CPU via the predefined functions _inp / _inpw and _outp / _outpw.
int _inp(unsigned portid); /* returns a byte read from the I/O port portid */
unsigned _inpw(unsigned portid); /* returns a word read from the I/O port portid */
int _outp(unsigned portid, /* writes the byte value to the I/O port portid */
int value); /* returns the data actually written */
unsigned _outpw(unsigned portid, /* writes the word value to the I/O port portid */
unsigned value); /* returns the data actually written */
portid can be any unsigned integer in the range 0-65535
#include /* required only for function declarations */
#define Data 0x378
#define Status 0x379
#define Control 0x37a
int Bits, /* 0 <= Bits <= 255 */
Dummy;
Dummy = _outp(Data,Bits); /* output data */
