Turbo C and Borland C/C++ provide access to the I/O ports on the 80x86 CPU via the predefined functions inportb / inport and outportb / outport.
int inportb(int portid); /* returns a byte read from the I/O port portid */ int inport(int portid); /* returns a word read from the I/O port portid */ void outportb(int portid, unsigned char value); /* writes the byte value to the I/O port portid */ void outport(int portid, int value); /* writes the word value to the I/O port portid */
#include <stdio.h> #include <dos.h> #define Data 0x378 #define Status 0x379 #define Control 0x37a unsigned char Bits; outportb(Data,Bits); /* output data */ Bits = inportb(Status); /* input data */ |
last updated: 13-Mar-97 Ian Harries <ih@doc.ic.ac.uk>