I/O Port Access in Watcom C

Watcom C provides access to the I/O ports on the 80x86 CPU via the predefined functions inp / inpw and outp / outpw.

  unsigned int inp(int portid);   /* returns a byte read from the I/O port portid */

 unsigned int inpw(int portid);   /* returns a word read from the I/O port portid */

 unsigned int outp(int portid,    /* writes the byte value to the I/O port portid */
                  int value);     /* returns the data actually written            */

unsigned int outpw(int portid,    /* writes the word value to the I/O port portid */
             unsigned int value); /* returns the data actually written            */
portid can be any unsigned integer in the range 0-65535

#include <conio.h>

#define Data    0x378
#define Status  0x379
#define Control 0x37a

int Bits,     /* 0 <= Bits <= 255 */
    Dummy;

Dummy = outp(Data,Bits); /* output data */

Bits = inp(Status);      /*  input data */                                 


[ Back to Reading & Writing Data ]

last updated: 13-Mar-97 Ian Harries <ih@doc.ic.ac.uk>