[buug] mapped io

johnd john at jjdev.com
Wed Dec 19 11:16:37 PST 2001

Can someone refer me to some docs on how to read from a port address?

something like the inp funtion from the dos lib conio.h

I'm looking for something to do this:

I/O Mapped I/O

To place things in the I/O map the CPU must be forced to activate the I/O control signals. The machine code instruction for IN and OUT perform this action. There are no corresponding ANSI-C commands. But almost every i86 architecture C compiler provides some support. Two or more functions are declared in the conio.h header file. Then these functions are defined and linked into the C library. These two groups of functions are known as inp and outp. 

Inp Function

The inp functions has one argument that is the port address. The function reads the port and returns the data read at that port address. Typically there is one function to read a single byte called inp and a second function to read a word called inpw. These functions are declared as follows:

int inp(unsigned port); 

unsigned inpw(unsigned port);

To read the byte at port address 0x45 and to save that byte in the integer ch would be coded as:

#include <conio.h> 

int ch; 

. . . 


More information about the buug mailing list