/*==================== basic IO access : port_write_then_read.c =============== PURPOSE - show port write and read. - usage ./port_write_then_read port_num value */ #include #include #include int main(int argc, char *argv[]) { /*--- check have parameter between 0-255) */ if (argc != 3) { printf(" Usage is \"./port_value port_num write_value\", 888 = LP1 data port.\n") ; exit( -1) ; } /*--- Output a byte to a port.*/ int port_num = atoi( argv[1]) & 0x3FF ; char value = atoi( argv[2]) & 0xFF ; outb( value, port_num); /*--- Read the data byte port.*/ printf(" Wrote 0x%X to port 0x%X, read back 0x%X.\n", value, port_num, inb( port_num) ); exit(0); }