/*==================== basic IO access : port_read.c =============== PURPOSE - show port read. - usage ./port_read port_num */ #include #include #include #include #include int main( int argc, char *argv[] ) { // check have one parameter: if ( argc != 2 ) { cerr << "usage: " << argv[ 0 ] << " port_num\n" << "Port number is in hexadecimal.\n"; exit( 1 ); } // Read the data byte port: int port_num = strtol( argv[1], NULL, 16 ) & 0x3ff; int value = inb( port_num ) & 0xff; cout << showbase << " Read from port " << hex << port_num << " (" << dec << port_num << "), data value " << hex << value << " (" << dec << value << ").\n"; exit( 0 ); }